merge-requests/30/head
Bob Mottram 2023-02-07 17:49:51 +00:00
commit 18598297a2
3 changed files with 40 additions and 17 deletions

View File

@ -2693,7 +2693,7 @@ def _receive_announce(recent_posts_cache: {},
announced_actor_nickname + '@' + announced_actor_domain)
return False
# is this post in the outbox of the person?
# is this post in the inbox or outbox of the account?
post_filename = locate_post(base_dir, nickname, domain,
message_json['object'])
if not post_filename:
@ -2701,6 +2701,7 @@ def _receive_announce(recent_posts_cache: {},
print('DEBUG: announce post not found in inbox or outbox')
print(message_json['object'])
return True
# add actor to the list of announcers for a post
update_announce_collection(recent_posts_cache, base_dir, post_filename,
message_json['actor'], nickname, domain, debug)
if debug:

View File

@ -362,7 +362,7 @@ def _save_individual_post_as_html_to_cache(base_dir: str,
with open(cached_post_filename, 'w+', encoding='utf-8') as fp_cache:
fp_cache.write(post_html)
return True
except Exception as ex:
except OSError as ex:
print('ERROR: saving post to cache, ' + str(ex))
return False
@ -916,7 +916,9 @@ def _get_like_icon_html(nickname: str, domain_full: str,
return like_str
def _get_bookmark_icon_html(nickname: str, domain_full: str,
def _get_bookmark_icon_html(base_dir: str,
nickname: str, domain: str,
domain_full: str,
post_json_object: {},
is_moderation_post: bool,
translate: {},
@ -924,7 +926,8 @@ def _get_bookmark_icon_html(nickname: str, domain_full: str,
post_start_time, box_name: str,
page_number_param: str,
timeline_post_bookmark: str,
first_post_id: str) -> str:
first_post_id: str,
post_url: str) -> str:
"""Returns html for bookmark icon/button
"""
bookmark_str = ''
@ -932,6 +935,9 @@ def _get_bookmark_icon_html(nickname: str, domain_full: str,
if is_moderation_post:
return bookmark_str
if not locate_post(base_dir, nickname, domain, post_url):
return bookmark_str
bookmark_icon = 'bookmark_inactive.png'
bookmark_link = 'bookmark'
bookmark_emoji = ''
@ -2133,9 +2139,13 @@ def individual_post_as_html(signing_priv_key_pem: str,
translate, post_json_object['actor'],
theme_name, system_language,
box_name)
try:
with open(announce_filename + '.tts', 'w+',
encoding='utf-8') as ttsfile:
ttsfile.write('\n')
except OSError:
print('EX: unable to write tts ' +
announce_filename + '.tts')
is_announced = True
@ -2295,15 +2305,14 @@ def individual_post_as_html(signing_priv_key_pem: str,
_log_post_timing(enable_timing_log, post_start_time, '12.5')
bookmark_str = \
_get_bookmark_icon_html(nickname, domain_full,
post_json_object,
is_moderation_post,
translate,
_get_bookmark_icon_html(base_dir, nickname, domain,
domain_full, post_json_object,
is_moderation_post, translate,
enable_timing_log,
post_start_time, box_name,
page_number_param,
timeline_post_bookmark,
first_post_id)
first_post_id, message_id)
_log_post_timing(enable_timing_log, post_start_time, '12.9')
@ -2652,8 +2661,10 @@ def individual_post_as_html(signing_priv_key_pem: str,
translate)
if map_str:
map_str = '<center>\n' + map_str + '</center>\n'
if map_str and post_json_object['object'].get('attributedTo'):
attrib = None
if post_json_object['object'].get('attributedTo'):
attrib = post_json_object['object']['attributedTo']
if map_str and attrib:
# is this being sent by the author?
if '://' + domain_full + '/users/' + nickname in attrib:
location_domain = location_str

View File

@ -226,6 +226,11 @@ def html_profile_after_search(recent_posts_cache: {}, max_recent_posts: int,
display_name = search_nickname
if profile_json.get('name'):
display_name = profile_json['name']
display_name = remove_html(display_name)
display_name = \
add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain,
display_name, False, translate)
locked_account = get_locked_account(profile_json)
if locked_account:
@ -246,6 +251,10 @@ def html_profile_after_search(recent_posts_cache: {}, max_recent_posts: int,
profile_description = ''
if profile_json.get('summary'):
profile_description = profile_json['summary']
profile_description = \
add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain,
profile_description, False, translate)
outbox_url = None
if not profile_json.get('outbox'):
if debug:
@ -468,7 +477,7 @@ def _get_profile_header(base_dir: str, http_prefix: str, nickname: str,
' <b>' + occupation_name + '</b><br>\n'
html_str += \
' <h1>' + remove_html(display_name) + '\n</h1>\n' + \
' <h1>' + display_name + '\n</h1>\n' + \
occupation_str
html_str += \
@ -577,7 +586,7 @@ def _get_profile_header_after_search(nickname: str, default_timeline: str,
display_name = search_nickname
html_str += \
' <h1>\n' + \
' ' + remove_html(display_name) + '\n' + \
' ' + display_name + '\n' + \
' </h1>\n' + \
' <p><b>@' + search_nickname + '@' + search_domain_full + \
'</b><br>\n'
@ -692,15 +701,17 @@ def html_profile(signing_priv_key_pem: str,
domain, port = get_domain_from_actor(profile_json['id'])
if not domain:
return ""
display_name = remove_html(profile_json['name'])
display_name = \
add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain,
profile_json['name'], True, translate)
display_name, True, translate)
domain_full = get_full_domain(domain, port)
profile_description = profile_json['summary']
profile_description = \
add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain,
profile_json['summary'], False, translate)
profile_description, False, translate)
if profile_description:
profile_description = standardize_text(profile_description)
posts_button = 'button'