From c4a08292ee44bc731ff90bad18a3f37e5ee8ef22 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Mon, 26 Sep 2022 11:56:01 +0200 Subject: [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) --- internal/typeutils/internaltoas.go | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'internal/typeutils/internaltoas.go') 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 -- cgit v1.2.3