From 73c1fead1200937dedf67cabb0aeb59c70e9bf2c Mon Sep 17 00:00:00 2001 From: tobi Date: Sun, 21 Jul 2024 15:02:02 +0200 Subject: [PATCH] [chore] Refresh origin acct before streaming notif --- internal/processing/workers/surface.go | 2 ++ internal/processing/workers/surfacenotify.go | 14 ++++++++++++++ internal/processing/workers/workers.go | 1 + 3 files changed, 17 insertions(+) diff --git a/internal/processing/workers/surface.go b/internal/processing/workers/surface.go index 5ec905ae8..8a6a38cf1 100644 --- a/internal/processing/workers/surface.go +++ b/internal/processing/workers/surface.go @@ -19,6 +19,7 @@ package workers import ( "github.com/superseriousbusiness/gotosocial/internal/email" + "github.com/superseriousbusiness/gotosocial/internal/federation" "github.com/superseriousbusiness/gotosocial/internal/filter/visibility" "github.com/superseriousbusiness/gotosocial/internal/processing/stream" "github.com/superseriousbusiness/gotosocial/internal/state" @@ -37,4 +38,5 @@ type Surface struct { Stream *stream.Processor Filter *visibility.Filter EmailSender email.Sender + Federator *federation.Federator } diff --git a/internal/processing/workers/surfacenotify.go b/internal/processing/workers/surfacenotify.go index edeb4b57e..239603315 100644 --- a/internal/processing/workers/surfacenotify.go +++ b/internal/processing/workers/surfacenotify.go @@ -468,6 +468,20 @@ func (s *Surface) Notify( // with the state-y stuff. unlock() + // Try to bring notif origin account is up to date, + // so receiver of the notif doesn't see an empty + // or out-of-date avatar in the stream. + updatedOrigin, _, err := s.Federator.RefreshAccount( + ctx, + targetAccount.Username, + originAccount, + nil, + nil, // default freshness + ) + if err == nil { + notif.OriginAccount = updatedOrigin + } + // Stream notification to the user. filters, err := s.State.DB.GetFiltersForAccountID(ctx, targetAccount.ID) if err != nil { diff --git a/internal/processing/workers/workers.go b/internal/processing/workers/workers.go index 6b4cc07a6..c6162a5a6 100644 --- a/internal/processing/workers/workers.go +++ b/internal/processing/workers/workers.go @@ -61,6 +61,7 @@ func New( Stream: stream, Filter: filter, EmailSender: emailSender, + Federator: federator, } // Init shared util funcs.