From f3f185435916165a6dd72f3a1bd67e370a2a783d Mon Sep 17 00:00:00 2001 From: tobi Date: Sun, 4 May 2025 09:45:10 +0000 Subject: [bugfix] Fix no notification if mention edited into status (#4102) This pull request adds mention notifications if a mention was edited into a status after its initial publication. Closes https://codeberg.org/superseriousbusiness/gotosocial/issues/3869 Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4102 Co-authored-by: tobi Co-committed-by: tobi --- internal/processing/parsemention.go | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'internal/processing/parsemention.go') diff --git a/internal/processing/parsemention.go b/internal/processing/parsemention.go index 6566ecd1c..7a75cb9bc 100644 --- a/internal/processing/parsemention.go +++ b/internal/processing/parsemention.go @@ -19,9 +19,11 @@ package processing import ( "context" + "errors" "fmt" "code.superseriousbusiness.org/gotosocial/internal/config" + "code.superseriousbusiness.org/gotosocial/internal/db" "code.superseriousbusiness.org/gotosocial/internal/federation" "code.superseriousbusiness.org/gotosocial/internal/gtscontext" "code.superseriousbusiness.org/gotosocial/internal/gtsmodel" @@ -100,7 +102,29 @@ func GetParseMentionFunc(state *state.State, federator *federation.Federator) gt } } - // Return mention with useful populated fields, + // Check if the mention was + // in the database already. + if statusID != "" { + mention, err := state.DB.GetMentionByTargetAcctStatus(ctx, targetAcct.ID, statusID) + if err != nil && !errors.Is(err, db.ErrNoEntries) { + return nil, fmt.Errorf( + "db error checking for existing mention: %w", + err, + ) + } + + if mention != nil { + // We had it, return this rather + // than creating a new one. + mention.NameString = namestring + mention.OriginAccountURI = originAcct.URI + mention.TargetAccountURI = targetAcct.URI + mention.TargetAccountURL = targetAcct.URL + return mention, nil + } + } + + // Return new mention with useful populated fields, // but *don't* store it in the database; that's // up to the calling function to do, if they want. return >smodel.Mention{ @@ -114,6 +138,10 @@ func GetParseMentionFunc(state *state.State, federator *federation.Federator) gt TargetAccountURL: targetAcct.URL, TargetAccount: targetAcct, NameString: namestring, + + // Mention wasn't + // stored in the db. + IsNew: true, }, nil } } -- cgit v1.2.3