From 03fc6eaf3901d8854f769f2322ea3748abf70c1e Mon Sep 17 00:00:00 2001 From: tobi Date: Mon, 6 Oct 2025 11:45:40 +0200 Subject: [PATCH 1/2] [bugfix] Fix nil ptr in `DifferentFrom` func (#4477) Closes https://codeberg.org/superseriousbusiness/gotosocial/issues/4476 Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4477 Co-authored-by: tobi Co-committed-by: tobi --- internal/gtsmodel/interactionpolicy.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/gtsmodel/interactionpolicy.go b/internal/gtsmodel/interactionpolicy.go index 4fa5f4d8e..a7455a108 100644 --- a/internal/gtsmodel/interactionpolicy.go +++ b/internal/gtsmodel/interactionpolicy.go @@ -244,6 +244,12 @@ func (pr1 *PolicyRules) DifferentFrom(pr2 *PolicyRules) bool { return true } + // If they're both nil we don't + // need to check anything else. + if pr1 == nil && pr2 == nil { + return false + } + // Check if AutomaticApproval // differs between the two. if slices.Compare( From c6044d014283abcd2f9e0a94149de232b00df8de Mon Sep 17 00:00:00 2001 From: tobi Date: Mon, 6 Oct 2025 13:11:23 +0200 Subject: [PATCH 2/2] [bugfix] Fix `db error checking for int req: sql: no rows in result set` (#4478) Fixes `sql: no rows in result set` when trying to append approvedByURI to a reply that was sent impolitely and approved impolitely. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4478 Co-authored-by: tobi Co-committed-by: tobi --- internal/typeutils/internaltoas.go | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/internal/typeutils/internaltoas.go b/internal/typeutils/internaltoas.go index feb794e51..6255ee8e2 100644 --- a/internal/typeutils/internaltoas.go +++ b/internal/typeutils/internaltoas.go @@ -2438,8 +2438,8 @@ func (c *Converter) InteractionReqToASAuthorization( } // appendASInteractionAuthorization is a utility function -// that sets `approvedBy`, and `likeAuthorization`, -// `replyAuthorization`, or `announceAuthorization`. +// that sets `approvedBy`, and (if possible) `likeAuthorization`, +// `replyAuthorization`, and/or `announceAuthorization`. func (c *Converter) appendASInteractionAuthorization( ctx context.Context, approvedByURIStr string, @@ -2458,11 +2458,28 @@ func (c *Converter) appendASInteractionAuthorization( gtscontext.SetBarebones(ctx), approvedByURIStr, ) - if err != nil { + if err != nil && !errors.Is(err, db.ErrNoEntries) { return gtserror.Newf("db error checking for int req: %w", err) } - // Make sure it's actually accepted. + // If the interaction request is nil, + // that means we originally sent out + // the interaction request impolitely, + // and it was accepted impolitely. + // Ie., behavior from <= v0.20.0. + // + // If this is so, just set `approvedBy` + // to given approvedByURIStr and bail, + // as there's nothing else we can do. + if intReq == nil { + if wap, ok := t.(ap.WithApprovedBy); ok { + ap.SetApprovedBy(wap, approvedByURI) + } + return nil + } + + // Make sure interaction request + // has actually been accepted. if !intReq.IsAccepted() { return gtserror.Newf( "approvedByURIStr %s corresponded to not-accepted interaction request %s",