mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-02 04:22:25 -06:00
fix up more tests, fix missing required changes, etc
This commit is contained in:
parent
61f8da707c
commit
64564496f1
10 changed files with 130 additions and 84 deletions
|
|
@ -371,7 +371,7 @@ func (p *clientAPI) CreateStatus(ctx context.Context, cMsg *messages.FromClientA
|
|||
if status.InReplyToID != "" {
|
||||
// Interaction counts changed on the replied status;
|
||||
// uncache the prepared version from all timelines.
|
||||
p.surface.invalidateStatusFromTimelines(ctx, status.InReplyToID)
|
||||
p.surface.invalidateStatusFromTimelines(status.InReplyToID)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -413,7 +413,7 @@ func (p *clientAPI) CreatePollVote(ctx context.Context, cMsg *messages.FromClien
|
|||
}
|
||||
|
||||
// Interaction counts changed on the source status, uncache from timelines.
|
||||
p.surface.invalidateStatusFromTimelines(ctx, vote.Poll.StatusID)
|
||||
p.surface.invalidateStatusFromTimelines(vote.Poll.StatusID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -565,7 +565,7 @@ func (p *clientAPI) CreateLike(ctx context.Context, cMsg *messages.FromClientAPI
|
|||
|
||||
// Interaction counts changed on the faved status;
|
||||
// uncache the prepared version from all timelines.
|
||||
p.surface.invalidateStatusFromTimelines(ctx, fave.StatusID)
|
||||
p.surface.invalidateStatusFromTimelines(fave.StatusID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -671,7 +671,7 @@ func (p *clientAPI) CreateAnnounce(ctx context.Context, cMsg *messages.FromClien
|
|||
|
||||
// Interaction counts changed on the boosted status;
|
||||
// uncache the prepared version from all timelines.
|
||||
p.surface.invalidateStatusFromTimelines(ctx, boost.BoostOfID)
|
||||
p.surface.invalidateStatusFromTimelines(boost.BoostOfID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -722,7 +722,7 @@ func (p *clientAPI) UpdateStatus(ctx context.Context, cMsg *messages.FromClientA
|
|||
}
|
||||
|
||||
// Status representation has changed, invalidate from timelines.
|
||||
p.surface.invalidateStatusFromTimelines(ctx, status.ID)
|
||||
p.surface.invalidateStatusFromTimelines(status.ID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -875,7 +875,7 @@ func (p *clientAPI) UndoFave(ctx context.Context, cMsg *messages.FromClientAPI)
|
|||
|
||||
// Interaction counts changed on the faved status;
|
||||
// uncache the prepared version from all timelines.
|
||||
p.surface.invalidateStatusFromTimelines(ctx, statusFave.StatusID)
|
||||
p.surface.invalidateStatusFromTimelines(statusFave.StatusID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -895,9 +895,8 @@ func (p *clientAPI) UndoAnnounce(ctx context.Context, cMsg *messages.FromClientA
|
|||
log.Errorf(ctx, "error updating account stats: %v", err)
|
||||
}
|
||||
|
||||
if err := p.surface.deleteStatusFromTimelines(ctx, status.ID); err != nil {
|
||||
log.Errorf(ctx, "error removing timelined status: %v", err)
|
||||
}
|
||||
// Delete the boost wrapper status from timelines.
|
||||
p.surface.deleteStatusFromTimelines(ctx, status.ID)
|
||||
|
||||
if err := p.federate.UndoAnnounce(ctx, status); err != nil {
|
||||
log.Errorf(ctx, "error federating announce undo: %v", err)
|
||||
|
|
@ -905,7 +904,7 @@ func (p *clientAPI) UndoAnnounce(ctx context.Context, cMsg *messages.FromClientA
|
|||
|
||||
// Interaction counts changed on the boosted status;
|
||||
// uncache the prepared version from all timelines.
|
||||
p.surface.invalidateStatusFromTimelines(ctx, status.BoostOfID)
|
||||
p.surface.invalidateStatusFromTimelines(status.BoostOfID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -968,7 +967,7 @@ func (p *clientAPI) DeleteStatus(ctx context.Context, cMsg *messages.FromClientA
|
|||
if status.InReplyToID != "" {
|
||||
// Interaction counts changed on the replied status;
|
||||
// uncache the prepared version from all timelines.
|
||||
p.surface.invalidateStatusFromTimelines(ctx, status.InReplyToID)
|
||||
p.surface.invalidateStatusFromTimelines(status.InReplyToID)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -1154,7 +1153,7 @@ func (p *clientAPI) AcceptLike(ctx context.Context, cMsg *messages.FromClientAPI
|
|||
|
||||
// Interaction counts changed on the faved status;
|
||||
// uncache the prepared version from all timelines.
|
||||
p.surface.invalidateStatusFromTimelines(ctx, req.Like.StatusID)
|
||||
p.surface.invalidateStatusFromTimelines(req.Like.StatusID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -1187,7 +1186,7 @@ func (p *clientAPI) AcceptReply(ctx context.Context, cMsg *messages.FromClientAP
|
|||
|
||||
// Interaction counts changed on the replied status;
|
||||
// uncache the prepared version from all timelines.
|
||||
p.surface.invalidateStatusFromTimelines(ctx, reply.InReplyToID)
|
||||
p.surface.invalidateStatusFromTimelines(reply.InReplyToID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -1225,7 +1224,7 @@ func (p *clientAPI) AcceptAnnounce(ctx context.Context, cMsg *messages.FromClien
|
|||
|
||||
// Interaction counts changed on the original status;
|
||||
// uncache the prepared version from all timelines.
|
||||
p.surface.invalidateStatusFromTimelines(ctx, boost.BoostOfID)
|
||||
p.surface.invalidateStatusFromTimelines(boost.BoostOfID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -346,7 +346,7 @@ func (p *fediAPI) CreateStatus(ctx context.Context, fMsg *messages.FromFediAPI)
|
|||
// Interaction counts changed on the replied status; uncache the
|
||||
// prepared version from all timelines. The status dereferencer
|
||||
// functions will ensure necessary ancestors exist before this point.
|
||||
p.surface.invalidateStatusFromTimelines(ctx, status.InReplyToID)
|
||||
p.surface.invalidateStatusFromTimelines(status.InReplyToID)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -393,7 +393,7 @@ func (p *fediAPI) CreatePollVote(ctx context.Context, fMsg *messages.FromFediAPI
|
|||
}
|
||||
|
||||
// Interaction counts changed, uncache from timelines.
|
||||
p.surface.invalidateStatusFromTimelines(ctx, status.ID)
|
||||
p.surface.invalidateStatusFromTimelines(status.ID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -428,7 +428,7 @@ func (p *fediAPI) UpdatePollVote(ctx context.Context, fMsg *messages.FromFediAPI
|
|||
}
|
||||
|
||||
// Interaction counts changed, uncache from timelines.
|
||||
p.surface.invalidateStatusFromTimelines(ctx, status.ID)
|
||||
p.surface.invalidateStatusFromTimelines(status.ID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -573,7 +573,7 @@ func (p *fediAPI) CreateLike(ctx context.Context, fMsg *messages.FromFediAPI) er
|
|||
|
||||
// Interaction counts changed on the faved status;
|
||||
// uncache the prepared version from all timelines.
|
||||
p.surface.invalidateStatusFromTimelines(ctx, fave.StatusID)
|
||||
p.surface.invalidateStatusFromTimelines(fave.StatusID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -690,7 +690,7 @@ func (p *fediAPI) CreateAnnounce(ctx context.Context, fMsg *messages.FromFediAPI
|
|||
|
||||
// Interaction counts changed on the original status;
|
||||
// uncache the prepared version from all timelines.
|
||||
p.surface.invalidateStatusFromTimelines(ctx, boost.BoostOfID)
|
||||
p.surface.invalidateStatusFromTimelines(boost.BoostOfID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -835,7 +835,7 @@ func (p *fediAPI) AcceptReply(ctx context.Context, fMsg *messages.FromFediAPI) e
|
|||
|
||||
// Interaction counts changed on the replied-to status;
|
||||
// uncache the prepared version from all timelines.
|
||||
p.surface.invalidateStatusFromTimelines(ctx, status.InReplyToID)
|
||||
p.surface.invalidateStatusFromTimelines(status.InReplyToID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -884,11 +884,11 @@ func (p *fediAPI) AcceptRemoteStatus(ctx context.Context, fMsg *messages.FromFed
|
|||
// Interaction counts changed on the interacted status;
|
||||
// uncache the prepared version from all timelines.
|
||||
if status.InReplyToID != "" {
|
||||
p.surface.invalidateStatusFromTimelines(ctx, status.InReplyToID)
|
||||
p.surface.invalidateStatusFromTimelines(status.InReplyToID)
|
||||
}
|
||||
|
||||
if status.BoostOfID != "" {
|
||||
p.surface.invalidateStatusFromTimelines(ctx, status.BoostOfID)
|
||||
p.surface.invalidateStatusFromTimelines(status.BoostOfID)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -917,7 +917,7 @@ func (p *fediAPI) AcceptAnnounce(ctx context.Context, fMsg *messages.FromFediAPI
|
|||
|
||||
// Interaction counts changed on the boosted status;
|
||||
// uncache the prepared version from all timelines.
|
||||
p.surface.invalidateStatusFromTimelines(ctx, boost.BoostOfID)
|
||||
p.surface.invalidateStatusFromTimelines(boost.BoostOfID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -968,7 +968,7 @@ func (p *fediAPI) UpdateStatus(ctx context.Context, fMsg *messages.FromFediAPI)
|
|||
}
|
||||
|
||||
// Status representation was refetched, uncache from timelines.
|
||||
p.surface.invalidateStatusFromTimelines(ctx, status.ID)
|
||||
p.surface.invalidateStatusFromTimelines(status.ID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -1027,7 +1027,7 @@ func (p *fediAPI) DeleteStatus(ctx context.Context, fMsg *messages.FromFediAPI)
|
|||
if status.InReplyToID != "" {
|
||||
// Interaction counts changed on the replied status;
|
||||
// uncache the prepared version from all timelines.
|
||||
p.surface.invalidateStatusFromTimelines(ctx, status.InReplyToID)
|
||||
p.surface.invalidateStatusFromTimelines(status.InReplyToID)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -1192,13 +1192,11 @@ func (p *fediAPI) UndoAnnounce(
|
|||
}
|
||||
|
||||
// Remove the boost wrapper from all timelines.
|
||||
if err := p.surface.deleteStatusFromTimelines(ctx, boost.ID); err != nil {
|
||||
log.Errorf(ctx, "error removing timelined boost: %v", err)
|
||||
}
|
||||
p.surface.deleteStatusFromTimelines(ctx, boost.ID)
|
||||
|
||||
// Interaction counts changed on the boosted status;
|
||||
// uncache the prepared version from all timelines.
|
||||
p.surface.invalidateStatusFromTimelines(ctx, boost.BoostOfID)
|
||||
p.surface.invalidateStatusFromTimelines(boost.BoostOfID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -531,18 +531,21 @@ func (s *Surface) tagFollowersForStatus(
|
|||
|
||||
// deleteStatusFromTimelines completely removes the given status from all timelines.
|
||||
// It will also stream deletion of the status to all open streams.
|
||||
func (s *Surface) deleteStatusFromTimelines(ctx context.Context, statusID string) error {
|
||||
func (s *Surface) deleteStatusFromTimelines(ctx context.Context, statusID string) {
|
||||
s.State.Caches.Timelines.Public.RemoveByStatusIDs(statusID)
|
||||
s.State.Caches.Timelines.Local.RemoveByStatusIDs(statusID)
|
||||
s.State.Caches.Timelines.Home.RemoveByStatusIDs(statusID)
|
||||
s.State.Caches.Timelines.List.RemoveByStatusIDs(statusID)
|
||||
s.Stream.Delete(ctx, statusID)
|
||||
return nil
|
||||
}
|
||||
|
||||
// invalidateStatusFromTimelines does cache invalidation on the given status by
|
||||
// unpreparing it from all timelines, forcing it to be prepared again (with updated
|
||||
// stats, boost counts, etc) next time it's fetched by the timeline owner. This goes
|
||||
// both for the status itself, and for any boosts of the status.
|
||||
func (s *Surface) invalidateStatusFromTimelines(ctx context.Context, statusID string) {
|
||||
func (s *Surface) invalidateStatusFromTimelines(statusID string) {
|
||||
s.State.Caches.Timelines.Public.UnprepareByStatusIDs(statusID)
|
||||
s.State.Caches.Timelines.Local.UnprepareByStatusIDs(statusID)
|
||||
s.State.Caches.Timelines.Home.UnprepareByStatusIDs(statusID)
|
||||
s.State.Caches.Timelines.List.UnprepareByStatusIDs(statusID)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,15 +172,11 @@ func (u *utils) wipeStatus(
|
|||
}
|
||||
|
||||
// Remove the boost from any and all timelines.
|
||||
if err := u.surface.deleteStatusFromTimelines(ctx, boost.ID); err != nil {
|
||||
errs.Appendf("error deleting boost from timelines: %w", err)
|
||||
}
|
||||
u.surface.deleteStatusFromTimelines(ctx, boost.ID)
|
||||
}
|
||||
|
||||
// Delete the status itself from any and all timelines.
|
||||
if err := u.surface.deleteStatusFromTimelines(ctx, status.ID); err != nil {
|
||||
errs.Appendf("error deleting status from timelines: %w", err)
|
||||
}
|
||||
u.surface.deleteStatusFromTimelines(ctx, status.ID)
|
||||
|
||||
// Delete this status from any conversations it's part of.
|
||||
if err := u.state.DB.DeleteStatusFromConversations(ctx, status.ID); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue