summaryrefslogtreecommitdiff
path: root/internal/typeutils/internaltofrontend.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-09-26 11:56:01 +0200
committerLibravatar GitHub <noreply@github.com>2022-09-26 11:56:01 +0200
commitc4a08292ee44bc731ff90bad18a3f37e5ee8ef22 (patch)
tree1726f8450ec37f744204a857c3be2bfab17f206c /internal/typeutils/internaltofrontend.go
parent[bugfix] more nil checks baybeeeeeeeeeeeeeeeeeeee (#854) (diff)
downloadgotosocial-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/internaltofrontend.go')
-rw-r--r--internal/typeutils/internaltofrontend.go25
1 files changed, 23 insertions, 2 deletions
diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go
index 2f21f2d19..ca86a1284 100644
--- a/internal/typeutils/internaltofrontend.go
+++ b/internal/typeutils/internaltofrontend.go
@@ -159,8 +159,29 @@ func (c *converter) AccountToAPIAccountPublic(ctx context.Context, a *gtsmodel.A
fields = append(fields, mField)
}
+ // account emojis
emojis := []model.Emoji{}
- // TODO: account emojis
+ gtsEmojis := a.Emojis
+ if len(a.EmojiIDs) > len(gtsEmojis) {
+ gtsEmojis = []*gtsmodel.Emoji{}
+ for _, emojiID := range a.EmojiIDs {
+ emoji, err := c.db.GetEmojiByID(ctx, emojiID)
+ if err != nil {
+ return nil, fmt.Errorf("AccountToAPIAccountPublic: error getting emoji %s from database: %s", emojiID, err)
+ }
+ gtsEmojis = append(gtsEmojis, emoji)
+ }
+ }
+ for _, emoji := range gtsEmojis {
+ if *emoji.Disabled {
+ continue
+ }
+ apiEmoji, err := c.EmojiToAPIEmoji(ctx, emoji)
+ if err != nil {
+ return nil, fmt.Errorf("AccountToAPIAccountPublic: error converting emoji to api emoji: %s", err)
+ }
+ emojis = append(emojis, apiEmoji)
+ }
var acct string
if a.Domain != "" {
@@ -194,7 +215,7 @@ func (c *converter) AccountToAPIAccountPublic(ctx context.Context, a *gtsmodel.A
FollowingCount: followingCount,
StatusesCount: statusesCount,
LastStatusAt: lastStatusAt,
- Emojis: emojis, // TODO: implement this
+ Emojis: emojis,
Fields: fields,
Suspended: suspended,
CustomCSS: a.CustomCSS,