diff options
author | 2022-09-26 11:56:01 +0200 | |
---|---|---|
committer | 2022-09-26 11:56:01 +0200 | |
commit | c4a08292ee44bc731ff90bad18a3f37e5ee8ef22 (patch) | |
tree | 1726f8450ec37f744204a857c3be2bfab17f206c /internal/gtsmodel/account.go | |
parent | [bugfix] more nil checks baybeeeeeeeeeeeeeeeeeeee (#854) (diff) | |
download | gotosocial-c4a08292ee44bc731ff90bad18a3f37e5ee8ef22.tar.xz |
[feature] Show + federate emojis in accounts (#837)
* Start adding account emoji
* get emojis serialized + deserialized nicely
* update tests
* set / retrieve emojis on accounts
* show account emojis in web view
* fetch emojis from db based on ids
* fix typo in test
* lint
* fix pg migration
* update tests
* update emoji checking logic
* update comment
* clarify comments + add some spacing
* tidy up loops a lil (thanks kim)
Diffstat (limited to 'internal/gtsmodel/account.go')
-rw-r--r-- | internal/gtsmodel/account.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/internal/gtsmodel/account.go b/internal/gtsmodel/account.go index 20405f9ac..ca5c74208 100644 --- a/internal/gtsmodel/account.go +++ b/internal/gtsmodel/account.go @@ -41,6 +41,8 @@ type Account struct { HeaderMediaAttachment *MediaAttachment `validate:"-" bun:"rel:belongs-to"` // MediaAttachment corresponding to headerMediaAttachmentID HeaderRemoteURL string `validate:"omitempty,url" bun:",nullzero"` // For a non-local account, where can the header be fetched? DisplayName string `validate:"-" bun:""` // DisplayName for this account. Can be empty, then just the Username will be used for display purposes. + EmojiIDs []string `validate:"dive,ulid" bun:"emojis,array"` // Database IDs of any emojis used in this account's bio, display name, etc + Emojis []*Emoji `validate:"-" bun:"attached_emojis,m2m:account_to_emojis"` // Emojis corresponding to emojiIDs. https://bun.uptrace.dev/guide/relations.html#many-to-many-relation Fields []Field `validate:"-"` // a key/value map of fields that this account has added to their profile Note string `validate:"-" bun:""` // A note that this account has on their profile (ie., the account's bio/description of themselves) NoteRaw string `validate:"-" bun:""` // The raw contents of .Note without conversion to HTML, only available when requester = target @@ -76,6 +78,14 @@ type Account struct { SuspensionOrigin string `validate:"omitempty,ulid" bun:"type:CHAR(26),nullzero"` // id of the database entry that caused this account to become suspended -- can be an account ID or a domain block ID } +// AccountToEmoji is an intermediate struct to facilitate the many2many relationship between an account and one or more emojis. +type AccountToEmoji struct { + AccountID string `validate:"ulid,required" bun:"type:CHAR(26),unique:accountemoji,nullzero,notnull"` + Account *Account `validate:"-" bun:"rel:belongs-to"` + EmojiID string `validate:"ulid,required" bun:"type:CHAR(26),unique:accountemoji,nullzero,notnull"` + Emoji *Emoji `validate:"-" bun:"rel:belongs-to"` +} + // Field represents a key value field on an account, for things like pronouns, website, etc. // VerifiedAt is optional, to be used only if Value is a URL to a webpage that contains the // username of the user. |