From 9ce4234b9fd1e201faf015df52bfc35db259dd46 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Fri, 1 Oct 2021 19:08:50 +0200 Subject: Follow request auto approval (#259) * start messing about * fiddle more * Tests & fiddling --- internal/processing/fromcommon.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'internal/processing/fromcommon.go') diff --git a/internal/processing/fromcommon.go b/internal/processing/fromcommon.go index 88d7405a8..e14c36fd4 100644 --- a/internal/processing/fromcommon.go +++ b/internal/processing/fromcommon.go @@ -109,9 +109,20 @@ func (p *processor) notifyStatus(ctx context.Context, status *gtsmodel.Status) e return nil } -func (p *processor) notifyFollowRequest(ctx context.Context, followRequest *gtsmodel.FollowRequest, receivingAccount *gtsmodel.Account) error { +func (p *processor) notifyFollowRequest(ctx context.Context, followRequest *gtsmodel.FollowRequest) error { + // make sure we have the target account pinned on the follow request + if followRequest.TargetAccount == nil { + a, err := p.db.GetAccountByID(ctx, followRequest.TargetAccountID) + if err != nil { + return err + } + followRequest.TargetAccount = a + } + targetAccount := followRequest.TargetAccount + // return if this isn't a local account - if receivingAccount.Domain != "" { + if targetAccount.Domain != "" { + // this isn't a local account so we've got nothing to do here return nil } @@ -137,7 +148,7 @@ func (p *processor) notifyFollowRequest(ctx context.Context, followRequest *gtsm return fmt.Errorf("notifyStatus: error converting notification to masto representation: %s", err) } - if err := p.streamingProcessor.StreamNotificationToAccount(mastoNotif, receivingAccount); err != nil { + if err := p.streamingProcessor.StreamNotificationToAccount(mastoNotif, targetAccount); err != nil { return fmt.Errorf("notifyStatus: error streaming notification to account: %s", err) } -- cgit v1.2.3