mirror of https://gitlab.com/bashrc2/epicyon
Add count of announces to posts
parent
101fe83251
commit
b1701db6dd
17
announce.py
17
announce.py
|
@ -9,6 +9,7 @@ __module_group__ = "ActivityPub"
|
|||
|
||||
from utils import has_object_string_object
|
||||
from utils import has_group_type
|
||||
from utils import has_object_dict
|
||||
from utils import remove_domain_port
|
||||
from utils import remove_id_ending
|
||||
from utils import has_users_path
|
||||
|
@ -33,6 +34,22 @@ from webfinger import webfinger_handle
|
|||
from auth import create_basic_auth_header
|
||||
|
||||
|
||||
def no_of_announces(post_json_object: {}) -> int:
|
||||
"""Returns the number of announces on a given post
|
||||
"""
|
||||
obj = post_json_object
|
||||
if has_object_dict(post_json_object):
|
||||
obj = post_json_object['object']
|
||||
if not obj.get('shares'):
|
||||
return 0
|
||||
if not isinstance(obj['shares'], dict):
|
||||
return 0
|
||||
if not obj['shares'].get('items'):
|
||||
obj['shares']['items'] = []
|
||||
obj['shares']['totalItems'] = 0
|
||||
return len(obj['shares']['items'])
|
||||
|
||||
|
||||
def is_self_announce(post_json_object: {}) -> bool:
|
||||
"""Is the given post a self announce?
|
||||
"""
|
||||
|
|
|
@ -512,5 +512,6 @@
|
|||
"Created": "مخلوق",
|
||||
"It is done": "تم",
|
||||
"Time Zone": "وحدة زمنية",
|
||||
"Show who liked this post": "أظهر من أحب هذا المنشور"
|
||||
"Show who liked this post": "أظهر من أحب هذا المنشور",
|
||||
"Show who repeated this post": "أظهر من كرر هذا المنصب"
|
||||
}
|
||||
|
|
|
@ -512,5 +512,6 @@
|
|||
"Created": "Creat",
|
||||
"It is done": "Esta fet",
|
||||
"Time Zone": "Fus horari",
|
||||
"Show who liked this post": "Mostra a qui li agrada aquesta publicació"
|
||||
"Show who liked this post": "Mostra a qui li agrada aquesta publicació",
|
||||
"Show who repeated this post": "Mostra qui ha repetit aquesta publicació"
|
||||
}
|
||||
|
|
|
@ -512,5 +512,6 @@
|
|||
"Created": "Wedi creu",
|
||||
"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 liked this post": "Dangoswch pwy oedd yn hoffi'r post hwn",
|
||||
"Show who repeated this post": "Dangoswch pwy ailadroddodd y post hwn"
|
||||
}
|
||||
|
|
|
@ -512,5 +512,6 @@
|
|||
"Created": "Erstellt",
|
||||
"It is done": "Es ist vollbracht",
|
||||
"Time Zone": "Zeitzone",
|
||||
"Show who liked this post": "Zeigen, wem dieser Beitrag gefallen hat"
|
||||
"Show who liked this post": "Zeigen, wem dieser Beitrag gefallen hat",
|
||||
"Show who repeated this post": "Zeigen Sie, wer diesen Beitrag wiederholt hat"
|
||||
}
|
||||
|
|
|
@ -512,5 +512,6 @@
|
|||
"Created": "Created",
|
||||
"It is done": "It is done",
|
||||
"Time Zone": "Time Zone",
|
||||
"Show who liked this post": "Show who liked this post"
|
||||
"Show who liked this post": "Show who liked this post",
|
||||
"Show who repeated this post": "Show who repeated this post"
|
||||
}
|
||||
|
|
|
@ -512,5 +512,6 @@
|
|||
"Created": "Creada",
|
||||
"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 liked this post": "Mostrar a quién le gustó esta publicación",
|
||||
"Show who repeated this post": "Mostrar quién repitió esta publicación"
|
||||
}
|
||||
|
|
|
@ -512,5 +512,6 @@
|
|||
"Created": "Créé",
|
||||
"It is done": "C'est fait",
|
||||
"Time Zone": "Fuseau horaire",
|
||||
"Show who liked this post": "Montrer qui a aimé ce post"
|
||||
"Show who liked this post": "Montrer qui a aimé ce post",
|
||||
"Show who repeated this post": "Montrer qui a répété ce post"
|
||||
}
|
||||
|
|
|
@ -512,5 +512,6 @@
|
|||
"Created": "Cruthaithe",
|
||||
"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 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"
|
||||
}
|
||||
|
|
|
@ -512,5 +512,6 @@
|
|||
"Created": "बनाया था",
|
||||
"It is done": "हो गया है",
|
||||
"Time Zone": "समय क्षेत्र",
|
||||
"Show who liked this post": "दिखाएँ कि इस पोस्ट को किसने पसंद किया"
|
||||
"Show who liked this post": "दिखाएँ कि इस पोस्ट को किसने पसंद किया",
|
||||
"Show who repeated this post": "दिखाएं कि इस पोस्ट को किसने दोहराया"
|
||||
}
|
||||
|
|
|
@ -512,5 +512,6 @@
|
|||
"Created": "Creata",
|
||||
"It is done": "È fatta",
|
||||
"Time Zone": "Fuso orario",
|
||||
"Show who liked this post": "Mostra a chi è piaciuto questo post"
|
||||
"Show who liked this post": "Mostra a chi è piaciuto questo post",
|
||||
"Show who repeated this post": "Mostra chi ha ripetuto questo post"
|
||||
}
|
||||
|
|
|
@ -512,5 +512,6 @@
|
|||
"Created": "作成した",
|
||||
"It is done": "されております",
|
||||
"Time Zone": "タイムゾーン",
|
||||
"Show who liked this post": "この投稿を高く評価した人を表示する"
|
||||
"Show who liked this post": "この投稿を高く評価した人を表示する",
|
||||
"Show who repeated this post": "この投稿を繰り返した人を表示する"
|
||||
}
|
||||
|
|
|
@ -512,5 +512,6 @@
|
|||
"Created": "Afirandin",
|
||||
"It is done": "Tê kirin",
|
||||
"Time Zone": "Qada demê",
|
||||
"Show who liked this post": "Nîşan bide kê ev post eciband"
|
||||
"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"
|
||||
}
|
||||
|
|
|
@ -508,5 +508,6 @@
|
|||
"Created": "Created",
|
||||
"It is done": "It is done",
|
||||
"Time Zone": "Time Zone",
|
||||
"Show who liked this post": "Show who liked this post"
|
||||
"Show who liked this post": "Show who liked this post",
|
||||
"Show who repeated this post": "Show who repeated this post"
|
||||
}
|
||||
|
|
|
@ -512,5 +512,6 @@
|
|||
"Created": "Criada",
|
||||
"It is done": "Está feito",
|
||||
"Time Zone": "Fuso horário",
|
||||
"Show who liked this post": "Mostrar quem gostou deste post"
|
||||
"Show who liked this post": "Mostrar quem gostou deste post",
|
||||
"Show who repeated this post": "Mostrar quem repetiu esta postagem"
|
||||
}
|
||||
|
|
|
@ -512,5 +512,6 @@
|
|||
"Created": "Созданный",
|
||||
"It is done": "Сделано",
|
||||
"Time Zone": "Часовой пояс",
|
||||
"Show who liked this post": "Показать, кому понравился этот пост"
|
||||
"Show who liked this post": "Показать, кому понравился этот пост",
|
||||
"Show who repeated this post": "Показать, кто повторил этот пост"
|
||||
}
|
||||
|
|
|
@ -512,5 +512,6 @@
|
|||
"Created": "Imeundwa",
|
||||
"It is done": "Imefanyika",
|
||||
"Time Zone": "Eneo la Saa",
|
||||
"Show who liked this post": "Onyesha ni nani aliyependa chapisho hili"
|
||||
"Show who liked this post": "Onyesha ni nani aliyependa chapisho hili",
|
||||
"Show who repeated this post": "Onyesha ni nani aliyerudia chapisho hili"
|
||||
}
|
||||
|
|
|
@ -512,5 +512,6 @@
|
|||
"Created": "已创建",
|
||||
"It is done": "完成了",
|
||||
"Time Zone": "时区",
|
||||
"Show who liked this post": "显示谁喜欢这篇文章"
|
||||
"Show who liked this post": "显示谁喜欢这篇文章",
|
||||
"Show who repeated this post": "显示谁重复了这篇文章"
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ from git import is_git_patch
|
|||
from datetime import datetime
|
||||
from cache import get_person_from_cache
|
||||
from bookmarks import bookmarked_by_person
|
||||
from announce import announced_by_person
|
||||
from announce import no_of_announces
|
||||
from like import liked_by_person
|
||||
from like import no_of_likes
|
||||
from follow import is_following_actor
|
||||
|
@ -65,7 +67,6 @@ from content import get_mentions_from_html
|
|||
from content import switch_words
|
||||
from person import is_person_snoozed
|
||||
from person import get_person_avatar_url
|
||||
from announce import announced_by_person
|
||||
from webapp_utils import get_banner_file
|
||||
from webapp_utils import get_avatar_image_url
|
||||
from webapp_utils import update_avatar_image_cache
|
||||
|
@ -549,7 +550,8 @@ def _get_announce_icon_html(is_announced: bool,
|
|||
translate: {},
|
||||
page_number_param: str,
|
||||
timeline_post_bookmark: str,
|
||||
box_name: str) -> str:
|
||||
box_name: str,
|
||||
max_announce_count: int) -> str:
|
||||
"""Returns html for announce icon/button
|
||||
"""
|
||||
announce_str = ''
|
||||
|
@ -571,9 +573,19 @@ def _get_announce_icon_html(is_announced: bool,
|
|||
repeat_this_post_str = translate[repeat_this_post_str]
|
||||
announce_title = repeat_this_post_str
|
||||
unannounce_link_str = ''
|
||||
announce_count = no_of_announces(post_json_object)
|
||||
|
||||
announce_count_str = ''
|
||||
if announce_count > 0:
|
||||
if announce_count <= max_announce_count:
|
||||
announce_count_str = ' (' + str(announce_count) + ')'
|
||||
else:
|
||||
announce_count_str = ' (' + str(max_announce_count) + '+)'
|
||||
if announced_by_person(is_announced,
|
||||
post_actor, nickname, domain_full):
|
||||
if announce_count == 1:
|
||||
# announced by the reader only
|
||||
announce_count_str = ''
|
||||
announce_icon = 'repeat.png'
|
||||
announce_emoji = '🔁 '
|
||||
announce_link = 'unrepeat'
|
||||
|
@ -590,9 +602,24 @@ def _get_announce_icon_html(is_announced: bool,
|
|||
announce_post_id = \
|
||||
remove_hash_from_post_id(post_json_object['object']['id'])
|
||||
announce_post_id = remove_id_ending(announce_post_id)
|
||||
|
||||
announce_str = ''
|
||||
if announce_count_str:
|
||||
announcers_post_id = announce_post_id.replace('/', '--')
|
||||
announcers_screen_link = \
|
||||
'/users/' + nickname + '?announcers=' + announcers_post_id
|
||||
|
||||
# show the number of announces next to icon
|
||||
announce_str += '<label class="likesCount">'
|
||||
announce_str += '<a href="' + announcers_screen_link + '" ' + \
|
||||
'title="' + translate['Show who repeated this post'] + '">'
|
||||
announce_str += \
|
||||
announce_count_str.replace('(', '').replace(')', '').strip()
|
||||
announce_str += '</a></label>\n'
|
||||
|
||||
announce_link_str = '?' + \
|
||||
announce_link + '=' + announce_post_id + page_number_param
|
||||
announce_str = \
|
||||
announce_str += \
|
||||
' <a class="imageAnchor" href="/users/' + \
|
||||
nickname + announce_link_str + unannounce_link_str + \
|
||||
'?actor=' + post_json_object['actor'] + \
|
||||
|
@ -1700,7 +1727,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
|
|||
translate,
|
||||
page_number_param,
|
||||
timeline_post_bookmark,
|
||||
box_name)
|
||||
box_name, max_like_count)
|
||||
|
||||
_log_post_timing(enable_timing_log, post_start_time, '12')
|
||||
|
||||
|
|
Loading…
Reference in New Issue