diff --git a/bookmarks.py b/bookmarks.py index b387464c8..beec5fa56 100644 --- a/bookmarks.py +++ b/bookmarks.py @@ -697,3 +697,11 @@ def outbox_undo_bookmark(recent_posts_cache: {}, actor_url, domain, debug) if debug: print('DEBUG: post unbookmarked via c2s - ' + post_filename) + + +def bookmark_from_id(post_id: str) -> str: + """ Converts a post id into a bookmark + """ + timeline_post_bookmark = remove_id_ending(post_id) + timeline_post_bookmark = timeline_post_bookmark.replace('://', '-') + return timeline_post_bookmark.replace('/', '-') diff --git a/webapp_post.py b/webapp_post.py index b4ff0f9b1..4ce7c68eb 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -14,6 +14,7 @@ from dateutil.parser import parse from auth import create_password from git import is_git_patch from cache import get_person_from_cache +from bookmarks import bookmark_from_id from bookmarks import bookmarked_by_person from announce import announced_by_person from announce import no_of_announces @@ -132,14 +133,6 @@ from session import get_json MAX_DISPLAY_NAME_LENGTH = 42 -def _bookmark_from_id(post_id: str) -> str: - """ Converts a post id into a bookmark - """ - timeline_post_bookmark = remove_id_ending(post_id) - timeline_post_bookmark = timeline_post_bookmark.replace('://', '-') - return timeline_post_bookmark.replace('/', '-') - - def _enforce_max_display_name_length(display_name: str) -> str: """Ensures that the display name does not get too long """ @@ -1351,7 +1344,7 @@ def _announce_unattributed_html(translate: {}, if translate.get(announces_str): announces_str = translate[announces_str] post_id = remove_id_ending(post_json_object['object']['id']) - post_bookmark = '#' + _bookmark_from_id(post_id) + post_bookmark = '#' + bookmark_from_id(post_id) post_link = '/users/' + nickname + '?convthread=' + \ post_id.replace('--', '/') + post_bookmark return ' ' + avatar_link + '\n' - timeline_post_bookmark = _bookmark_from_id(post_json_object['id']) + timeline_post_bookmark = bookmark_from_id(post_json_object['id']) # If this is the inbox timeline then don't show the repeat icon on any DMs show_repeat_icon = show_repeats @@ -2725,7 +2718,7 @@ def individual_post_as_html(signing_priv_key_pem: str, if content_license_url and not is_reminder(post_json_object): footer_str += _get_copyright_footer(content_license_url, translate) - post_bookmark = '#' + _bookmark_from_id(published_link) + post_bookmark = '#' + bookmark_from_id(published_link) conv_link = '/users/' + nickname + '?convthread=' + \ published_link.replace('--', '/') + post_bookmark footer_str += '