Notify about emoji reactions

main
Bob Mottram 2021-11-10 19:13:23 +00:00
parent f36000246d
commit 6b86c83db0
21 changed files with 105 additions and 30 deletions

View File

@ -8960,6 +8960,18 @@ class PubServer(BaseHTTPRequestHandler):
likedBy = likedBy.split('?')[0] likedBy = likedBy.split('?')[0]
path = path.split('?likedBy=')[0] path = path.split('?likedBy=')[0]
reactBy = None
reactEmoji = None
if '?reactBy=' in path:
reactBy = path.split('?reactBy=')[1].strip()
if ';' in reactBy:
reactBy = reactBy.split(';')[0]
if ';emoj=' in path:
reactEmoji = path.split(';emoj=')[1].strip()
if ';' in reactEmoji:
reactEmoji = reactEmoji.split(';')[0]
path = path.split('?reactBy=')[0]
namedStatus = path.split('/@')[1] namedStatus = path.split('/@')[1]
if '/' not in namedStatus: if '/' not in namedStatus:
# show actor # show actor
@ -8984,6 +8996,7 @@ class PubServer(BaseHTTPRequestHandler):
includeCreateWrapper = True includeCreateWrapper = True
result = self._showPostFromFile(postFilename, likedBy, result = self._showPostFromFile(postFilename, likedBy,
reactBy, reactEmoji,
authorized, callingDomain, path, authorized, callingDomain, path,
baseDir, httpPrefix, nickname, baseDir, httpPrefix, nickname,
domain, domainFull, port, domain, domainFull, port,
@ -8997,6 +9010,7 @@ class PubServer(BaseHTTPRequestHandler):
return result return result
def _showPostFromFile(self, postFilename: str, likedBy: str, def _showPostFromFile(self, postFilename: str, likedBy: str,
reactBy: str, reactEmoji: str,
authorized: bool, authorized: bool,
callingDomain: str, path: str, callingDomain: str, path: str,
baseDir: str, httpPrefix: str, nickname: str, baseDir: str, httpPrefix: str, nickname: str,
@ -9043,7 +9057,7 @@ class PubServer(BaseHTTPRequestHandler):
postJsonObject, postJsonObject,
httpPrefix, httpPrefix,
self.server.projectVersion, self.server.projectVersion,
likedBy, likedBy, reactBy, reactEmoji,
self.server.YTReplacementDomain, self.server.YTReplacementDomain,
self.server.twitterReplacementDomain, self.server.twitterReplacementDomain,
self.server.showPublishedDateOnly, self.server.showPublishedDateOnly,
@ -9106,6 +9120,19 @@ class PubServer(BaseHTTPRequestHandler):
if '?' in likedBy: if '?' in likedBy:
likedBy = likedBy.split('?')[0] likedBy = likedBy.split('?')[0]
path = path.split('?likedBy=')[0] path = path.split('?likedBy=')[0]
reactBy = None
reactEmoji = None
if '?reactBy=' in path:
reactBy = path.split('?reactBy=')[1].strip()
if ';' in reactBy:
reactBy = reactBy.split(';')[0]
if ';emoj=' in path:
reactEmoji = path.split(';emoj=')[1].strip()
if ';' in reactEmoji:
reactEmoji = reactEmoji.split(';')[0]
path = path.split('?reactBy=')[0]
namedStatus = path.split('/users/')[1] namedStatus = path.split('/users/')[1]
if '/' not in namedStatus: if '/' not in namedStatus:
return False return False
@ -9127,6 +9154,7 @@ class PubServer(BaseHTTPRequestHandler):
includeCreateWrapper = True includeCreateWrapper = True
result = self._showPostFromFile(postFilename, likedBy, result = self._showPostFromFile(postFilename, likedBy,
reactBy, reactEmoji,
authorized, callingDomain, path, authorized, callingDomain, path,
baseDir, httpPrefix, nickname, baseDir, httpPrefix, nickname,
domain, domainFull, port, domain, domainFull, port,
@ -9151,6 +9179,8 @@ class PubServer(BaseHTTPRequestHandler):
and where you have the notify checkbox set on person options and where you have the notify checkbox set on person options
""" """
likedBy = None likedBy = None
reactBy = None
reactEmoji = None
postId = path.split('?notifypost=')[1].strip() postId = path.split('?notifypost=')[1].strip()
postId = postId.replace('-', '/') postId = postId.replace('-', '/')
path = path.split('?notifypost=')[0] path = path.split('?notifypost=')[0]
@ -9168,6 +9198,7 @@ class PubServer(BaseHTTPRequestHandler):
includeCreateWrapper = True includeCreateWrapper = True
result = self._showPostFromFile(postFilename, likedBy, result = self._showPostFromFile(postFilename, likedBy,
reactBy, reactEmoji,
authorized, callingDomain, path, authorized, callingDomain, path,
baseDir, httpPrefix, nickname, baseDir, httpPrefix, nickname,
domain, domainFull, port, domain, domainFull, port,

View File

@ -529,7 +529,8 @@ def htmlEmojiReactions(postJsonObject: {}, interactive: bool,
reactions[emojiContent] += 1 reactions[emojiContent] += 1
if len(reactions.items()) == 0: if len(reactions.items()) == 0:
return '' return ''
baseUrl = actor + '?reactUrl=' + postJsonObject['object']['id'] + ';emoj=' reactBy = removeIdEnding(postJsonObject['object']['id'])
baseUrl = actor + '?reactBy=' + reactBy + ';emoj='
htmlStr = '<div class="emojiReactionBar">\n' htmlStr = '<div class="emojiReactionBar">\n'
for emojiContent, count in reactions.items(): for emojiContent, count in reactions.items():
htmlStr += ' <div class="emojiReactionButton">\n' htmlStr += ' <div class="emojiReactionButton">\n'

View File

@ -215,6 +215,21 @@ function notifications {
fi fi
fi fi
# send notifications for emoji reactions to XMPP/email users
epicyonLikeFile="$epicyonDir/.newReaction"
if [ -f "$epicyonReactionFile" ]; then
if ! grep -q "##sent##" "$epicyonReactionFile"; then
epicyonReactionMessage=$(notification_translate_text 'Reaction by')
epicyonReactionFileContent=$(cat "$epicyonReactionFile" | awk -F ' ' '{print $1}')" "$(echo "$epicyonReactionMessage")" "$(cat "$epicyonReactionFile" | awk -F ' ' '{print $2}')
if [[ "$epicyonReactionFileContent" == *':'* ]]; then
epicyonReactionMessage="Epicyon: $epicyonReactionFileContent"
fi
sendNotification "$USERNAME" "Epicyon" "$epicyonReactionMessage"
echo "##sent##" > "$epicyonReactionFile"
chown ${PROJECT_NAME}:${PROJECT_NAME} "$epicyonReactionFile"
fi
fi
# send notifications for posts arriving from a particular person # send notifications for posts arriving from a particular person
epicyonNotifyFile="$epicyonDir/.newNotifiedPost" epicyonNotifyFile="$epicyonDir/.newNotifiedPost"
if [ -f "$epicyonNotifyFile" ]; then if [ -f "$epicyonNotifyFile" ]; then

View File

@ -492,5 +492,6 @@
"Add content warnings for the following sites": "أضف تحذيرات المحتوى للمواقع التالية", "Add content warnings for the following sites": "أضف تحذيرات المحتوى للمواقع التالية",
"Known Web Crawlers": "برامج زحف الويب المعروفة", "Known Web Crawlers": "برامج زحف الويب المعروفة",
"Add to the calendar": "أضف إلى التقويم", "Add to the calendar": "أضف إلى التقويم",
"Content License": "ترخيص المحتوى" "Content License": "ترخيص المحتوى",
"Reaction by": "رد فعل"
} }

View File

@ -492,5 +492,6 @@
"Add content warnings for the following sites": "Afegiu advertiments de contingut per als llocs següents", "Add content warnings for the following sites": "Afegiu advertiments de contingut per als llocs següents",
"Known Web Crawlers": "Exploradors web coneguts", "Known Web Crawlers": "Exploradors web coneguts",
"Add to the calendar": "Afegeix al calendari", "Add to the calendar": "Afegeix al calendari",
"Content License": "Llicència de contingut" "Content License": "Llicència de contingut",
"Reaction by": "Reacció de"
} }

View File

@ -492,5 +492,6 @@
"Add content warnings for the following sites": "Ychwanegwch rybuddion cynnwys ar gyfer y gwefannau canlynol", "Add content warnings for the following sites": "Ychwanegwch rybuddion cynnwys ar gyfer y gwefannau canlynol",
"Known Web Crawlers": "Crawlers Gwe Hysbys", "Known Web Crawlers": "Crawlers Gwe Hysbys",
"Add to the calendar": "Ychwanegwch at y calendr", "Add to the calendar": "Ychwanegwch at y calendr",
"Content License": "Trwydded Cynnwys" "Content License": "Trwydded Cynnwys",
"Reaction by": "Ymateb gan"
} }

View File

@ -492,5 +492,6 @@
"Add content warnings for the following sites": "Inhaltswarnungen für die folgenden Websites hinzufügen", "Add content warnings for the following sites": "Inhaltswarnungen für die folgenden Websites hinzufügen",
"Known Web Crawlers": "Bekannte Web-Crawler", "Known Web Crawlers": "Bekannte Web-Crawler",
"Add to the calendar": "Zum Kalender hinzufügen", "Add to the calendar": "Zum Kalender hinzufügen",
"Content License": "Inhaltslizenz" "Content License": "Inhaltslizenz",
"Reaction by": "Reaktion von"
} }

View File

@ -492,5 +492,6 @@
"Add content warnings for the following sites": "Add content warnings for the following sites", "Add content warnings for the following sites": "Add content warnings for the following sites",
"Known Web Crawlers": "Known Web Crawlers", "Known Web Crawlers": "Known Web Crawlers",
"Add to the calendar": "Add to the calendar", "Add to the calendar": "Add to the calendar",
"Content License": "Content License" "Content License": "Content License",
"Reaction by": "Reaction by"
} }

