From 862403054ab7e064aa2814422b6c856fcc010088 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 10 Nov 2021 21:55:56 +0000 Subject: [PATCH] Reaction icon links react or unreact --- reaction.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/reaction.py b/reaction.py index 099d27fa3..09b6a8598 100644 --- a/reaction.py +++ b/reaction.py @@ -521,8 +521,13 @@ def htmlEmojiReactions(postJsonObject: {}, interactive: bool, if not postJsonObject['object']['reactions'].get('items'): return '' reactions = {} + reactedToByThisActor = [] for item in postJsonObject['object']['reactions']['items']: emojiContent = item['content'] + emojiActor = item['actor'] + if emojiActor == actor: + if emojiContent not in reactedToByThisActor: + reactedToByThisActor.append(emojiContent) if not reactions.get(emojiContent): if len(reactions.items()) < maxReactionTypes: reactions[emojiContent] = 1 @@ -531,9 +536,13 @@ def htmlEmojiReactions(postJsonObject: {}, interactive: bool, if len(reactions.items()) == 0: return '' reactBy = removeIdEnding(postJsonObject['object']['id']) - baseUrl = actor + '?react=' + reactBy + '?emojreact=' htmlStr = '
\n' for emojiContent, count in reactions.items(): + if emojiContent not in reactedToByThisActor: + baseUrl = actor + '?react=' + reactBy + '?emojreact=' + else: + baseUrl = actor + '?unreact=' + reactBy + '?emojreact=' + htmlStr += '
\n' if count < 100: countStr = str(count)