mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
a5b935f9a5
commit
a39f8bcb77
|
|
@ -42,7 +42,6 @@ from textmode import text_mode_removals
|
||||||
from quote import get_quote_toot_url
|
from quote import get_quote_toot_url
|
||||||
from timeFunctions import date_from_string_format
|
from timeFunctions import date_from_string_format
|
||||||
from timeFunctions import convert_published_to_local_timezone
|
from timeFunctions import convert_published_to_local_timezone
|
||||||
from utils import chatbot_nicknames
|
|
||||||
from utils import get_mutuals_of_person
|
from utils import get_mutuals_of_person
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import remove_header_tags
|
from utils import remove_header_tags
|
||||||
|
|
@ -107,6 +106,7 @@ from content import add_auto_cw
|
||||||
from person import is_person_snoozed
|
from person import is_person_snoozed
|
||||||
from person import get_person_avatar_url
|
from person import get_person_avatar_url
|
||||||
from textmode import text_mode_browser
|
from textmode import text_mode_browser
|
||||||
|
from webapp_utils import get_display_name_prefix
|
||||||
from webapp_utils import get_show_map_button
|
from webapp_utils import get_show_map_button
|
||||||
from webapp_utils import mitm_warning_html
|
from webapp_utils import mitm_warning_html
|
||||||
from webapp_utils import get_buy_links
|
from webapp_utils import get_buy_links
|
||||||
|
|
@ -1578,15 +1578,8 @@ def _get_post_title_announce_html(base_dir: str,
|
||||||
mutual_prefix = '⇆ '
|
mutual_prefix = '⇆ '
|
||||||
|
|
||||||
actor_type = get_actor_type(base_dir, attributed_to, person_cache)
|
actor_type = get_actor_type(base_dir, attributed_to, person_cache)
|
||||||
bot_prefix = ''
|
bot_prefix = get_display_name_prefix(actor_type, announce_nickname,
|
||||||
if actor_type:
|
translate)
|
||||||
if actor_type in ('Organization', 'Organisation'):
|
|
||||||
bot_prefix = '<b>[' + translate['Organisation'] + ']</b> '
|
|
||||||
elif actor_type == 'Group':
|
|
||||||
bot_prefix = '<b>[' + translate['Group'] + ']</b> '
|
|
||||||
elif (actor_type != 'Person' or
|
|
||||||
announce_nickname in chatbot_nicknames()):
|
|
||||||
bot_prefix = '<b>[' + translate['Bot'] + ']</b> '
|
|
||||||
|
|
||||||
_log_post_timing(enable_timing_log, post_start_time, '13.3.1')
|
_log_post_timing(enable_timing_log, post_start_time, '13.3.1')
|
||||||
announce_display_name2 = \
|
announce_display_name2 = \
|
||||||
|
|
@ -1735,18 +1728,11 @@ def _get_reply_html(translate: {},
|
||||||
if reply_handle in mutuals_list:
|
if reply_handle in mutuals_list:
|
||||||
mutual_prefix = '⇆ '
|
mutual_prefix = '⇆ '
|
||||||
|
|
||||||
bot_prefix = ''
|
reply_nickname = ''
|
||||||
if actor_type:
|
if '@' in reply_nickname:
|
||||||
reply_nickname = ''
|
reply_nickname = reply_handle.split('@')[0]
|
||||||
if '@' in reply_nickname:
|
bot_prefix = get_display_name_prefix(actor_type, reply_nickname,
|
||||||
reply_nickname = reply_handle.split('@')[0]
|
translate)
|
||||||
if actor_type in ('Organization', 'Organisation'):
|
|
||||||
bot_prefix = '<b>[' + translate['Organisation'] + ']</b> '
|
|
||||||
elif actor_type == 'Group':
|
|
||||||
bot_prefix = '<b>[' + translate['Group'] + ']</b> '
|
|
||||||
elif (actor_type != 'Person' or
|
|
||||||
reply_nickname in chatbot_nicknames()):
|
|
||||||
bot_prefix = '<b>[' + translate['Bot'] + ']</b> '
|
|
||||||
|
|
||||||
replying_to_str = _replying_to_with_scope(post_json_object, translate)
|
replying_to_str = _replying_to_with_scope(post_json_object, translate)
|
||||||
post_bookmark = '#' + bookmark_from_id(in_reply_to)
|
post_bookmark = '#' + bookmark_from_id(in_reply_to)
|
||||||
|
|
@ -2705,15 +2691,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
|
||||||
mutual_prefix = '⇆ '
|
mutual_prefix = '⇆ '
|
||||||
|
|
||||||
actor_type = get_actor_type(base_dir, post_actor, person_cache)
|
actor_type = get_actor_type(base_dir, post_actor, person_cache)
|
||||||
bot_prefix = ''
|
bot_prefix = get_display_name_prefix(actor_type, actor_nickname,
|
||||||
if actor_type:
|
translate)
|
||||||
if actor_type in ('Organization', 'Organisation'):
|
|
||||||
bot_prefix = '<b>[' + translate['Organisation'] + ']</b> '
|
|
||||||
elif actor_type == 'Group':
|
|
||||||
bot_prefix = '<b>[' + translate['Group'] + ']</b> '
|
|
||||||
elif (actor_type != 'Person' or
|
|
||||||
actor_nickname in chatbot_nicknames()):
|
|
||||||
bot_prefix = '<b>[' + translate['Bot'] + ']</b> '
|
|
||||||
|
|
||||||
if display_name:
|
if display_name:
|
||||||
display_name = _enforce_max_display_name_length(display_name)
|
display_name = _enforce_max_display_name_length(display_name)
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ from session import get_json_valid
|
||||||
from flags import is_float
|
from flags import is_float
|
||||||
from flags import is_moderator
|
from flags import is_moderator
|
||||||
from formats import media_file_mime_type
|
from formats import media_file_mime_type
|
||||||
|
from utils import chatbot_nicknames
|
||||||
from utils import replace_strings
|
from utils import replace_strings
|
||||||
from utils import get_image_file
|
from utils import get_image_file
|
||||||
from utils import data_dir
|
from utils import data_dir
|
||||||
|
|
@ -2528,3 +2529,22 @@ def mitm_warning_html(translate: {}) -> str:
|
||||||
mitm_warning_str + '" alt="' + \
|
mitm_warning_str + '" alt="' + \
|
||||||
mitm_warning_str + '" src="/icons' + \
|
mitm_warning_str + '" src="/icons' + \
|
||||||
'/mitm.png" class="mitm"/>\n'
|
'/mitm.png" class="mitm"/>\n'
|
||||||
|
|
||||||
|
|
||||||
|
def get_display_name_prefix(actor_type: str,
|
||||||
|
nickname: str,
|
||||||
|
translate: {}) -> str:
|
||||||
|
"""Returns a prefix prepended to the display name to indicate that
|
||||||
|
an account is a bot, organisation or group
|
||||||
|
"""
|
||||||
|
if not actor_type:
|
||||||
|
return ''
|
||||||
|
display_name_prefix = ''
|
||||||
|
if actor_type in ('Organization', 'Organisation'):
|
||||||
|
display_name_prefix = '<b>[' + translate['Organisation'] + ']</b> '
|
||||||
|
elif actor_type == 'Group':
|
||||||
|
display_name_prefix = '<b>[' + translate['Group'] + ']</b> '
|
||||||
|
elif (actor_type != 'Person' or
|
||||||
|
nickname in chatbot_nicknames()):
|
||||||
|
display_name_prefix = '<b>[' + translate['Bot'] + ']</b> '
|
||||||
|
return display_name_prefix
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue