From faed35c9388bc28ea0fdfe3aae3b489ca952c006 Mon Sep 17 00:00:00 2001 From: kim Date: Sat, 31 May 2025 17:30:57 +0200 Subject: [performance] cache mute check results (#4202) This separates our the user mute handling from the typeconverter code, and creates a new "mutes" filter type (in a similar vein to the visibility filter) subpkg with its own result cache. This is a heavy mix of both chore given that mute calculation shouldn't have been handled in the conversion to frontend API types, and a performance bonus since we don't need to load and calculate so many things each time, just the single result each time with all necessary invalidation handled by database cache hooks. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4202 Co-authored-by: kim Co-committed-by: kim --- internal/processing/workers/fromfediapi.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'internal/processing/workers/fromfediapi.go') diff --git a/internal/processing/workers/fromfediapi.go b/internal/processing/workers/fromfediapi.go index d1e5bb2f7..5dbb8ba2e 100644 --- a/internal/processing/workers/fromfediapi.go +++ b/internal/processing/workers/fromfediapi.go @@ -1010,10 +1010,17 @@ func (p *fediAPI) UpdateStatus(ctx context.Context, fMsg *messages.FromFediAPI) } } - // Notify of the latest edit. - if editsLen := len(status.EditIDs); editsLen != 0 { - editID := status.EditIDs[editsLen-1] - if err := p.surface.notifyStatusEdit(ctx, status, editID); err != nil { + if len(status.EditIDs) > 0 { + // Ensure edits are fully populated for this status before anything. + if err := p.surface.State.DB.PopulateStatusEdits(ctx, status); err != nil { + log.Error(ctx, "error populating updated status edits: %v") + + // Then send notifications of a status edit + // to any local interactors of the status. + } else if err := p.surface.notifyStatusEdit(ctx, + status, + status.Edits[len(status.Edits)-1], // latest + ); err != nil { log.Errorf(ctx, "error notifying status edit: %v", err) } } -- cgit v1.2.3