Screen showing announcers of a post

merge-requests/30/head
Bob Mottram 2022-03-02 14:27:31 +00:00
parent b644523d30
commit 742c69163a
19 changed files with 124 additions and 23 deletions

View File

@ -10486,6 +10486,68 @@ class PubServer(BaseHTTPRequestHandler):
self.server.debug)
return True
def _show_announcers_of_post(self, authorized: bool,
calling_domain: str, path: str,
base_dir: str, http_prefix: str,
domain: str, domain_full: str, port: int,
onion_domain: str, i2p_domain: str,
getreq_start_time,
proxy_type: str, cookie: str,
debug: str) -> bool:
"""Show the announcers of a post
"""
if not authorized:
return False
if '?announcers=' not in path:
return False
if '/users/' not in path:
return False
nickname = path.split('/users/')[1]
if '?' in nickname:
nickname = nickname.split('?')[0]
post_url = path.split('?announcers=')[1]
if '?' in post_url:
post_url = post_url.split('?')[0]
post_url = post_url.replace('--', '/')
# note that the likers function is reused, but with 'shares'
msg = \
html_likers_of_post(base_dir, nickname, domain, port,
post_url, self.server.translate,
http_prefix,
self.server.theme_name,
self.server.access_keys,
self.server.recent_posts_cache,
self.server.max_recent_posts,
self.server.session,
self.server.cached_webfingers,
self.server.person_cache,
self.server.project_version,
self.server.yt_replace_domain,
self.server.twitter_replacement_domain,
self.server.show_published_date_only,
self.server.peertube_instances,
self.server.allow_local_network_access,
self.server.system_language,
self.server.max_like_count,
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
'inbox', self.server.default_timeline,
'shares')
if not msg:
self._404()
return True
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
cookie, calling_domain, False)
self._write(msg)
fitness_performance(getreq_start_time, self.server.fitness,
'_GET', '_show_announcers_of_post',
self.server.debug)
return True
def _show_post_from_file(self, post_filename: str, liked_by: str,
react_by: str, react_emoji: str,
authorized: bool,
@ -16568,6 +16630,22 @@ class PubServer(BaseHTTPRequestHandler):
self.server.getreq_busy = False
return
# show the announcers/repeaters of a post
if self._show_announcers_of_post(authorized,
calling_domain, self.path,
self.server.base_dir,
self.server.http_prefix,
self.server.domain,
self.server.domain_full,
self.server.port,
self.server.onion_domain,
self.server.i2p_domain,
getreq_start_time,
self.server.proxy_type,
cookie, self.server.debug):
self.server.getreq_busy = False
return
fitness_performance(getreq_start_time, self.server.fitness,
'_GET', 'individual post done',
self.server.debug)

View File

@ -513,5 +513,6 @@
"It is done": "تم",
"Time Zone": "وحدة زمنية",
"Show who liked this post": "أظهر من أحب هذا المنشور",
"Show who repeated this post": "أظهر من كرر هذا المنصب"
"Show who repeated this post": "أظهر من كرر هذا المنصب",
"Repeated by": "يتكرر بواسطة"
}

View File

@ -513,5 +513,6 @@
"It is done": "Esta fet",
"Time Zone": "Fus horari",
"Show who liked this post": "Mostra a qui li agrada aquesta publicació",
"Show who repeated this post": "Mostra qui ha repetit aquesta publicació"
"Show who repeated this post": "Mostra qui ha repetit aquesta publicació",
"Repeated by": "Repetit per"
}

View File

@ -513,5 +513,6 @@
"It is done": "Mae'n cael ei wneud",
"Time Zone": "Parth Amser",
"Show who liked this post": "Dangoswch pwy oedd yn hoffi'r post hwn",
"Show who repeated this post": "Dangoswch pwy ailadroddodd y post hwn"
"Show who repeated this post": "Dangoswch pwy ailadroddodd y post hwn",
"Repeated by": "Ailadrodd gan"
}

View File

@ -513,5 +513,6 @@
"It is done": "Es ist vollbracht",
"Time Zone": "Zeitzone",
"Show who liked this post": "Zeigen, wem dieser Beitrag gefallen hat",
"Show who repeated this post": "Zeigen Sie, wer diesen Beitrag wiederholt hat"
"Show who repeated this post": "Zeigen Sie, wer diesen Beitrag wiederholt hat",
"Repeated by": "Wiederholt von"
}

View File

@ -513,5 +513,6 @@
"It is done": "It is done",
"Time Zone": "Time Zone",
"Show who liked this post": "Show who liked this post",
"Show who repeated this post": "Show who repeated this post"
"Show who repeated this post": "Show who repeated this post",
"Repeated by": "Repeated by"
}

View File

@ -513,5 +513,6 @@
"It is done": "Se hace",
"Time Zone": "Zona horaria",
"Show who liked this post": "Mostrar a quién le gustó esta publicación",
"Show who repeated this post": "Mostrar quién repitió esta publicación"
"Show who repeated this post": "Mostrar quién repitió esta publicación",
"Repeated by": "Repetido por"
}

View File

@ -513,5 +513,6 @@
"It is done": "C'est fait",
"Time Zone": "Fuseau horaire",
"Show who liked this post": "Montrer qui a aimé ce post",
"Show who repeated this post": "Montrer qui a répété ce post"
"Show who repeated this post": "Montrer qui a répété ce post",
"Repeated by": "Répété par"
}

View File

@ -513,5 +513,6 @@
"It is done": "Déantar é",
"Time Zone": "Crios Ama",
"Show who liked this post": "Taispeáin cé a thaitin an postáil seo",
"Show who repeated this post": "Taispeáin cé a rinne an postáil seo arís"
"Show who repeated this post": "Taispeáin cé a rinne an postáil seo arís",
"Repeated by": "Arís agus arís eile ag"
}

View File

@ -513,5 +513,6 @@
"It is done": "हो गया है",
"Time Zone": "समय क्षेत्र",
"Show who liked this post": "दिखाएँ कि इस पोस्ट को किसने पसंद किया",
"Show who repeated this post": "दिखाएं कि इस पोस्ट को किसने दोहराया"
"Show who repeated this post": "दिखाएं कि इस पोस्ट को किसने दोहराया",
"Repeated by": "द्वारा दोहराया गया"
}

View File

@ -513,5 +513,6 @@
"It is done": "È fatta",
"Time Zone": "Fuso orario",
"Show who liked this post": "Mostra a chi è piaciuto questo post",
"Show who repeated this post": "Mostra chi ha ripetuto questo post"
"Show who repeated this post": "Mostra chi ha ripetuto questo post",
"Repeated by": "Ripetuto da"
}

View File

@ -513,5 +513,6 @@
"It is done": "されております",
"Time Zone": "タイムゾーン",
"Show who liked this post": "この投稿を高く評価した人を表示する",
"Show who repeated this post": "この投稿を繰り返した人を表示する"
"Show who repeated this post": "この投稿を繰り返した人を表示する",
"Repeated by": "によって繰り返される"
}

View File

@ -513,5 +513,6 @@
"It is done": "Tê kirin",
"Time Zone": "Qada demê",
"Show who liked this post": "Nîşan bide kê ev post eciband",
"Show who repeated this post": "Nîşan bide kê ev post dubare kiriye"
"Show who repeated this post": "Nîşan bide kê ev post dubare kiriye",
"Repeated by": "Ji hêla dubare kirin"
}

View File

@ -509,5 +509,6 @@
"It is done": "It is done",
"Time Zone": "Time Zone",
"Show who liked this post": "Show who liked this post",
"Show who repeated this post": "Show who repeated this post"
"Show who repeated this post": "Show who repeated this post",
"Repeated by": "Repeated by"
}

View File

@ -513,5 +513,6 @@
"It is done": "Está feito",
"Time Zone": "Fuso horário",
"Show who liked this post": "Mostrar quem gostou deste post",
"Show who repeated this post": "Mostrar quem repetiu esta postagem"
"Show who repeated this post": "Mostrar quem repetiu esta postagem",
"Repeated by": "Repetido por"
}

View File

@ -513,5 +513,6 @@
"It is done": "Сделано",
"Time Zone": "Часовой пояс",
"Show who liked this post": "Показать, кому понравился этот пост",
"Show who repeated this post": "Показать, кто повторил этот пост"
"Show who repeated this post": "Показать, кто повторил этот пост",
"Repeated by": "Повторено"
}

View File

@ -513,5 +513,6 @@
"It is done": "Imefanyika",
"Time Zone": "Eneo la Saa",
"Show who liked this post": "Onyesha ni nani aliyependa chapisho hili",
"Show who repeated this post": "Onyesha ni nani aliyerudia chapisho hili"
"Show who repeated this post": "Onyesha ni nani aliyerudia chapisho hili",
"Repeated by": "Imerudiwa na"
}

View File

@ -513,5 +513,6 @@
"It is done": "完成了",
"Time Zone": "时区",
"Show who liked this post": "显示谁喜欢这篇文章",
"Show who repeated this post": "显示谁重复了这篇文章"
"Show who repeated this post": "显示谁重复了这篇文章",
"Repeated by": "重复"
}

View File

@ -40,7 +40,8 @@ def html_likers_of_post(base_dir: str, nickname: str,
system_language: str,
max_like_count: int, signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
boxName: str, default_timeline: str) -> str:
boxName: str, default_timeline: str,
dict_name: str = 'likes') -> str:
"""Returns html for a screen showing who liked a post
"""
css_filename = base_dir + '/epicyon-profile.css'
@ -107,17 +108,22 @@ def html_likers_of_post(base_dir: str, nickname: str,
obj = post_json_object
if has_object_dict(post_json_object):
obj = post_json_object['object']
if not obj.get('likes'):
if not obj.get(dict_name):
return None
if not isinstance(obj['likes'], dict):
if not isinstance(obj[dict_name], dict):
return None
if not obj['likes'].get('items'):
if not obj[dict_name].get('items'):
return None
html_str += '<center><h2>' + translate['Liked by'] + '</h2></center>\n'
if dict_name == 'likes':
html_str += \
'<center><h2>' + translate['Liked by'] + '</h2></center>\n'
else:
html_str += \
'<center><h2>' + translate['Repeated by'] + '</h2></center>\n'
likers_list = ''
for like_item in obj['likes']['items']:
for like_item in obj[dict_name]['items']:
if not like_item.get('actor'):
continue
liker_actor = like_item['actor']