View File

@ -492,5 +492,6 @@
"Add content warnings for the following sites": "Agregue advertencias de contenido para los siguientes sitios", "Add content warnings for the following sites": "Agregue advertencias de contenido para los siguientes sitios",
"Known Web Crawlers": "Rastreadores web conocidos", "Known Web Crawlers": "Rastreadores web conocidos",
"Add to the calendar": "Agregar al calendario", "Add to the calendar": "Agregar al calendario",
"Content License": "Licencia de contenido" "Content License": "Licencia de contenido",
"Reaction by": "Reacción de"
} }

View File

@ -492,5 +492,6 @@
"Add content warnings for the following sites": "Ajouter des avertissements de contenu pour les sites suivants", "Add content warnings for the following sites": "Ajouter des avertissements de contenu pour les sites suivants",
"Known Web Crawlers": "Crawlers Web connus", "Known Web Crawlers": "Crawlers Web connus",
"Add to the calendar": "Ajouter au calendrier", "Add to the calendar": "Ajouter au calendrier",
"Content License": "Licence de contenu" "Content License": "Licence de contenu",
"Reaction by": "Réaction par"
} }

View File

@ -492,5 +492,6 @@
"Add content warnings for the following sites": "Cuir rabhaidh ábhair leis na suíomhanna seo a leanas", "Add content warnings for the following sites": "Cuir rabhaidh ábhair leis na suíomhanna seo a leanas",
"Known Web Crawlers": "Crawlers Gréasáin Aitheanta", "Known Web Crawlers": "Crawlers Gréasáin Aitheanta",
"Add to the calendar": "Cuir leis an bhféilire", "Add to the calendar": "Cuir leis an bhféilire",
"Content License": "Ceadúnas Ábhar" "Content License": "Ceadúnas Ábhar",
"Reaction by": "Imoibriú le"
} }

