From c00f640f3dcf752c287e8c89c29831501cfc2a1a Mon Sep 17 00:00:00 2001 From: tobi Date: Thu, 22 Jan 2026 13:14:27 +0100 Subject: [bugfix] Mark targets of pre-approved polite interaction requests as no longer pending approval (#4647) Fix a little bug written by yours truly, where we weren't marking the targets of pre-approved ReplyRequests and AnnounceRequests as no longer pending approval. Only just found this now because of testing with polite requests. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4647 Co-authored-by: tobi Co-committed-by: tobi --- internal/processing/workers/fromfediapi.go | 45 ++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 9 deletions(-) (limited to 'internal/processing') diff --git a/internal/processing/workers/fromfediapi.go b/internal/processing/workers/fromfediapi.go index f6feeb622..310ea32b6 100644 --- a/internal/processing/workers/fromfediapi.go +++ b/internal/processing/workers/fromfediapi.go @@ -473,6 +473,20 @@ func (p *fediAPI) CreateReplyRequest(ctx context.Context, fMsg *messages.FromFed return gtserror.Newf("db error updating interaction request: %w", err) } + // Mark the reply as now approved, referring to + // the accepted interaction request we just stored. + reply.PreApproved = false + reply.PendingApproval = util.Ptr(false) + reply.ApprovedByURI = req.AuthorizationURI + if err := p.state.DB.UpdateStatus( + ctx, + reply, + "pending_approval", + "approved_by_uri", + ); err != nil { + return gtserror.Newf("db error updating status: %w", err) + } + // Send out the accept. if err := p.federate.AcceptInteraction(ctx, req); err != nil { log.Errorf(ctx, "error federating accept: %v", err) @@ -756,17 +770,11 @@ func (p *fediAPI) CreateLikeRequest(ctx context.Context, fMsg *messages.FromFedi return gtserror.Newf("db error updating interaction request: %w", err) } - // Send out the accept. - if err := p.federate.AcceptInteraction(ctx, req); err != nil { - log.Errorf(ctx, "error federating accept: %v", err) - } - - // Mark the fave as approved. + // Mark the status fave as now approved, referring to + // the accepted interaction request we just stored. + req.Like.PreApproved = false req.Like.PendingApproval = util.Ptr(false) req.Like.ApprovedByURI = req.AuthorizationURI - req.Like.PreApproved = false - - // Update in the db. if err := p.state.DB.UpdateStatusFave( ctx, req.Like, @@ -776,6 +784,11 @@ func (p *fediAPI) CreateLikeRequest(ctx context.Context, fMsg *messages.FromFedi return gtserror.Newf("db error updating status fave: %w", err) } + // Send out the accept. + if err := p.federate.AcceptInteraction(ctx, req); err != nil { + log.Errorf(ctx, "error federating accept: %v", err) + } + // Notify the faved account. if err := p.surface.notifyFave(ctx, req.Like); err != nil { log.Errorf(ctx, "error notifying fave: %v", err) @@ -979,6 +992,20 @@ func (p *fediAPI) CreateAnnounceRequest(ctx context.Context, fMsg *messages.From return gtserror.Newf("db error updating interaction request: %w", err) } + // Mark the boost as now approved, referring to + // the accepted interaction request we just stored. + boost.PreApproved = false + boost.PendingApproval = util.Ptr(false) + boost.ApprovedByURI = req.AuthorizationURI + if err := p.state.DB.UpdateStatus( + ctx, + boost, + "pending_approval", + "approved_by_uri", + ); err != nil { + return gtserror.Newf("db error updating status: %w", err) + } + // Send out the accept. if err := p.federate.AcceptInteraction(ctx, req); err != nil { log.Errorf(ctx, "error federating accept: %v", err) -- cgit v1.3