summaryrefslogtreecommitdiff
path: root/internal/processing/parsemention.go
diff options
context:
space:
mode:
authorLibravatar tobi <tobi.smethurst@protonmail.com>2025-05-04 09:45:10 +0000
committerLibravatar kim <gruf@noreply.codeberg.org>2025-05-04 09:45:10 +0000
commitf3f185435916165a6dd72f3a1bd67e370a2a783d (patch)
tree766f79d878fbd94cf622944b3cdd8120469ecb55 /internal/processing/parsemention.go
parent[chore/cicd] Account for force pushes in conditional runs (#4121) (diff)
downloadgotosocial-f3f185435916165a6dd72f3a1bd67e370a2a783d.tar.xz
[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 <tobi.smethurst@protonmail.com> Co-committed-by: tobi <tobi.smethurst@protonmail.com>
Diffstat (limited to 'internal/processing/parsemention.go')
-rw-r--r--internal/processing/parsemention.go30
1 files changed, 29 insertions, 1 deletions
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 &gtsmodel.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
}
}