View File

@ -492,5 +492,6 @@
"Add content warnings for the following sites": "निम्नलिखित साइटों के लिए सामग्री चेतावनियाँ जोड़ें", "Add content warnings for the following sites": "निम्नलिखित साइटों के लिए सामग्री चेतावनियाँ जोड़ें",
"Known Web Crawlers": "ज्ञात वेब क्रॉलर", "Known Web Crawlers": "ज्ञात वेब क्रॉलर",
"Add to the calendar": "कैलेंडर में जोड़ें", "Add to the calendar": "कैलेंडर में जोड़ें",
"Content License": "सामग्री लाइसेंस" "Content License": "सामग्री लाइसेंस",
"Reaction by": "द्वारा प्रतिक्रिया"
} }

View File

@ -492,5 +492,6 @@
"Add content warnings for the following sites": "Aggiungi avvisi sui contenuti per i seguenti siti", "Add content warnings for the following sites": "Aggiungi avvisi sui contenuti per i seguenti siti",
"Known Web Crawlers": "Crawler Web conosciuti", "Known Web Crawlers": "Crawler Web conosciuti",
"Add to the calendar": "Aggiungi al calendario", "Add to the calendar": "Aggiungi al calendario",
"Content License": "Licenza sui contenuti" "Content License": "Licenza sui contenuti",
"Reaction by": "Reazione di"
} }

