mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 16:42:25 -05:00
[feature/chore] Add Move database functions + cache (#2647)
* [feature/chore] Add Move database functions + cache * add move mem ratio to envparsing.sh * update comment
This commit is contained in:
parent
61a2b91f45
commit
b22e213e15
17 changed files with 671 additions and 1 deletions
|
|
@ -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"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue