From edd62c1f1b863cd1238fd16367adc399db1e2a03 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 17 Nov 2021 14:25:24 +0000 Subject: [PATCH] Option to turn emoji reactions off --- daemon.py | 35 ++++++++++++++++++++++++++++++++++- inbox.py | 6 ++++++ translations/ar.json | 3 ++- translations/ca.json | 3 ++- translations/cy.json | 3 ++- translations/de.json | 3 ++- translations/en.json | 3 ++- translations/es.json | 3 ++- translations/fr.json | 3 ++- translations/ga.json | 3 ++- translations/hi.json | 3 ++- translations/it.json | 3 ++- translations/ja.json | 3 ++- translations/ku.json | 3 ++- translations/oc.json | 3 ++- translations/pt.json | 3 ++- translations/ru.json | 3 ++- translations/sw.json | 3 ++- translations/zh.json | 3 ++- webapp_post.py | 11 ++++++++++- webapp_profile.py | 12 ++++++++++-- 21 files changed, 94 insertions(+), 21 deletions(-) diff --git a/daemon.py b/daemon.py index c68801575..64dfd9fb5 100644 --- a/daemon.py +++ b/daemon.py @@ -5725,6 +5725,38 @@ class PubServer(BaseHTTPRequestHandler): hideLikeButtonFile) pass + # hide Reaction button + hideReactionButtonFile = \ + acctDir(baseDir, nickname, domain) + \ + '/.hideReactionButton' + notifyReactionsFilename = \ + acctDir(baseDir, nickname, domain) + \ + '/.notifyReactions' + hideReactionButtonActive = False + if fields.get('hideReactionButton'): + if fields['hideReactionButton'] == 'on': + hideReactionButtonActive = True + with open(hideReactionButtonFile, 'w+') as rFile: + rFile.write('\n') + # remove notify Reaction selection + if os.path.isfile(notifyReactionsFilename): + try: + os.remove(notifyReactionsFilename) + except BaseException: + print('EX: _profileUpdate ' + + 'unable to delete ' + + notifyReactionsFilename) + pass + if not hideReactionButtonActive: + if os.path.isfile(hideReactionButtonFile): + try: + os.remove(hideReactionButtonFile) + except BaseException: + print('EX: _profileUpdate ' + + 'unable to delete ' + + hideReactionButtonFile) + pass + # notify about new Likes if onFinalWelcomeScreen: # default setting from welcome screen @@ -5760,7 +5792,8 @@ class PubServer(BaseHTTPRequestHandler): else: notifyReactionsActive = False if fields.get('notifyReactions'): - if fields['notifyReactions'] == 'on': + if fields['notifyReactions'] == 'on' and \ + not hideReactionButtonActive: notifyReactionsActive = True with open(notifyReactionsFilename, 'w+') as rFile: diff --git a/inbox.py b/inbox.py index a2bbdf81d..3a88b42b7 100644 --- a/inbox.py +++ b/inbox.py @@ -1263,9 +1263,15 @@ def _receiveReaction(recentPostsCache: {}, return False if not os.path.isdir(baseDir + '/accounts/' + handle): print('DEBUG: unknown recipient of emoji reaction - ' + handle) + if os.path.isfile(baseDir + '/accounts/' + handle + + '/.hideReactionButton'): + print('Emoji reaction rejected by ' + handle + + ' due to their settings') + return True # if this post in the outbox of the person? handleName = handle.split('@')[0] handleDom = handle.split('@')[1] + postReactionId = messageJson['object'] emojiContent = removeHtml(messageJson['content']) if not emojiContent: diff --git a/translations/ar.json b/translations/ar.json index 2aa67428f..ab669c49b 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -495,5 +495,6 @@ "Content License": "ترخيص المحتوى", "Reaction by": "رد فعل", "Notify on emoji reactions": "يخطر على ردود الفعل الرموز التعبيرية", - "Select reaction": "حدد رد الفعل" + "Select reaction": "حدد رد الفعل", + "Don't show the Reaction button": "لا تظهر زر رد الفعل" } diff --git a/translations/ca.json b/translations/ca.json index cd87323a8..5390e4a18 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -495,5 +495,6 @@ "Content License": "Llicència de contingut", "Reaction by": "Reacció de", "Notify on emoji reactions": "Notificar sobre les reaccions dels emojis", - "Select reaction": "Seleccioneu la reacció" + "Select reaction": "Seleccioneu la reacció", + "Don't show the Reaction button": "No mostris el botó de reacció" } diff --git a/translations/cy.json b/translations/cy.json index 643238496..4858fd0d7 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -495,5 +495,6 @@ "Content License": "Trwydded Cynnwys", "Reaction by": "Ymateb gan", "Notify on emoji reactions": "Hysbysu ar ymatebion emoji", - "Select reaction": "Dewiswch adwaith" + "Select reaction": "Dewiswch adwaith", + "Don't show the Reaction button": "Peidiwch â dangos y botwm Adwaith" } diff --git a/translations/de.json b/translations/de.json index 0432f0d52..ae339248f 100644 --- a/translations/de.json +++ b/translations/de.json @@ -495,5 +495,6 @@ "Content License": "Inhaltslizenz", "Reaction by": "Reaktion von", "Notify on emoji reactions": "Bei Emoji-Reaktionen benachrichtigen", - "Select reaction": "Reaktion auswählen" + "Select reaction": "Reaktion auswählen", + "Don't show the Reaction button": "Reaktionstaste nicht anzeigen" } diff --git a/translations/en.json b/translations/en.json index a65a63695..4104895f6 100644 --- a/translations/en.json +++ b/translations/en.json @@ -495,5 +495,6 @@ "Content License": "Content License", "Reaction by": "Reaction by", "Notify on emoji reactions": "Notify on emoji reactions", - "Select reaction": "Select reaction" + "Select reaction": "Select reaction", + "Don't show the Reaction button": "Don't show the Reaction button" } diff --git a/translations/es.json b/translations/es.json index 5917dcfc2..1c4782b74 100644 --- a/translations/es.json +++ b/translations/es.json @@ -495,5 +495,6 @@ "Content License": "Licencia de contenido", "Reaction by": "Reacción de", "Notify on emoji reactions": "Notificar sobre reacciones emoji", - "Select reaction": "Seleccionar reacción" + "Select reaction": "Seleccionar reacción", + "Don't show the Reaction button": "No mostrar el botón de reacción" } diff --git a/translations/fr.json b/translations/fr.json index db3948815..bced31ac3 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -495,5 +495,6 @@ "Content License": "Licence de contenu", "Reaction by": "Réaction par", "Notify on emoji reactions": "Avertir sur les réactions emoji", - "Select reaction": "Sélectionnez la réaction" + "Select reaction": "Sélectionnez la réaction", + "Don't show the Reaction button": "Ne pas afficher le bouton Réaction" } diff --git a/translations/ga.json b/translations/ga.json index 63b7d3add..6d26ad938 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -495,5 +495,6 @@ "Content License": "Ceadúnas Ábhar", "Reaction by": "Imoibriú le", "Notify on emoji reactions": "Fógra a thabhairt faoi imoibrithe emoji", - "Select reaction": "Roghnaigh imoibriú" + "Select reaction": "Roghnaigh imoibriú", + "Don't show the Reaction button": "Ná taispeáin an cnaipe Imoibriú" } diff --git a/translations/hi.json b/translations/hi.json index 58099bcf2..09f390289 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -495,5 +495,6 @@ "Content License": "सामग्री लाइसेंस", "Reaction by": "द्वारा प्रतिक्रिया", "Notify on emoji reactions": "इमोजी प्रतिक्रियाओं पर सूचित करें", - "Select reaction": "प्रतिक्रिया का चयन करें" + "Select reaction": "प्रतिक्रिया का चयन करें", + "Don't show the Reaction button": "प्रतिक्रिया बटन न दिखाएं" } diff --git a/translations/it.json b/translations/it.json index 80c6d4376..656ff16b5 100644 --- a/translations/it.json +++ b/translations/it.json @@ -495,5 +495,6 @@ "Content License": "Licenza sui contenuti", "Reaction by": "Reazione di", "Notify on emoji reactions": "Notifica sulle reazioni emoji", - "Select reaction": "Seleziona reazione" + "Select reaction": "Seleziona reazione", + "Don't show the Reaction button": "Non mostrare il pulsante Reazione" } diff --git a/translations/ja.json b/translations/ja.json index 17db79a59..c5f67b34c 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -495,5 +495,6 @@ "Content License": "コンテンツライセンス", "Reaction by": "による反応", "Notify on emoji reactions": "絵文字の反応を通知する", - "Select reaction": "反応を選択" + "Select reaction": "反応を選択", + "Don't show the Reaction button": "反応ボタンを表示しない" } diff --git a/translations/ku.json b/translations/ku.json index 8d7130e7a..a5d1a2efd 100644 --- a/translations/ku.json +++ b/translations/ku.json @@ -495,5 +495,6 @@ "Content License": "Naverok License de", "Reaction by": "Reaction by", "Notify on emoji reactions": "Li ser reaksiyonên emoji agahdar bikin", - "Select reaction": "Reaksiyonê hilbijêrin" + "Select reaction": "Reaksiyonê hilbijêrin", + "Don't show the Reaction button": "Bişkoka Reaksiyonê nîşan nede" } diff --git a/translations/oc.json b/translations/oc.json index 5db6f0855..821c9cef2 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -491,5 +491,6 @@ "Content License": "Content License", "Reaction by": "Reaction by", "Notify on emoji reactions": "Notify on emoji reactions", - "Select reaction": "Select reaction" + "Select reaction": "Select reaction", + "Don't show the Reaction button": "Don't show the Reaction button" } diff --git a/translations/pt.json b/translations/pt.json index 556520314..90805fc67 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -495,5 +495,6 @@ "Content License": "Licença de Conteúdo", "Reaction by": "Reazione di", "Notify on emoji reactions": "Notificar sobre reações de emoji", - "Select reaction": "Selecione a reação" + "Select reaction": "Selecione a reação", + "Don't show the Reaction button": "Não mostrar o botão de reação" } diff --git a/translations/ru.json b/translations/ru.json index 7714015bd..8529e9935 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -495,5 +495,6 @@ "Content License": "Лицензия на содержание", "Reaction by": "Реакция со стороны", "Notify on emoji reactions": "Уведомлять о реакции на смайлики", - "Select reaction": "Выберите реакцию" + "Select reaction": "Выберите реакцию", + "Don't show the Reaction button": "Не показывать кнопку реакции" } diff --git a/translations/sw.json b/translations/sw.json index b153ee46b..487a73bb4 100644 --- a/translations/sw.json +++ b/translations/sw.json @@ -495,5 +495,6 @@ "Content License": "Leseni ya Maudhui", "Reaction by": "Majibu kwa", "Notify on emoji reactions": "Arifu kuhusu maitikio ya emoji", - "Select reaction": "Chagua majibu" + "Select reaction": "Chagua majibu", + "Don't show the Reaction button": "Usionyeshe kitufe cha Majibu" } diff --git a/translations/zh.json b/translations/zh.json index 319389d06..e339fb9a0 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -495,5 +495,6 @@ "Content License": "内容许可", "Reaction by": "反应由", "Notify on emoji reactions": "通知表情符号反应", - "Select reaction": "选择反应" + "Select reaction": "选择反应", + "Don't show the Reaction button": "不显示“反应”按钮" } diff --git a/webapp_post.py b/webapp_post.py index 486990216..649f97d66 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -704,6 +704,7 @@ def _getBookmarkIconHtml(nickname: str, domainFull: str, def _getReactionIconHtml(nickname: str, domainFull: str, postJsonObject: {}, isModerationPost: bool, + showReactionButton: bool, translate: {}, enableTimingLog: bool, postStartTime, boxName: str, @@ -713,7 +714,7 @@ def _getReactionIconHtml(nickname: str, domainFull: str, """ reactionStr = '' - if isModerationPost: + if not showReactionButton or isModerationPost: return reactionStr reactionIcon = 'reaction.png' @@ -1660,6 +1661,13 @@ def individualPostAsHtml(signingPrivateKeyPem: str, if os.path.isfile(hideLikeButtonFile): showLikeButton = False + # whether to show a reaction button + hideReactionButtonFile = \ + acctDir(baseDir, nickname, domain) + '/.hideReactionButton' + showReactionButton = True + if os.path.isfile(hideReactionButtonFile): + showReactionButton = False + likeJsonObject = postJsonObject if announceJsonObject: likeJsonObject = announceJsonObject @@ -1691,6 +1699,7 @@ def individualPostAsHtml(signingPrivateKeyPem: str, _getReactionIconHtml(nickname, domainFull, postJsonObject, isModerationPost, + showReactionButton, translate, enableTimingLog, postStartTime, boxName, diff --git a/webapp_profile.py b/webapp_profile.py index 1b68e8b47..807c996a4 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -1869,6 +1869,7 @@ def _htmlEditProfileOptions(isAdmin: bool, followDMs: str, removeTwitter: str, notifyLikes: str, notifyReactions: str, hideLikeButton: str, + hideReactionButton: str, translate: {}) -> str: """option checkboxes section of edit profile screen """ @@ -1898,6 +1899,9 @@ def _htmlEditProfileOptions(isAdmin: bool, editProfileForm += \ editCheckBox(translate["Don't show the Like button"], 'hideLikeButton', hideLikeButton) + editProfileForm += \ + editCheckBox(translate["Don't show the Reaction button"], + 'hideReactionButton', hideReactionButton) editProfileForm += ' \n' return editProfileForm @@ -2052,7 +2056,8 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str, displayNickname = nickname isBot = isGroup = followDMs = removeTwitter = '' - notifyLikes = notifyReactions = hideLikeButton = mediaInstanceStr = '' + notifyLikes = notifyReactions = '' + hideLikeButton = hideReactionButton = mediaInstanceStr = '' blogsInstanceStr = newsInstanceStr = movedTo = twitterStr = '' bioStr = donateUrl = websiteUrl = emailAddress = PGPpubKey = '' PGPfingerprint = xmppAddress = matrixAddress = '' @@ -2107,6 +2112,8 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str, notifyReactions = 'checked' if os.path.isfile(accountDir + '/.hideLikeButton'): hideLikeButton = 'checked' + if os.path.isfile(accountDir + '/.hideReactionButton'): + hideReactionButton = 'checked' mediaInstance = getConfigParam(baseDir, "mediaInstance") if mediaInstance: @@ -2203,7 +2210,8 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str, _htmlEditProfileOptions(isAdmin, manuallyApprovesFollowers, isBot, isGroup, followDMs, removeTwitter, notifyLikes, notifyReactions, - hideLikeButton, translate) + hideLikeButton, hideReactionButton, + translate) # Contact information editProfileForm += \