View File

@ -492,5 +492,6 @@
"Add content warnings for the following sites": "次のサイトのコンテンツ警告を追加します", "Add content warnings for the following sites": "次のサイトのコンテンツ警告を追加します",
"Known Web Crawlers": "既知のWebクローラー", "Known Web Crawlers": "既知のWebクローラー",
"Add to the calendar": "カレンダーに追加", "Add to the calendar": "カレンダーに追加",
"Content License": "コンテンツライセンス" "Content License": "コンテンツライセンス",
"Reaction by": "による反応"
} }

View File

@ -492,5 +492,6 @@
"Add content warnings for the following sites": "Ji bo malperên jêrîn hişyariyên naverokê zêde bikin", "Add content warnings for the following sites": "Ji bo malperên jêrîn hişyariyên naverokê zêde bikin",
"Known Web Crawlers": "Crawlerên Webê yên naskirî", "Known Web Crawlers": "Crawlerên Webê yên naskirî",
"Add to the calendar": "Di salnameyê de zêde bike", "Add to the calendar": "Di salnameyê de zêde bike",
"Content License": "Naverok License de" "Content License": "Naverok License de",
"Reaction by": "Reaction by"
} }

View File

@ -488,5 +488,6 @@
"Add content warnings for the following sites": "Add content warnings for the following sites", "Add content warnings for the following sites": "Add content warnings for the following sites",
"Known Web Crawlers": "Known Web Crawlers", "Known Web Crawlers": "Known Web Crawlers",
"Add to the calendar": "Add to the calendar", "Add to the calendar": "Add to the calendar",
"Content License": "Content License" "Content License": "Content License",
"Reaction by": "Reaction by"
} }

View File

@ -492,5 +492,6 @@
"Add content warnings for the following sites": "Adicione avisos de conteúdo para os seguintes sites", "Add content warnings for the following sites": "Adicione avisos de conteúdo para os seguintes sites",
"Known Web Crawlers": "Rastreadores da Web conhecidos", "Known Web Crawlers": "Rastreadores da Web conhecidos",
"Add to the calendar": "Adicionar ao calendário", "Add to the calendar": "Adicionar ao calendário",
"Content License": "Licença de Conteúdo" "Content License": "Licença de Conteúdo",
"Reaction by": "Reazione di"
} }

View File

@ -492,5 +492,6 @@
"Add content warnings for the following sites": "Добавить предупреждения о содержании для следующих сайтов", "Add content warnings for the following sites": "Добавить предупреждения о содержании для следующих сайтов",
"Known Web Crawlers": "Известные веб-сканеры", "Known Web Crawlers": "Известные веб-сканеры",
"Add to the calendar": "Добавить в календарь", "Add to the calendar": "Добавить в календарь",
"Content License": "Лицензия на содержание" "Content License": "Лицензия на содержание",
"Reaction by": "Реакция со стороны"
} }

View File

