[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:
tobi 2022-03-29 11:54:56 +02:00 committed by GitHub
commit 37d310f981
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 420 additions and 183 deletions

View file

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