From 37d310f981f3e26bc643aeabac134b591c84455a Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Tue, 29 Mar 2022 11:54:56 +0200 Subject: [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 --- internal/gtsmodel/mention.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'internal/gtsmodel/mention.go') diff --git a/internal/gtsmodel/mention.go b/internal/gtsmodel/mention.go index e00df8911..fd1d45622 100644 --- a/internal/gtsmodel/mention.go +++ b/internal/gtsmodel/mention.go @@ -18,7 +18,10 @@ package gtsmodel -import "time" +import ( + "context" + "time" +) // Mention refers to the 'tagging' or 'mention' of a user within a status. type Mention struct { @@ -57,3 +60,15 @@ type Mention struct { TargetAccountURL string `validate:"-" bun:"-"` // A pointer to the gtsmodel account of the mentioned account. } + +// ParseMentionFunc describes a function that takes a lowercase account name +// in the form "@test@whatever.example.org" for a remote account, or "@test" +// for a local account, and returns a fully populated mention for that account, +// with the given origin status ID and origin account ID. +// +// If the account is remote and not yet found in the database, then ParseMentionFunc +// will try to webfinger the remote account and put it in the database before returning. +// +// Mentions generated by this function are not put in the database, that's still up to +// the caller to do. +type ParseMentionFunc func(ctx context.Context, targetAccount string, originAccountID string, statusID string) (*Mention, error) -- cgit v1.2.3