@ -492,5 +492,6 @@
"Add content warnings for the following sites": "Ongeza maonyo ya yaliyomo kwa wavuti zifuatazo", "Add content warnings for the following sites": "Ongeza maonyo ya yaliyomo kwa wavuti zifuatazo",
"Known Web Crawlers": "Watambaji Wavuti Wanaojulikana", "Known Web Crawlers": "Watambaji Wavuti Wanaojulikana",
"Add to the calendar": "Ongeza kwenye kalenda", "Add to the calendar": "Ongeza kwenye kalenda",
"Content License": "Leseni ya Maudhui" "Content License": "Leseni ya Maudhui",
"Reaction by": "Majibu kwa"
} }

View File

@ -492,5 +492,6 @@
"Add content warnings for the following sites": "为以下网站添加内容警告", "Add content warnings for the following sites": "为以下网站添加内容警告",
"Known Web Crawlers": "已知的网络爬虫", "Known Web Crawlers": "已知的网络爬虫",
"Add to the calendar": "添加到日历", "Add to the calendar": "添加到日历",
"Content License": "内容许可" "Content License": "内容许可",
"Reaction by": "反应由"
} }

View File

@ -1925,6 +1925,7 @@ def htmlIndividualPost(cssCache: {},
nickname: str, domain: str, port: int, authorized: bool, nickname: str, domain: str, port: int, authorized: bool,
postJsonObject: {}, httpPrefix: str, postJsonObject: {}, httpPrefix: str,
projectVersion: str, likedBy: str, projectVersion: str, likedBy: str,
reactBy: str, reactEmoji: str,
YTReplacementDomain: str, YTReplacementDomain: str,
twitterReplacementDomain: str, twitterReplacementDomain: str,
showPublishedDateOnly: bool, showPublishedDateOnly: bool,
@ -1937,17 +1938,27 @@ def htmlIndividualPost(cssCache: {},
""" """
originalPostJson = postJsonObject originalPostJson = postJsonObject
postStr = '' postStr = ''
byStr = ''
byText = ''
byTextExtra = ''
if likedBy: if likedBy:
likedByNickname = getNicknameFromActor(likedBy) byStr = likedBy
likedByDomain, likedByPort = getDomainFromActor(likedBy) byText = 'Liked by'
likedByDomain = getFullDomain(likedByDomain, likedByPort) elif reactBy and reactEmoji:
likedByHandle = likedByNickname + '@' + likedByDomain byStr = reactBy
likedByStr = 'Liked by' byText = 'Reaction by'
if translate.get(likedByStr): byTextExtra = ' ' + reactEmoji
likedByStr = translate[likedByStr]
if byStr:
byStrNickname = getNicknameFromActor(byStr)
byStrDomain, byStrPort = getDomainFromActor(byStr)
byStrDomain = getFullDomain(byStrDomain, byStrPort)
byStrHandle = byStrNickname + '@' + byStrDomain
if translate.get(byText):
byText = translate[byText]
postStr += \ postStr += \
'<p>' + likedByStr + ' <a href="' + likedBy + '">@' + \ '<p>' + byText + ' <a href="' + byStr + '">@' + \
likedByHandle + '</a>\n' byStrHandle + '</a>' + byTextExtra + '\n'
domainFull = getFullDomain(domain, port) domainFull = getFullDomain(domain, port)
actor = '/users/' + nickname actor = '/users/' + nickname
@ -1957,8 +1968,8 @@ def htmlIndividualPost(cssCache: {},
' <input type="hidden" name="actor" value="' + actor + '">\n' ' <input type="hidden" name="actor" value="' + actor + '">\n'
followStr += \ followStr += \
' <input type="hidden" name="searchtext" value="' + \ ' <input type="hidden" name="searchtext" value="' + \
likedByHandle + '">\n' byStrHandle + '">\n'
if not isFollowingActor(baseDir, nickname, domainFull, likedBy): if not isFollowingActor(baseDir, nickname, domainFull, byStr):
translateFollowStr = 'Follow' translateFollowStr = 'Follow'
if translate.get(translateFollowStr): if translate.get(translateFollowStr):
translateFollowStr = translate[translateFollowStr] translateFollowStr = translate[translateFollowStr]