diff --git a/webapp_profile.py b/webapp_profile.py index 7a187a6ab..8638b46a5 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -146,7 +146,7 @@ BLOCKFILE_FORMATS = '.csv' def _import_export_blocks(translate: {}) -> str: """ import and export blocks on edit profile screen """ - edit_profile_form = \ + edit_profile_form: str = \ ' \n' edit_profile_form += ' str: def _get_profile_short_description(profile_description: str) -> str: """Returns a short version of the profile description """ - profile_description_short = profile_description + profile_description_short: str = profile_description if '\n' in profile_description: if len(profile_description.split('\n')) > 6: profile_description_short: str = '' @@ -206,7 +206,7 @@ def _valid_profile_preview_post(post_json_object: {}, cc_list: list[str] = [] if post_json_object.get('cc'): cc_list = post_json_object['cc'] - new_post_json_object = { + new_post_json_object: dict = { 'object': post_json_object, 'to': post_json_object['to'], 'cc': cc_list, @@ -225,14 +225,14 @@ def _valid_profile_preview_post(post_json_object: {}, if has_object_dict(post_json_object): # convert attributedTo actor back to id if post_json_object['object'].get('attributedTo'): - attrib_field = post_json_object['object']['attributedTo'] + attrib_field: str = post_json_object['object']['attributedTo'] if attrib_field: if isinstance(attrib_field, dict): - attrib = get_attributed_to(attrib_field) + attrib: str = get_attributed_to(attrib_field) if attrib: post_json_object['object']['attributedTo'] = attrib if not is_announced_feed_item: - actor_url = get_actor_from_post(post_json_object) + actor_url: str = get_actor_from_post(post_json_object) if actor_url != person_url and \ post_json_object['object']['type'] != 'Page': return False, None @@ -289,7 +289,7 @@ def html_profile_after_search(authorized: bool, ipfs = True elif http_prefix == 'ipns': ipns = True - from_domain = domain + from_domain: str = domain if onion_domain: if '.onion/' in profile_handle or profile_handle.endswith('.onion'): from_domain = onion_domain @@ -320,21 +320,21 @@ def html_profile_after_search(authorized: bool, if not profile_json.get('id'): return None - person_url = profile_json['id'] - person_url2 = person_url + person_url: str = profile_json['id'] + person_url2: str = person_url if profile_json.get('url'): if isinstance(profile_json['url'], str): person_url2 = remove_html(profile_json['url']) search_domain, search_port = get_domain_from_actor(person_url) if not search_domain: return None - search_nickname = get_nickname_from_actor(person_url) + search_nickname: str = get_nickname_from_actor(person_url) if not search_nickname: return None - search_domain_full = get_full_domain(search_domain, search_port) + search_domain_full: str = get_full_domain(search_domain, search_port) profile_str: str = '' - css_filename = base_dir + '/epicyon-profile.css' + css_filename: str = base_dir + '/epicyon-profile.css' if is_a_file(base_dir + '/epicyon.css'): css_filename = base_dir + '/epicyon.css' @@ -345,17 +345,17 @@ def html_profile_after_search(authorized: bool, # shared items attached to the actor # https://codeberg.org/fediverse/fep/src/branch/main/fep/0837/fep-0837.md - attached_shared_items = \ + attached_shared_items: str = \ actor_attached_shares_as_html(profile_json, max_shares_on_profile) avatar_url: str = '' if profile_json.get('icon'): - url_str = get_person_icon(profile_json) + url_str: str = get_person_icon(profile_json) if url_str: avatar_url = remove_html(url_str) if not avatar_url: avatar_url = get_person_avatar_url(base_dir, person_url, person_cache) - display_name = search_nickname + display_name: str = search_nickname if profile_json.get('name'): display_name = profile_json['name'] display_name = remove_html(display_name) @@ -365,29 +365,29 @@ def html_profile_after_search(authorized: bool, nickname, domain, display_name, False, translate) - locked_account = get_locked_account(profile_json) + locked_account: bool = get_locked_account(profile_json) if locked_account: display_name += '🔒' # is this a bot account? if profile_json.get('type'): if isinstance(profile_json['type'], str): - bot_prefix = get_display_name_prefix(profile_json['type'], - search_nickname, - translate) + bot_prefix: str = \ + get_display_name_prefix(profile_json['type'], search_nickname, + translate) if bot_prefix: display_name = bot_prefix + ' ' + display_name - pronouns = get_pronouns(profile_json) - discord = get_discord(profile_json) - art_site_url = get_art_site_url(profile_json) - music_site_url = get_music_site_url(profile_json) - youtube = get_youtube(profile_json) - peertube = get_peertube(profile_json) - pixelfed = get_pixelfed(profile_json) - donate_url = get_donation_url(profile_json) - blog_url = get_blog_address(profile_json) - lxmf_address = get_lxmf_address(profile_json) + pronouns: str = get_pronouns(profile_json) + discord: str = get_discord(profile_json) + art_site_url: str = get_art_site_url(profile_json) + music_site_url: str = get_music_site_url(profile_json) + youtube: str = get_youtube(profile_json) + peertube: str = get_peertube(profile_json) + pixelfed: str = get_pixelfed(profile_json) + donate_url: str = get_donation_url(profile_json) + blog_url: str = get_blog_address(profile_json) + lxmf_address: str = get_lxmf_address(profile_json) moved_to: str = '' if profile_json.get('movedTo') or profile_json.get('copiedTo'): @@ -402,17 +402,17 @@ def html_profile_after_search(authorized: bool, moved_to = moved_to.split('"')[1] display_name += ' ⌂' - you_follow = \ + you_follow: str = \ is_following_actor(base_dir, nickname, domain, person_url) - follows_you = \ + follows_you: str = \ is_follower_of_person(base_dir, nickname, domain, search_nickname, search_domain_full) - profile_status = get_actor_status(profile_json) + profile_status: str = get_actor_status(profile_json) if profile_status: if actor_status_expired(profile_json['sm:status']): profile_status: str = '' @@ -436,9 +436,9 @@ def html_profile_after_search(authorized: bool, add_emoji_to_display_name(session, base_dir, http_prefix, nickname, domain, profile_description, False, translate) - featured_hashtags = \ + featured_hashtags: str = \ get_featured_hashtags_as_html(profile_json, profile_description) - outbox_url = None + outbox_url: str = None if not profile_json.get('outbox'): if debug: pprint(profile_json) @@ -453,11 +453,11 @@ def html_profile_after_search(authorized: bool, # profileBackgroundImage = remove_html(url_str) # url to return to - back_url = path + back_url: str = path if not back_url.endswith('/inbox'): back_url += '/inbox' - profile_description_short = \ + profile_description_short: str = \ _get_profile_short_description(profile_description) # remove formatting from profile description used on title avatar_description: str = '' @@ -473,26 +473,26 @@ def html_profile_after_search(authorized: bool, image_url: str = '' if profile_json.get('image'): if profile_json['image'].get('url'): - url_str = get_url_from_post(profile_json['image']['url']) + url_str: str = get_url_from_post(profile_json['image']['url']) image_url = remove_html(url_str) - also_known_as = None + also_known_as: str = None if profile_json.get('alsoKnownAs'): also_known_as = remove_html(profile_json['alsoKnownAs']) elif profile_json.get('sameAs'): also_known_as = remove_html(profile_json['sameAs']) - joined_date = None + joined_date: str = None if profile_json.get('published'): if 'T' in profile_json['published']: joined_date = remove_html(profile_json['published']) - available = get_availability(base_dir, nickname, domain, profile_json) + available: str = get_availability(base_dir, nickname, domain, profile_json) - actor_proxied = ap_proxy_type(profile_json) + actor_proxied: str = ap_proxy_type(profile_json) - website_url = get_website(profile_json, translate) - repo_url = get_repo_url(profile_json) + website_url: str = get_website(profile_json, translate) + repo_url: str = get_repo_url(profile_json) # is sending posts to this account blocked? send_blocks_str: str = '' @@ -511,7 +511,7 @@ def html_profile_after_search(authorized: bool, if profile_json.get('vcard:bday'): birth_date = profile_json['vcard:bday'] - profile_str = \ + profile_str: str = \ _get_profile_header_after_search(base_dir, nickname, domain, default_timeline, search_nickname, @@ -539,7 +539,7 @@ def html_profile_after_search(authorized: bool, art_site_url, donate_url) - domain_full = get_full_domain(domain, port) + domain_full: str = get_full_domain(domain, port) follow_is_permitted: bool = True if not profile_json.get('followers'): @@ -552,12 +552,12 @@ def html_profile_after_search(authorized: bool, # don't follow yourself! follow_is_permitted = False - blocked = \ + blocked: bool = \ is_blocked(base_dir, nickname, domain, search_nickname, search_domain, None, None) if follow_is_permitted: - follow_str = 'Follow' + follow_str: str = 'Follow' if is_group: follow_str = 'Join' @@ -615,9 +615,9 @@ def html_profile_after_search(authorized: bool, ' \n' + \ '\n' - text_mode_separator = '
' + translate['Other accounts'] + ': ' - actor = local_actor_url(http_prefix, nickname, domain_full) + actor: str = local_actor_url(http_prefix, nickname, domain_full) ctr: int = 0 if isinstance(also_known_as, list): for alt_actor in also_known_as: @@ -870,7 +871,7 @@ def _get_profile_header(base_dir: str, http_prefix: str, nickname: str, if ctr > 0: html_str += other_accounts_html if is_valid_date(birth_date): - birth_date = remove_html(birth_date) + birth_date: str = remove_html(birth_date) html_str += \ '
' + translate['Birthday'] + ': ' + \ birth_date + '
\n' @@ -885,7 +886,7 @@ def _get_profile_header(base_dir: str, http_prefix: str, nickname: str, if profile_status: # https://codeberg.org/fediverse/fep/src/branch/main/ # fep/82f6/fep-82f6.md - status_str = 'Status' + status_str: str = 'Status' if translate.get('Status'): status_str = translate['Status'] html_str += \ @@ -962,7 +963,7 @@ def _get_profile_header_after_search(base_dir: str, """ if not image_url: image_url = '/defaultprofilebackground' - html_str = \ + html_str: str = \ '\n\n' + joined_str + ' ' + \ @@ -1027,15 +1028,15 @@ def _get_profile_header_after_search(base_dir: str, if send_blocks_str: html_str += '
' + send_blocks_str + '
\n' if moved_to: - new_nickname = get_nickname_from_actor(moved_to) + new_nickname: str = get_nickname_from_actor(moved_to) new_domain, new_port = get_domain_from_actor(moved_to) if new_nickname and new_domain: - new_domain_full = get_full_domain(new_domain, new_port) - new_handle = new_nickname + '@' + new_domain_full + new_domain_full: str = get_full_domain(new_domain, new_port) + new_handle: str = new_nickname + '@' + new_domain_full html_str += '' + translate['New account'] + \ ': @' + new_handle + '
\n' elif also_known_as: - other_accounts_html = \ + other_accounts_html: str = \ '' + translate['Other accounts'] + ': ' ctr: int = 0 @@ -1064,7 +1065,7 @@ def _get_profile_header_after_search(base_dir: str, if ctr > 0: html_str += other_accounts_html if is_valid_date(birth_date): - birth_date = remove_html(birth_date) + birth_date: str = remove_html(birth_date) html_str += \ '
' + translate['Birthday'] + ': ' + \ birth_date + '
\n' @@ -1074,7 +1075,7 @@ def _get_profile_header_after_search(base_dir: str, html_str += ' \n' if blog_url: - blog_str = 'Blog' + blog_str: str = 'Blog' if translate.get('Blog'): blog_str = translate['Blog'] html_str += '' + blog_str + ': ' + \
@@ -1095,7 +1096,7 @@ def _get_profile_header_after_search(base_dir: str,
html_str += ' Discord: ' + \
discord + ' ' + donate_str + ': ' + \
repo_url + ' ' + \
translate['Notes'].upper() + ': ' + \
person_notes_html + '
')
+ person_notes_html: str = person_notes.replace('\n', '
')
html_str += '
\n'
- logout_str = \
+ logout_str: str = \
'' + \
'
\n'
# are there any follow requests?
- follow_requests_filename = \
+ follow_requests_filename: str = \
acct_dir(base_dir, nickname, domain) + '/followrequests.txt'
if is_a_file(follow_requests_filename):
follow_requests_list: list[str] = \
@@ -1515,7 +1516,7 @@ def html_profile(signing_priv_key_pem: str,
break
if selected == 'followers':
if follow_approvals:
- curr_follower_domains = \
+ curr_follower_domains: str = \
get_follower_domains(base_dir, nickname, domain)
follow_requests_list: list[str] = \
load_list(follow_requests_filename,
@@ -1525,13 +1526,13 @@ def html_profile(signing_priv_key_pem: str,
for follower_handle in follow_requests_list:
if not follower_handle:
continue
- follower_handle = remove_eol(follower_handle)
+ follower_handle: str = remove_eol(follower_handle)
if '://' in follower_handle:
- follower_actor = follower_handle
+ follower_actor: str = follower_handle
else:
- nick = follower_handle.split('@')[0]
- dom = follower_handle.split('@')[1]
- follower_actor = \
+ nick: str = follower_handle.split('@')[0]
+ dom: str = follower_handle.split('@')[1]
+ follower_actor: str = \
local_actor_url(http_prefix, nick, dom)
# is this a new domain?
@@ -1544,7 +1545,7 @@ def html_profile(signing_priv_key_pem: str,
# Show the handle of the potential follower
# being approved, linking to search on that handle
- base_path = '/users/' + nickname
+ base_path: str = '/users/' + nickname
follow_approvals_section += \
'