Link to who liked a post

merge-requests/8/head
Bob Mottram 2020-07-13 20:42:30 +01:00
parent 6b3e9396d7
commit 3333574007
18 changed files with 61 additions and 20 deletions

View File

@ -3444,6 +3444,13 @@ class PubServer(BaseHTTPRequestHandler):
# get an individual post from the path /@nickname/statusnumber # get an individual post from the path /@nickname/statusnumber
if '/@' in self.path: 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] namedStatus = self.path.split('/@')[1]
if '/' not in namedStatus: if '/' not in namedStatus:
# show actor # show actor
@ -3504,7 +3511,8 @@ class PubServer(BaseHTTPRequestHandler):
authorized, authorized,
postJsonObject, postJsonObject,
httpPrefix, httpPrefix,
projectVersion) projectVersion,
likedBy)
msg = msg.encode('utf-8') msg = msg.encode('utf-8')
self._set_headers('text/html', len(msg), self._set_headers('text/html', len(msg),
cookie, callingDomain) cookie, callingDomain)
@ -3897,6 +3905,12 @@ class PubServer(BaseHTTPRequestHandler):
# get an individual post from the path # get an individual post from the path
# /users/nickname/statuses/number # /users/nickname/statuses/number
if '/statuses/' in self.path and '/users/' in self.path: 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] namedStatus = self.path.split('/users/')[1]
if '/' in namedStatus: if '/' in namedStatus:
postSections = namedStatus.split('/') postSections = namedStatus.split('/')
@ -3957,7 +3971,8 @@ class PubServer(BaseHTTPRequestHandler):
authorized, authorized,
postJsonObject, postJsonObject,
httpPrefix, httpPrefix,
projectVersion) projectVersion,
likedBy)
msg = msg.encode('utf-8') msg = msg.encode('utf-8')
self._set_headers('text/html', self._set_headers('text/html',
len(msg), len(msg),

View File

@ -1775,7 +1775,7 @@ def likeNotify(baseDir: str, domain: str, onionDomain: str,
str(likerNickname) + '@' + str(likerDomain)) str(likerNickname) + '@' + str(likerDomain))
likerHandle = actor likerHandle = actor
if likerHandle != handle: if likerHandle != handle:
likeStr = likerHandle + ' ' + url likeStr = likerHandle + ' ' + url + '?likedBy=' + actor
prevLikeFile = accountDir + '/.prevLike' prevLikeFile = accountDir + '/.prevLike'
# was there a previous like notification? # was there a previous like notification?
if os.path.isfile(prevLikeFile): if os.path.isfile(prevLikeFile):

View File

@ -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": "درجات الرمادي",
"Liked by": "نال إعجاب"
} }

View File

@ -251,5 +251,6 @@
"Unavailable": "No disponible", "Unavailable": "No disponible",
"The server is busy. Please try again later": "El servidor està ocupat. Siusplau, intenta-ho més tard", "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 daquest compte", "Receive calendar events from this account": "Rep esdeveniments del calendari des daquest compte",
"Grayscale": "Escala de grisos" "Grayscale": "Escala de grisos",
"Liked by": "M'agrada"
} }

View File

@ -251,5 +251,6 @@
"Unavailable": "Ddim ar gael", "Unavailable": "Ddim ar gael",
"The server is busy. Please try again later": "Mae'r gweinydd yn brysur. Rho gynnig Arni eto'n hwyrach", "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", "Receive calendar events from this account": "Derbyn digwyddiadau calendr o'r cyfrif hwn",
"Grayscale": "Graddlwyd" "Grayscale": "Graddlwyd",
"Liked by": "Hoffi"
} }

View File

@ -251,5 +251,6 @@
"Unavailable": "Nicht verfügbar", "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", "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", "Receive calendar events from this account": "Erhalten Sie Kalenderereignisse von diesem Konto",
"Grayscale": "Graustufen" "Grayscale": "Graustufen",
"Liked by": "Gefallen von"
} }

View File

@ -251,5 +251,6 @@
"Unavailable": "Unavailable", "Unavailable": "Unavailable",
"The server is busy. Please try again later": "The server is busy. Please try again later", "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", "Receive calendar events from this account": "Receive calendar events from this account",
"Grayscale": "Grayscale" "Grayscale": "Grayscale",
"Liked by": "Liked by"
} }

View File

@ -251,5 +251,6 @@
"Unavailable": "Indisponible", "Unavailable": "Indisponible",
"The server is busy. Please try again later": "El servidor esta ocupado. Por favor, inténtelo de nuevo más tarde", "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", "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"
} }

View File

@ -251,5 +251,6 @@
"Unavailable": "Indisponible", "Unavailable": "Indisponible",
"The server is busy. Please try again later": "Le serveur est occupé. Veuillez réessayer plus tard", "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", "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"
} }

View File

@ -251,5 +251,6 @@
"Unavailable": "Níl sé ar fáil", "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í", "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", "Receive calendar events from this account": "Faigh imeachtaí féilire ón gcuntas seo",
"Grayscale": "Liathscála" "Grayscale": "Liathscála",
"Liked by": "Thaitin"
} }

View File

@ -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": "ग्रेस्केल",
"Liked by": "द्वारा पसंद किया गया"
} }

View File

@ -251,5 +251,6 @@
"Unavailable": "non disponibile", "Unavailable": "non disponibile",
"The server is busy. Please try again later": "Il server è occupato. Per favore riprova più tardi", "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", "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"
} }

View File

@ -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": "グレースケール",
"Liked by": "好き"
} }

View File

@ -247,5 +247,6 @@
"Unavailable": "Unavailable", "Unavailable": "Unavailable",
"The server is busy. Please try again later": "The server is busy. Please try again later", "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", "Receive calendar events from this account": "Receive calendar events from this account",
"Grayscale": "Grayscale" "Grayscale": "Grayscale",
"Liked by": "Liked by"
} }

View File

@ -251,5 +251,6 @@
"Unavailable": "Indisponível", "Unavailable": "Indisponível",
"The server is busy. Please try again later": "O servidor está ocupado. Por favor, tente novamente mais tarde", "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", "Receive calendar events from this account": "Receba eventos da agenda desta conta",
"Grayscale": "Escala de cinza" "Grayscale": "Escala de cinza",
"Liked by": "Curtida por"
} }

View File

@ -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": "Оттенки серого",
"Liked by": "Понравилось"
} }

View File

@ -250,5 +250,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": "灰阶",
"Liked by": "喜欢的人"
} }

View File

@ -4983,11 +4983,22 @@ def htmlIndividualPost(recentPostsCache: {}, maxRecentPosts: int,
baseDir: str, session, wfRequest: {}, personCache: {}, baseDir: str, session, wfRequest: {}, personCache: {},
nickname: str, domain: str, port: int, authorized: bool, nickname: str, domain: str, port: int, authorized: bool,
postJsonObject: {}, httpPrefix: str, postJsonObject: {}, httpPrefix: str,
projectVersion: str) -> str: projectVersion: str, likedBy: str) -> str:
"""Show an individual post as html """Show an individual post as html
""" """
iconsDir = getIconsDir(baseDir) 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 += \
'<p>' + translate['Liked by'] + \
' <a href="' + likedBy + '">@' + \
likedByNickname + '@' + likedByDomain + '</a></p>\n'
postStr += \
individualPostAsHtml(recentPostsCache, maxRecentPosts, individualPostAsHtml(recentPostsCache, maxRecentPosts,
iconsDir, translate, None, iconsDir, translate, None,
baseDir, session, wfRequest, personCache, baseDir, session, wfRequest, personCache,