summaryrefslogtreecommitdiff
path: root/internal/gtsmodel/mention.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-03-29 11:54:56 +0200
committerLibravatar GitHub <noreply@github.com>2022-03-29 11:54:56 +0200
commit37d310f981f3e26bc643aeabac134b591c84455a (patch)
tree041f5db16254b5257471bcac0730ac9d93ce13d5 /internal/gtsmodel/mention.go
parent[feature/security] Add systemd sandboxing options to harden security (#440) (diff)
downloadgotosocial-37d310f981f3e26bc643aeabac134b591c84455a.tar.xz
[feature] Dereference remote mentions when the account is not already known (#442)v0.2.2
* 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
Diffstat (limited to 'internal/gtsmodel/mention.go')
-rw-r--r--internal/gtsmodel/mention.go17
1 files changed, 16 insertions, 1 deletions
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)