From 0a5657fba44d66552e2f2ac0e8c7ca3f5c4c77e2 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 13 Nov 2021 20:48:53 +0000 Subject: [PATCH] Show handles for emoji reactions, same as matrix --- reaction.py | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/reaction.py b/reaction.py index ab42b71f3..92485804d 100644 --- a/reaction.py +++ b/reaction.py @@ -517,6 +517,7 @@ def htmlEmojiReactions(postJsonObject: {}, interactive: bool, actor: str, maxReactionTypes: int, boxName: str, pageNumber: int) -> str: """html containing row of emoji reactions + displayed at the bottom of posts, above the icons """ if not hasObjectDict(postJsonObject): return '' @@ -531,19 +532,37 @@ def htmlEmojiReactions(postJsonObject: {}, interactive: bool, for item in postJsonObject['object']['reactions']['items']: emojiContent = item['content'] emojiActor = item['actor'] + emojiNickname = getNicknameFromActor(emojiActor) + emojiDomain, _ = getDomainFromActor(emojiActor) + emojiHandle = emojiNickname + '@' + emojiDomain if emojiActor == actor: if emojiContent not in reactedToByThisActor: reactedToByThisActor.append(emojiContent) if not reactions.get(emojiContent): if len(reactions.items()) < maxReactionTypes: - reactions[emojiContent] = 1 + reactions[emojiContent] = { + "handles": [emojiHandle], + "count": 1 + } else: - reactions[emojiContent] += 1 + reactions[emojiContent]['count'] += 1 + if len(reactions[emojiContent]['handles']) < 32: + reactions[emojiContent]['handles'].append(emojiHandle) if len(reactions.items()) == 0: return '' reactBy = removeIdEnding(postJsonObject['object']['id']) htmlStr = '
\n' - for emojiContent, count in reactions.items(): + for emojiContent, item in reactions.items(): + count = item['count'] + + # get the handles of actors who reacted + handlesStr = '' + item['handles'].sort() + for handle in item['handles']: + if handlesStr: + handlesStr += ' ' + handlesStr += handle + if emojiContent not in reactedToByThisActor: baseUrl = actor + '?react=' + reactBy else: @@ -563,7 +582,8 @@ def htmlEmojiReactions(postJsonObject: {}, interactive: bool, # urlencode the emoji emojiContentEncoded = urllib.parse.quote_plus(emojiContent) emojiContentStr = \ - ' ' + \ + ' ' + \ emojiContentStr + '\n' htmlStr += emojiContentStr htmlStr += '
\n'