From 333357400761037f9dba5aa8636524f1e43afaae Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 13 Jul 2020 20:42:30 +0100 Subject: [PATCH] Link to who liked a post --- daemon.py | 19 +++++++++++++++++-- inbox.py | 2 +- 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/oc.json | 3 ++- translations/pt.json | 3 ++- translations/ru.json | 3 ++- translations/zh.json | 3 ++- webinterface.py | 15 +++++++++++++-- 18 files changed, 61 insertions(+), 20 deletions(-) diff --git a/daemon.py b/daemon.py index 6795a1504..6b9892f95 100644 --- a/daemon.py +++ b/daemon.py @@ -3444,6 +3444,13 @@ class PubServer(BaseHTTPRequestHandler): # get an individual post from the path /@nickname/statusnumber if '/@' in self.path: + likedBy = None + if '?likedBy=' in self.path: + likedBy = self.path.split('?likedBy=')[1].strip() + if '?' in likedBy: + likedBy = likedBy.split('?')[0] + self.path = self.path.split('?likedBy=')[0] + namedStatus = self.path.split('/@')[1] if '/' not in namedStatus: # show actor @@ -3504,7 +3511,8 @@ class PubServer(BaseHTTPRequestHandler): authorized, postJsonObject, httpPrefix, - projectVersion) + projectVersion, + likedBy) msg = msg.encode('utf-8') self._set_headers('text/html', len(msg), cookie, callingDomain) @@ -3897,6 +3905,12 @@ class PubServer(BaseHTTPRequestHandler): # get an individual post from the path # /users/nickname/statuses/number if '/statuses/' in self.path and '/users/' in self.path: + likedBy = None + if '?likedBy=' in self.path: + likedBy = self.path.split('?likedBy=')[1].strip() + if '?' in likedBy: + likedBy = likedBy.split('?')[0] + self.path = self.path.split('?likedBy=')[0] namedStatus = self.path.split('/users/')[1] if '/' in namedStatus: postSections = namedStatus.split('/') @@ -3957,7 +3971,8 @@ class PubServer(BaseHTTPRequestHandler): authorized, postJsonObject, httpPrefix, - projectVersion) + projectVersion, + likedBy) msg = msg.encode('utf-8') self._set_headers('text/html', len(msg), diff --git a/inbox.py b/inbox.py index be5af0ce0..171206ce5 100644 --- a/inbox.py +++ b/inbox.py @@ -1775,7 +1775,7 @@ def likeNotify(baseDir: str, domain: str, onionDomain: str, str(likerNickname) + '@' + str(likerDomain)) likerHandle = actor if likerHandle != handle: - likeStr = likerHandle + ' ' + url + likeStr = likerHandle + ' ' + url + '?likedBy=' + actor prevLikeFile = accountDir + '/.prevLike' # was there a previous like notification? if os.path.isfile(prevLikeFile): diff --git a/translations/ar.json b/translations/ar.json index cf3cad0fb..4bd93a6ce 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -251,5 +251,6 @@ "Unavailable": "غير متوفره", "The server is busy. Please try again later": "الخادم مشغول. الرجاء معاودة المحاولة في وقت لاحق", "Receive calendar events from this account": "تلقي أحداث التقويم من هذا الحساب", - "Grayscale": "درجات الرمادي" + "Grayscale": "درجات الرمادي", + "Liked by": "نال إعجاب" } diff --git a/translations/ca.json b/translations/ca.json index cfb4be41c..ccaebffa1 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -251,5 +251,6 @@ "Unavailable": "No disponible", "The server is busy. Please try again later": "El servidor està ocupat. Siusplau, intenta-ho més tard", "Receive calendar events from this account": "Rep esdeveniments del calendari des d’aquest compte", - "Grayscale": "Escala de grisos" + "Grayscale": "Escala de grisos", + "Liked by": "M'agrada" } diff --git a/translations/cy.json b/translations/cy.json index 508955a57..4544c2de4 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -251,5 +251,6 @@ "Unavailable": "Ddim ar gael", "The server is busy. Please try again later": "Mae'r gweinydd yn brysur. Rho gynnig Arni eto'n hwyrach", "Receive calendar events from this account": "Derbyn digwyddiadau calendr o'r cyfrif hwn", - "Grayscale": "Graddlwyd" + "Grayscale": "Graddlwyd", + "Liked by": "Hoffi" } diff --git a/translations/de.json b/translations/de.json index 63919ff73..25e70a00e 100644 --- a/translations/de.json +++ b/translations/de.json @@ -251,5 +251,6 @@ "Unavailable": "Nicht verfügbar", "The server is busy. Please try again later": "Der Server ist beschäftigt. Bitte versuchen Sie es später noch einmal", "Receive calendar events from this account": "Erhalten Sie Kalenderereignisse von diesem Konto", - "Grayscale": "Graustufen" + "Grayscale": "Graustufen", + "Liked by": "Gefallen von" } diff --git a/translations/en.json b/translations/en.json index 3f8e37521..44a323614 100644 --- a/translations/en.json +++ b/translations/en.json @@ -251,5 +251,6 @@ "Unavailable": "Unavailable", "The server is busy. Please try again later": "The server is busy. Please try again later", "Receive calendar events from this account": "Receive calendar events from this account", - "Grayscale": "Grayscale" + "Grayscale": "Grayscale", + "Liked by": "Liked by" } diff --git a/translations/es.json b/translations/es.json index a49c3e296..cedb08a47 100644 --- a/translations/es.json +++ b/translations/es.json @@ -251,5 +251,6 @@ "Unavailable": "Indisponible", "The server is busy. Please try again later": "El servidor esta ocupado. Por favor, inténtelo de nuevo más tarde", "Receive calendar events from this account": "Recibe eventos de calendario de esta cuenta", - "Grayscale": "Escala de grises" + "Grayscale": "Escala de grises", + "Liked by": "Apreciado por" } diff --git a/translations/fr.json b/translations/fr.json index 3b59c6ce2..35413a30d 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -251,5 +251,6 @@ "Unavailable": "Indisponible", "The server is busy. Please try again later": "Le serveur est occupé. Veuillez réessayer plus tard", "Receive calendar events from this account": "Recevoir des événements d'agenda de ce compte", - "Grayscale": "Niveaux de gris" + "Grayscale": "Niveaux de gris", + "Liked by": "Aimé par" } diff --git a/translations/ga.json b/translations/ga.json index f905ea89e..89c3d8df4 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -251,5 +251,6 @@ "Unavailable": "Níl sé ar fáil", "The server is busy. Please try again later": "Tá an freastalaí gnóthach. Bain triail eile as níos déanaí", "Receive calendar events from this account": "Faigh imeachtaí féilire ón gcuntas seo", - "Grayscale": "Liathscála" + "Grayscale": "Liathscála", + "Liked by": "Thaitin" } diff --git a/translations/hi.json b/translations/hi.json index 253a727a0..7222f66c6 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -251,5 +251,6 @@ "Unavailable": "अनुपलब्ध", "The server is busy. Please try again later": "सर्वर व्यस्त है। बाद में पुन: प्रयास करें", "Receive calendar events from this account": "इस खाते से कैलेंडर ईवेंट प्राप्त करें", - "Grayscale": "ग्रेस्केल" + "Grayscale": "ग्रेस्केल", + "Liked by": "द्वारा पसंद किया गया" } diff --git a/translations/it.json b/translations/it.json index a5d0ace2f..fa88fb7d4 100644 --- a/translations/it.json +++ b/translations/it.json @@ -251,5 +251,6 @@ "Unavailable": "non disponibile", "The server is busy. Please try again later": "Il server è occupato. Per favore riprova più tardi", "Receive calendar events from this account": "Ricevi eventi di calendario da questo account", - "Grayscale": "Scala di grigi" + "Grayscale": "Scala di grigi", + "Liked by": "Mi è piaciuto" } diff --git a/translations/ja.json b/translations/ja.json index 33574f2c2..7952606c5 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -251,5 +251,6 @@ "Unavailable": "利用できません", "The server is busy. Please try again later": "サーバーはビジーです。 後でもう一度やり直してください", "Receive calendar events from this account": "このアカウントからカレンダーイベントを受信します", - "Grayscale": "グレースケール" + "Grayscale": "グレースケール", + "Liked by": "好き" } diff --git a/translations/oc.json b/translations/oc.json index e1f09dfd5..006a4f40a 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -247,5 +247,6 @@ "Unavailable": "Unavailable", "The server is busy. Please try again later": "The server is busy. Please try again later", "Receive calendar events from this account": "Receive calendar events from this account", - "Grayscale": "Grayscale" + "Grayscale": "Grayscale", + "Liked by": "Liked by" } diff --git a/translations/pt.json b/translations/pt.json index fa1299000..930e15d55 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -251,5 +251,6 @@ "Unavailable": "Indisponível", "The server is busy. Please try again later": "O servidor está ocupado. Por favor, tente novamente mais tarde", "Receive calendar events from this account": "Receba eventos da agenda desta conta", - "Grayscale": "Escala de cinza" + "Grayscale": "Escala de cinza", + "Liked by": "Curtida por" } diff --git a/translations/ru.json b/translations/ru.json index c15f68cd4..bf69ce736 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -251,5 +251,6 @@ "Unavailable": "Недоступен", "The server is busy. Please try again later": "Сервер занят. Пожалуйста, попробуйте позже", "Receive calendar events from this account": "Получать события календаря от этого аккаунта", - "Grayscale": "Оттенки серого" + "Grayscale": "Оттенки серого", + "Liked by": "Понравилось" } diff --git a/translations/zh.json b/translations/zh.json index a1886a2c8..8b8c89c38 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -250,5 +250,6 @@ "Unavailable": "不可用", "The server is busy. Please try again later": "服务器忙。 请稍后再试", "Receive calendar events from this account": "从该帐户接收日历事件", - "Grayscale": "灰阶" + "Grayscale": "灰阶", + "Liked by": "喜欢的人" } diff --git a/webinterface.py b/webinterface.py index ecc49606b..2453e50cd 100644 --- a/webinterface.py +++ b/webinterface.py @@ -4983,11 +4983,22 @@ def htmlIndividualPost(recentPostsCache: {}, maxRecentPosts: int, baseDir: str, session, wfRequest: {}, personCache: {}, nickname: str, domain: str, port: int, authorized: bool, postJsonObject: {}, httpPrefix: str, - projectVersion: str) -> str: + projectVersion: str, likedBy: str) -> str: """Show an individual post as html """ iconsDir = getIconsDir(baseDir) - postStr = \ + postStr = '' + if likedBy: + likedByNickname = getNicknameFromActor(likedBy) + likedByDomain, likedByPort = getDomainFromActor(likedBy) + if likedByPort: + if likedByPort != 80 and likedByPort != 443: + likedByDomain += ':' + str(likedByPort) + postStr += \ + '

' + translate['Liked by'] + \ + ' @' + \ + likedByNickname + '@' + likedByDomain + '

\n' + postStr += \ individualPostAsHtml(recentPostsCache, maxRecentPosts, iconsDir, translate, None, baseDir, session, wfRequest, personCache,