summaryrefslogtreecommitdiff
path: root/internal/gtsmodel/account.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2024-03-06 11:18:57 +0100
committerLibravatar GitHub <noreply@github.com>2024-03-06 11:18:57 +0100
commitb22e213e15a7bc64773e626d76305bd860e6301c (patch)
treebdc0f14481b144f8e4e45a380ea3b7cf78490041 /internal/gtsmodel/account.go
parent[feature] Filters v1 (#2594) (diff)
downloadgotosocial-b22e213e15a7bc64773e626d76305bd860e6301c.tar.xz
[feature/chore] Add Move database functions + cache (#2647)
* [feature/chore] Add Move database functions + cache * add move mem ratio to envparsing.sh * update comment
Diffstat (limited to 'internal/gtsmodel/account.go')
-rw-r--r--internal/gtsmodel/account.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/internal/gtsmodel/account.go b/internal/gtsmodel/account.go
index 5421c41bb..8b1412255 100644
--- a/internal/gtsmodel/account.go
+++ b/internal/gtsmodel/account.go
@@ -23,6 +23,7 @@ package gtsmodel
import (
"crypto/rsa"
+ "slices"
"strings"
"time"
@@ -54,8 +55,10 @@ type Account struct {
Memorial *bool `bun:",default:false"` // Is this a memorial account, ie., has the user passed away?
AlsoKnownAsURIs []string `bun:"also_known_as_uris,array"` // This account is associated with these account URIs.
AlsoKnownAs []*Account `bun:"-"` // This account is associated with these accounts (field not stored in the db).
- MovedToURI string `bun:",nullzero"` // This account has moved to this account URI.
+ MovedToURI string `bun:",nullzero"` // This account has (or claims to have) moved to this account URI. Even if this field is set the move may not yet have been processed. Check `move` for this.
MovedTo *Account `bun:"-"` // This account has moved to this account (field not stored in the db).
+ MoveID string `bun:""` // ID of a Move in the database for this account. Only set if we received or created a Move activity for which this account URI was the origin.
+ Move *Move `bun:"-"` // Move corresponding to MoveID, if set.
Bot *bool `bun:",default:false"` // Does this account identify itself as a bot?
Reason string `bun:""` // What reason was given for signing up when this account was created?
Locked *bool `bun:",default:true"` // Does this account need an approval for new followers?
@@ -172,6 +175,18 @@ func (a *Account) PubKeyExpired() bool {
a.PublicKeyExpiresAt.Before(time.Now())
}
+// IsAliasedTo returns true if account
+// is aliased to the given account URI.
+func (a *Account) IsAliasedTo(uri string) bool {
+ return slices.Contains(a.AlsoKnownAsURIs, uri)
+}
+
+// IsSuspended returns true if account
+// has been suspended from this instance.
+func (a *Account) IsSuspended() bool {
+ return !a.SuspendedAt.IsZero()
+}
+
// AccountToEmoji is an intermediate struct to facilitate the many2many relationship between an account and one or more emojis.
type AccountToEmoji struct {
AccountID string `bun:"type:CHAR(26),unique:accountemoji,nullzero,notnull"`