mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-30 10:23:32 -06:00
[feature] Dereference remote mentions when the account is not already known (#442)
* remove mention util function from db * add ParseMentionFunc to gtsmodel * add parseMentionFunc to processor * refactor search to simplify it a bit * add parseMentionFunc to account * add parseMentionFunc to status * some renaming for clarity * test dereference of unknown mentioned account
This commit is contained in:
parent
983e696bd6
commit
37d310f981
16 changed files with 420 additions and 183 deletions
|
|
@ -87,10 +87,11 @@ type processor struct {
|
|||
formatter text.Formatter
|
||||
db db.DB
|
||||
federator federation.Federator
|
||||
parseMention gtsmodel.ParseMentionFunc
|
||||
}
|
||||
|
||||
// New returns a new account processor.
|
||||
func New(db db.DB, tc typeutils.TypeConverter, mediaManager media.Manager, oauthServer oauth.Server, fromClientAPI chan messages.FromClientAPI, federator federation.Federator) Processor {
|
||||
func New(db db.DB, tc typeutils.TypeConverter, mediaManager media.Manager, oauthServer oauth.Server, fromClientAPI chan messages.FromClientAPI, federator federation.Federator, parseMention gtsmodel.ParseMentionFunc) Processor {
|
||||
return &processor{
|
||||
tc: tc,
|
||||
mediaManager: mediaManager,
|
||||
|
|
@ -100,5 +101,6 @@ func New(db db.DB, tc typeutils.TypeConverter, mediaManager media.Manager, oauth
|
|||
formatter: text.NewFormatter(db),
|
||||
db: db,
|
||||
federator: federator,
|
||||
parseMention: parseMention,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import (
|
|||
"github.com/superseriousbusiness/gotosocial/internal/media"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/messages"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/oauth"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing/account"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/transport"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
|
||||
|
|
@ -88,7 +89,7 @@ func (suite *AccountStandardTestSuite) SetupTest() {
|
|||
suite.federator = testrig.NewTestFederator(suite.db, suite.transportController, suite.storage, suite.mediaManager)
|
||||
suite.sentEmails = make(map[string]string)
|
||||
suite.emailSender = testrig.NewEmailSender("../../../web/template/", suite.sentEmails)
|
||||
suite.accountProcessor = account.New(suite.db, suite.tc, suite.mediaManager, suite.oauthServer, suite.fromClientAPIChan, suite.federator)
|
||||
suite.accountProcessor = account.New(suite.db, suite.tc, suite.mediaManager, suite.oauthServer, suite.fromClientAPIChan, suite.federator, processing.GetParseMentionFunc(suite.db, suite.federator))
|
||||
testrig.StandardDBSetup(suite.db, nil)
|
||||
testrig.StandardStorageSetup(suite.storage, "../../../testrig/media")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -199,10 +199,14 @@ func (p *processor) processNote(ctx context.Context, note string, accountID stri
|
|||
return "", err
|
||||
}
|
||||
|
||||
mentionStrings := util.DeriveMentionsFromText(note)
|
||||
mentions, err := p.db.MentionStringsToMentions(ctx, mentionStrings, accountID, "")
|
||||
if err != nil {
|
||||
return "", err
|
||||
mentionStrings := util.DeriveMentionNamesFromText(note)
|
||||
mentions := []*gtsmodel.Mention{}
|
||||
for _, mentionString := range mentionStrings {
|
||||
mention, err := p.parseMention(ctx, mentionString, accountID, "")
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
mentions = append(mentions, mention)
|
||||
}
|
||||
|
||||
// TODO: support emojis in account notes
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue