[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>
This commit is contained in:
tobi
2025-05-04 09:45:10 +00:00
committed by kim
parent 056c67f396
commit f3f1854359
13 changed files with 196 additions and 48 deletions

View File

@@ -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
}
}