diff options
author | 2022-09-26 11:56:01 +0200 | |
---|---|---|
committer | 2022-09-26 11:56:01 +0200 | |
commit | c4a08292ee44bc731ff90bad18a3f37e5ee8ef22 (patch) | |
tree | 1726f8450ec37f744204a857c3be2bfab17f206c /internal/typeutils/internaltoas.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/typeutils/internaltoas.go')
-rw-r--r-- | internal/typeutils/internaltoas.go | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/internal/typeutils/internaltoas.go b/internal/typeutils/internaltoas.go index a678a970f..6194dba82 100644 --- a/internal/typeutils/internaltoas.go +++ b/internal/typeutils/internaltoas.go @@ -216,8 +216,33 @@ func (c *converter) AccountToAS(ctx context.Context, a *gtsmodel.Account) (vocab // set the public key property on the Person person.SetW3IDSecurityV1PublicKey(publicKeyProp) - // tag - // TODO: Any tags used in the summary of this profile + // tags + tagProp := streams.NewActivityStreamsTagProperty() + + // tag -- emojis + emojis := a.Emojis + if len(a.EmojiIDs) > len(emojis) { + emojis = []*gtsmodel.Emoji{} + for _, emojiID := range a.EmojiIDs { + emoji, err := c.db.GetEmojiByID(ctx, emojiID) + if err != nil { + return nil, fmt.Errorf("AccountToAS: error getting emoji %s from database: %s", emojiID, err) + } + emojis = append(emojis, emoji) + } + } + for _, emoji := range emojis { + asEmoji, err := c.EmojiToAS(ctx, emoji) + if err != nil { + return nil, fmt.Errorf("AccountToAS: error converting emoji to AS emoji: %s", err) + } + tagProp.AppendTootEmoji(asEmoji) + } + + // tag -- hashtags + // TODO + + person.SetActivityStreamsTag(tagProp) // attachment // Used for profile fields. @@ -477,11 +502,11 @@ func (c *converter) StatusToAS(ctx context.Context, s *gtsmodel.Status) (vocab.A } } for _, emoji := range emojis { - asMention, err := c.EmojiToAS(ctx, emoji) + asEmoji, err := c.EmojiToAS(ctx, emoji) if err != nil { return nil, fmt.Errorf("StatusToAS: error converting emoji to AS emoji: %s", err) } - tagProp.AppendTootEmoji(asMention) + tagProp.AppendTootEmoji(asEmoji) } // tag -- hashtags |