Snake case

main
Bob Mottram 2021-12-31 23:07:23 +00:00
parent 2099cad0ac
commit 0a3d10b2ca
8 changed files with 986 additions and 978 deletions

1562
daemon.py

File diff suppressed because it is too large Load Diff

View File

@ -674,7 +674,7 @@ def _read_local_box_post(session, nickname: str, domain: str,
translate: {}, yourActor: str,
domain_full: str, person_cache: {},
signing_priv_key_pem: str,
blockedCache: {}) -> {}:
blocked_cache: {}) -> {}:
"""Reads a post from the given timeline
Returns the post json
"""
@ -715,7 +715,7 @@ def _read_local_box_post(session, nickname: str, domain: str,
system_language,
domain_full, person_cache,
signing_priv_key_pem,
blockedCache)
blocked_cache)
if post_json_object2:
if has_object_dict(post_json_object2):
if post_json_object2['object'].get('attributedTo') and \
@ -1339,7 +1339,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
blockedCache = {}
blocked_cache = {}
indent = ' '
if showNewPosts:
@ -1653,7 +1653,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
espeak, translate, yourActor,
domain_full, person_cache,
signing_priv_key_pem,
blockedCache)
blocked_cache)
print('')
sayStr = 'Press Enter to continue...'
sayStr2 = _highlight_text(sayStr)
@ -2439,7 +2439,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
system_language,
domain_full, person_cache,
signing_priv_key_pem,
blockedCache)
blocked_cache)
if post_json_object2:
post_json_object = post_json_object2
if post_json_object:

View File

@ -457,7 +457,7 @@ def save_post_to_inbox_queue(base_dir: str, http_prefix: str,
messageBytes: str,
httpHeaders: {},
postPath: str, debug: bool,
blockedCache: [], system_language: str) -> str:
blocked_cache: [], system_language: str) -> str:
"""Saves the given json to the inbox queue for the person
keyId specifies the actor sending the post
"""
@ -488,7 +488,7 @@ def save_post_to_inbox_queue(base_dir: str, http_prefix: str,
print('No post Domain in actor')
return None
if is_blocked(base_dir, nickname, domain,
postNickname, postDomain, blockedCache):
postNickname, postDomain, blocked_cache):
if debug:
print('DEBUG: post from ' + postNickname + ' blocked')
return None
@ -501,7 +501,7 @@ def save_post_to_inbox_queue(base_dir: str, http_prefix: str,
post_json_object['object']['inReplyTo']
replyDomain, replyPort = \
get_domain_from_actor(inReplyTo)
if is_blocked_domain(base_dir, replyDomain, blockedCache):
if is_blocked_domain(base_dir, replyDomain, blocked_cache):
if debug:
print('WARN: post contains reply from ' +
str(actor) +
@ -513,7 +513,7 @@ def save_post_to_inbox_queue(base_dir: str, http_prefix: str,
if replyNickname and replyDomain:
if is_blocked(base_dir, nickname, domain,
replyNickname, replyDomain,
blockedCache):
blocked_cache):
if debug:
print('WARN: post contains reply from ' +
str(actor) +
@ -1864,7 +1864,7 @@ def _receive_announce(recent_posts_cache: {},
message_json['type'])
return False
blockedCache = {}
blocked_cache = {}
prefixes = get_protocol_prefixes()
# is the domain of the announce actor blocked?
objectDomain = message_json['object']
@ -1961,7 +1961,7 @@ def _receive_announce(recent_posts_cache: {},
system_language,
domain_full, person_cache,
signing_priv_key_pem,
blockedCache)
blocked_cache)
if not post_json_object:
print('WARN: unable to download announce: ' + str(message_json))
notInOnion = True

View File

@ -178,7 +178,7 @@ def _person_receive_update_outbox(recent_posts_cache: {},
def post_message_to_outbox(session, translate: {},
message_json: {}, postToNickname: str,
message_json: {}, post_to_nickname: str,
server, base_dir: str, http_prefix: str,
domain: str, domain_full: str,
onion_domain: str, i2p_domain: str, port: int,
@ -216,7 +216,7 @@ def post_message_to_outbox(session, translate: {},
print('DEBUG: POST to outbox - adding Create wrapper')
message_json = \
outbox_message_create_wrap(http_prefix,
postToNickname,
post_to_nickname,
domain, port,
message_json)
@ -320,7 +320,7 @@ def post_message_to_outbox(session, translate: {},
mediaDir = \
base_dir + '/accounts/' + \
postToNickname + '@' + domain
post_to_nickname + '@' + domain
uploadMediaFilename = mediaDir + '/upload.' + fileExtension
if not os.path.isfile(uploadMediaFilename):
del message_json['object']['attachment']
@ -374,16 +374,16 @@ def post_message_to_outbox(session, translate: {},
save_post_to_box(base_dir,
http_prefix,
post_id,
postToNickname, domain_full,
post_to_nickname, domain_full,
message_json, outboxName)
if not savedFilename:
print('WARN: post not saved to outbox ' + outboxName)
return False
# save all instance blogs to the news actor
if postToNickname != 'news' and outboxName == 'tlblogs':
if post_to_nickname != 'news' and outboxName == 'tlblogs':
if '/' in savedFilename:
if is_featured_writer(base_dir, postToNickname, domain):
if is_featured_writer(base_dir, post_to_nickname, domain):
savedPostId = savedFilename.split('/')[-1]
blogsDir = \
base_dir + '/accounts/news@' + domain + '/tlblogs'
@ -397,7 +397,7 @@ def post_message_to_outbox(session, translate: {},
# clear the citations file if it exists
citationsFilename = \
base_dir + '/accounts/' + \
postToNickname + '@' + domain + '/.citations.txt'
post_to_nickname + '@' + domain + '/.citations.txt'
if os.path.isfile(citationsFilename):
try:
os.remove(citationsFilename)
@ -413,7 +413,7 @@ def post_message_to_outbox(session, translate: {},
if message_json['type'] in indexedActivities:
indexes = [outboxName, "inbox"]
selfActor = \
local_actor_url(http_prefix, postToNickname, domain_full)
local_actor_url(http_prefix, post_to_nickname, domain_full)
for boxNameIndex in indexes:
if not boxNameIndex:
continue
@ -421,7 +421,7 @@ def post_message_to_outbox(session, translate: {},
# should this also go to the media timeline?
if boxNameIndex == 'inbox':
if is_image_media(session, base_dir, http_prefix,
postToNickname, domain,
post_to_nickname, domain,
message_json,
translate,
yt_replace_domain,
@ -432,7 +432,7 @@ def post_message_to_outbox(session, translate: {},
domain_full, person_cache,
signing_priv_key_pem):
inbox_update_index('tlmedia', base_dir,
postToNickname + '@' + domain,
post_to_nickname + '@' + domain,
savedFilename, debug)
if boxNameIndex == 'inbox' and outboxName == 'tlblogs':
@ -444,7 +444,7 @@ def post_message_to_outbox(session, translate: {},
# show sent post within the inbox,
# as is the typical convention
inbox_update_index(boxNameIndex, base_dir,
postToNickname + '@' + domain,
post_to_nickname + '@' + domain,
savedFilename, debug)
# regenerate the html
@ -453,7 +453,7 @@ def post_message_to_outbox(session, translate: {},
showIndividualPostIcons = True
manuallyApproveFollowers = \
follower_approval_active(base_dir,
postToNickname, domain)
post_to_nickname, domain)
individual_post_as_html(signing_priv_key_pem,
False, recent_posts_cache,
max_recent_posts,
@ -461,7 +461,7 @@ def post_message_to_outbox(session, translate: {},
base_dir, session,
cached_webfingers,
person_cache,
postToNickname, domain, port,
post_to_nickname, domain, port,
message_json, None, True,
allow_deletion,
http_prefix, __version__,
@ -513,7 +513,7 @@ def post_message_to_outbox(session, translate: {},
followersThread = \
send_to_followers_thread(server.session,
base_dir,
postToNickname,
post_to_nickname,
domain, onion_domain, i2p_domain,
port, http_prefix,
federation_list,
@ -534,62 +534,62 @@ def post_message_to_outbox(session, translate: {},
if debug:
print('DEBUG: handle skills changes requests')
outbox_skills(base_dir, postToNickname, message_json, debug)
outbox_skills(base_dir, post_to_nickname, message_json, debug)
if debug:
print('DEBUG: handle availability changes requests')
outbox_availability(base_dir, postToNickname, message_json, debug)
outbox_availability(base_dir, post_to_nickname, message_json, debug)
if debug:
print('DEBUG: handle any like requests')
outbox_like(recent_posts_cache,
base_dir, http_prefix,
postToNickname, domain, port,
post_to_nickname, domain, port,
message_json, debug)
if debug:
print('DEBUG: handle any undo like requests')
outbox_undo_like(recent_posts_cache,
base_dir, http_prefix,
postToNickname, domain, port,
post_to_nickname, domain, port,
message_json, debug)
if debug:
print('DEBUG: handle any emoji reaction requests')
outbox_reaction(recent_posts_cache,
base_dir, http_prefix,
postToNickname, domain, port,
post_to_nickname, domain, port,
message_json, debug)
if debug:
print('DEBUG: handle any undo emoji reaction requests')
outbox_undo_reaction(recent_posts_cache,
base_dir, http_prefix,
postToNickname, domain, port,
post_to_nickname, domain, port,
message_json, debug)
if debug:
print('DEBUG: handle any undo announce requests')
outbox_undo_announce(recent_posts_cache,
base_dir, http_prefix,
postToNickname, domain, port,
post_to_nickname, domain, port,
message_json, debug)
if debug:
print('DEBUG: handle any bookmark requests')
outbox_bookmark(recent_posts_cache,
base_dir, http_prefix,
postToNickname, domain, port,
post_to_nickname, domain, port,
message_json, debug)
if debug:
print('DEBUG: handle any undo bookmark requests')
outbox_undo_bookmark(recent_posts_cache,
base_dir, http_prefix,
postToNickname, domain, port,
post_to_nickname, domain, port,
message_json, debug)
if debug:
print('DEBUG: handle delete requests')
outbox_delete(base_dir, http_prefix,
postToNickname, domain,
post_to_nickname, domain,
message_json, debug,
allow_deletion,
recent_posts_cache)
@ -597,20 +597,20 @@ def post_message_to_outbox(session, translate: {},
if debug:
print('DEBUG: handle block requests')
outbox_block(base_dir, http_prefix,
postToNickname, domain,
post_to_nickname, domain,
port,
message_json, debug)
if debug:
print('DEBUG: handle undo block requests')
outbox_undo_block(base_dir, http_prefix,
postToNickname, domain,
post_to_nickname, domain,
port, message_json, debug)
if debug:
print('DEBUG: handle mute requests')
outbox_mute(base_dir, http_prefix,
postToNickname, domain,
post_to_nickname, domain,
port,
message_json, debug,
recent_posts_cache)
@ -618,14 +618,14 @@ def post_message_to_outbox(session, translate: {},
if debug:
print('DEBUG: handle undo mute requests')
outbox_undo_mute(base_dir, http_prefix,
postToNickname, domain,
post_to_nickname, domain,
port,
message_json, debug,
recent_posts_cache)
if debug:
print('DEBUG: handle share uploads')
outbox_share_upload(base_dir, http_prefix, postToNickname, domain,
outbox_share_upload(base_dir, http_prefix, post_to_nickname, domain,
port, message_json, debug, city,
system_language, translate, low_bandwidth,
content_license_url)
@ -633,28 +633,28 @@ def post_message_to_outbox(session, translate: {},
if debug:
print('DEBUG: handle undo share uploads')
outbox_undo_share_upload(base_dir, http_prefix,
postToNickname, domain,
post_to_nickname, domain,
port, message_json, debug)
if debug:
print('DEBUG: handle actor updates from c2s')
_person_receive_update_outbox(recent_posts_cache,
base_dir, http_prefix,
postToNickname, domain, port,
post_to_nickname, domain, port,
message_json, debug)
if debug:
print('DEBUG: sending c2s post to named addresses')
if message_json.get('to'):
print('c2s sender: ' +
postToNickname + '@' + domain + ':' + str(port) +
post_to_nickname + '@' + domain + ':' + str(port) +
' recipient: ' + str(message_json['to']))
else:
print('c2s sender: ' +
postToNickname + '@' + domain + ':' + str(port))
post_to_nickname + '@' + domain + ':' + str(port))
namedAddressesThread = \
send_to_named_addresses_thread(server.session, base_dir,
postToNickname,
post_to_nickname,
domain, onion_domain, i2p_domain, port,
http_prefix,
federation_list,

View File

@ -92,7 +92,7 @@ def _update_post_schedule(base_dir: str, handle: str, httpd,
print('Sending scheduled post ' + post_id)
if nickname:
httpd.postToNickname = nickname
httpd.post_to_nickname = nickname
if not post_message_to_outbox(httpd.session,
httpd.translate,
post_json_object, nickname,

View File

@ -17,7 +17,7 @@ from filters import is_filtered
def convert_video_to_note(base_dir: str, nickname: str, domain: str,
system_language: str,
post_json_object: {}, blockedCache: {}) -> {}:
post_json_object: {}, blocked_cache: {}) -> {}:
"""Converts a PeerTube Video ActivityPub(ish) object into
a Note, so that it can then be displayed in a timeline
"""
@ -69,7 +69,7 @@ def convert_video_to_note(base_dir: str, nickname: str, domain: str,
return None
postDomainFull = get_full_domain(postDomain, postDomainPort)
if is_blocked(base_dir, nickname, domain,
postNickname, postDomainFull, blockedCache):
postNickname, postDomainFull, blocked_cache):
return None
# check that the content is valid

View File

@ -25,8 +25,8 @@ from webapp_post import individual_post_as_html
def html_confirm_delete(css_cache: {},
recent_posts_cache: {}, max_recent_posts: int,
translate, pageNumber: int,
session, base_dir: str, messageId: str,
translate, page_number: int,
session, base_dir: str, message_id: str,
http_prefix: str, project_version: str,
cached_webfingers: {}, person_cache: {},
calling_domain: str,
@ -40,14 +40,14 @@ def html_confirm_delete(css_cache: {},
cw_lists: {}, lists_enabled: str) -> str:
"""Shows a screen asking to confirm the deletion of a post
"""
if '/statuses/' not in messageId:
if '/statuses/' not in message_id:
return None
actor = messageId.split('/statuses/')[0]
actor = message_id.split('/statuses/')[0]
nickname = get_nickname_from_actor(actor)
domain, port = get_domain_from_actor(actor)
domain_full = get_full_domain(domain, port)
post_filename = locate_post(base_dir, nickname, domain, messageId)
post_filename = locate_post(base_dir, nickname, domain, message_id)
if not post_filename:
return None
@ -55,19 +55,19 @@ def html_confirm_delete(css_cache: {},
if not post_json_object:
return None
delete_postStr = None
delete_post_str = None
css_filename = base_dir + '/epicyon-profile.css'
if os.path.isfile(base_dir + '/epicyon.css'):
css_filename = base_dir + '/epicyon.css'
instanceTitle = \
instance_title = \
get_config_param(base_dir, 'instanceTitle')
delete_postStr = \
html_header_with_external_style(css_filename, instanceTitle, None)
delete_postStr += \
delete_post_str = \
html_header_with_external_style(css_filename, instance_title, None)
delete_post_str += \
individual_post_as_html(signing_priv_key_pem,
True, recent_posts_cache, max_recent_posts,
translate, pageNumber,
translate, page_number,
base_dir, session,
cached_webfingers, person_cache,
nickname, domain, port, post_json_object,
@ -80,58 +80,58 @@ def html_confirm_delete(css_cache: {},
theme_name, system_language, max_like_count,
False, False, False, False, False, False,
cw_lists, lists_enabled)
delete_postStr += '<center>'
delete_postStr += \
delete_post_str += '<center>'
delete_post_str += \
' <p class="followText">' + \
translate['Delete this post?'] + '</p>'
postActor = get_alt_path(actor, domain_full, calling_domain)
delete_postStr += \
' <form method="POST" action="' + postActor + '/rmpost">\n'
delete_postStr += \
post_actor = get_alt_path(actor, domain_full, calling_domain)
delete_post_str += \
' <form method="POST" action="' + post_actor + '/rmpost">\n'
delete_post_str += \
' <input type="hidden" name="pageNumber" value="' + \
str(pageNumber) + '">\n'
delete_postStr += \
str(page_number) + '">\n'
delete_post_str += \
' <input type="hidden" name="messageId" value="' + \
messageId + '">\n'
delete_postStr += \
message_id + '">\n'
delete_post_str += \
' <button type="submit" class="button" name="submitYes">' + \
translate['Yes'] + '</button>\n'
delete_postStr += \
delete_post_str += \
' <a href="' + actor + '/inbox"><button class="button">' + \
translate['No'] + '</button></a>\n'
delete_postStr += ' </form>\n'
delete_postStr += '</center>\n'
delete_postStr += html_footer()
return delete_postStr
delete_post_str += ' </form>\n'
delete_post_str += '</center>\n'
delete_post_str += html_footer()
return delete_post_str
def html_confirm_remove_shared_item(css_cache: {}, translate: {},
base_dir: str,
actor: str, itemID: str,
actor: str, item_id: str,
calling_domain: str,
sharesFileType: str) -> str:
shares_file_type: str) -> str:
"""Shows a screen asking to confirm the removal of a shared item
"""
nickname = get_nickname_from_actor(actor)
domain, port = get_domain_from_actor(actor)
domain_full = get_full_domain(domain, port)
sharesFile = \
acct_dir(base_dir, nickname, domain) + '/' + sharesFileType + '.json'
if not os.path.isfile(sharesFile):
print('ERROR: no ' + sharesFileType + ' file ' + sharesFile)
shares_file = \
acct_dir(base_dir, nickname, domain) + '/' + shares_file_type + '.json'
if not os.path.isfile(shares_file):
print('ERROR: no ' + shares_file_type + ' file ' + shares_file)
return None
sharesJson = load_json(sharesFile)
if not sharesJson:
print('ERROR: unable to load ' + sharesFileType + '.json')
shares_json = load_json(shares_file)
if not shares_json:
print('ERROR: unable to load ' + shares_file_type + '.json')
return None
if not sharesJson.get(itemID):
print('ERROR: share named "' + itemID + '" is not in ' + sharesFile)
if not shares_json.get(item_id):
print('ERROR: share named "' + item_id + '" is not in ' + shares_file)
return None
sharedItemDisplayName = sharesJson[itemID]['displayName']
sharedItemImageUrl = None
if sharesJson[itemID].get('imageUrl'):
sharedItemImageUrl = sharesJson[itemID]['imageUrl']
shared_item_display_name = shares_json[item_id]['displayName']
shared_item_image_url = None
if shares_json[item_id].get('imageUrl'):
shared_item_image_url = shares_json[item_id]['imageUrl']
set_custom_background(base_dir, 'shares-background', 'follow-background')
@ -139,50 +139,50 @@ def html_confirm_remove_shared_item(css_cache: {}, translate: {},
if os.path.isfile(base_dir + '/follow.css'):
css_filename = base_dir + '/follow.css'
instanceTitle = get_config_param(base_dir, 'instanceTitle')
sharesStr = html_header_with_external_style(css_filename,
instanceTitle, None)
sharesStr += '<div class="follow">\n'
sharesStr += ' <div class="followAvatar">\n'
sharesStr += ' <center>\n'
if sharedItemImageUrl:
sharesStr += ' <img loading="lazy" src="' + \
sharedItemImageUrl + '"/>\n'
sharesStr += \
instance_title = get_config_param(base_dir, 'instanceTitle')
shares_str = html_header_with_external_style(css_filename,
instance_title, None)
shares_str += '<div class="follow">\n'
shares_str += ' <div class="followAvatar">\n'
shares_str += ' <center>\n'
if shared_item_image_url:
shares_str += ' <img loading="lazy" src="' + \
shared_item_image_url + '"/>\n'
shares_str += \
' <p class="followText">' + translate['Remove'] + \
' ' + sharedItemDisplayName + ' ?</p>\n'
postActor = get_alt_path(actor, domain_full, calling_domain)
if sharesFileType == 'shares':
' ' + shared_item_display_name + ' ?</p>\n'
post_actor = get_alt_path(actor, domain_full, calling_domain)
if shares_file_type == 'shares':
endpoint = 'rmshare'
else:
endpoint = 'rmwanted'
sharesStr += \
' <form method="POST" action="' + postActor + '/' + endpoint + '">\n'
sharesStr += \
shares_str += \
' <form method="POST" action="' + post_actor + '/' + endpoint + '">\n'
shares_str += \
' <input type="hidden" name="actor" value="' + actor + '">\n'
sharesStr += ' <input type="hidden" name="itemID" value="' + \
itemID + '">\n'
sharesStr += \
shares_str += ' <input type="hidden" name="itemID" value="' + \
item_id + '">\n'
shares_str += \
' <button type="submit" class="button" name="submitYes">' + \
translate['Yes'] + '</button>\n'
sharesStr += \
shares_str += \
' <a href="' + actor + '/inbox' + '"><button class="button">' + \
translate['No'] + '</button></a>\n'
sharesStr += ' </form>\n'
sharesStr += ' </center>\n'
sharesStr += ' </div>\n'
sharesStr += '</div>\n'
sharesStr += html_footer()
return sharesStr
shares_str += ' </form>\n'
shares_str += ' </center>\n'
shares_str += ' </div>\n'
shares_str += '</div>\n'
shares_str += html_footer()
return shares_str
def html_confirm_follow(css_cache: {}, translate: {}, base_dir: str,
originPathStr: str,
followActor: str,
followProfileUrl: str) -> str:
origin_path_str: str,
follow_actor: str,
follow_profile_url: str) -> str:
"""Asks to confirm a follow
"""
followDomain, port = get_domain_from_actor(followActor)
follow_domain, _ = get_domain_from_actor(follow_actor)
if os.path.isfile(base_dir + '/accounts/follow-background-custom.jpg'):
if not os.path.isfile(base_dir + '/accounts/follow-background.jpg'):
@ -193,42 +193,44 @@ def html_confirm_follow(css_cache: {}, translate: {}, base_dir: str,
if os.path.isfile(base_dir + '/follow.css'):
css_filename = base_dir + '/follow.css'
instanceTitle = get_config_param(base_dir, 'instanceTitle')
followStr = html_header_with_external_style(css_filename,
instanceTitle, None)
followStr += '<div class="follow">\n'
followStr += ' <div class="followAvatar">\n'
followStr += ' <center>\n'
followStr += ' <a href="' + followActor + '">\n'
followStr += ' <img loading="lazy" src="' + followProfileUrl + '"/></a>\n'
followStr += \
instance_title = get_config_param(base_dir, 'instanceTitle')
follow_str = html_header_with_external_style(css_filename,
instance_title, None)
follow_str += '<div class="follow">\n'
follow_str += ' <div class="followAvatar">\n'
follow_str += ' <center>\n'
follow_str += ' <a href="' + follow_actor + '">\n'
follow_str += \
' <img loading="lazy" src="' + follow_profile_url + '"/></a>\n'
follow_str += \
' <p class="followText">' + translate['Follow'] + ' ' + \
get_nickname_from_actor(followActor) + '@' + followDomain + ' ?</p>\n'
followStr += ' <form method="POST" action="' + \
originPathStr + '/followconfirm">\n'
followStr += ' <input type="hidden" name="actor" value="' + \
followActor + '">\n'
followStr += \
get_nickname_from_actor(follow_actor) + \
'@' + follow_domain + ' ?</p>\n'
follow_str += ' <form method="POST" action="' + \
origin_path_str + '/followconfirm">\n'
follow_str += ' <input type="hidden" name="actor" value="' + \
follow_actor + '">\n'
follow_str += \
' <button type="submit" class="button" name="submitYes">' + \
translate['Yes'] + '</button>\n'
followStr += \
' <a href="' + originPathStr + '"><button class="button">' + \
follow_str += \
' <a href="' + origin_path_str + '"><button class="button">' + \
translate['No'] + '</button></a>\n'
followStr += ' </form>\n'
followStr += '</center>\n'
followStr += '</div>\n'
followStr += '</div>\n'
followStr += html_footer()
return followStr
follow_str += ' </form>\n'
follow_str += '</center>\n'
follow_str += '</div>\n'
follow_str += '</div>\n'
follow_str += html_footer()
return follow_str
def html_confirm_unfollow(css_cache: {}, translate: {}, base_dir: str,
originPathStr: str,
followActor: str,
followProfileUrl: str) -> str:
origin_path_str: str,
follow_actor: str,
follow_profile_url: str) -> str:
"""Asks to confirm unfollowing an actor
"""
followDomain, port = get_domain_from_actor(followActor)
follow_domain, _ = get_domain_from_actor(follow_actor)
if os.path.isfile(base_dir + '/accounts/follow-background-custom.jpg'):
if not os.path.isfile(base_dir + '/accounts/follow-background.jpg'):
@ -239,43 +241,44 @@ def html_confirm_unfollow(css_cache: {}, translate: {}, base_dir: str,
if os.path.isfile(base_dir + '/follow.css'):
css_filename = base_dir + '/follow.css'
instanceTitle = get_config_param(base_dir, 'instanceTitle')
followStr = html_header_with_external_style(css_filename,
instanceTitle, None)
followStr += '<div class="follow">\n'
followStr += ' <div class="followAvatar">\n'
followStr += ' <center>\n'
followStr += ' <a href="' + followActor + '">\n'
followStr += ' <img loading="lazy" src="' + followProfileUrl + '"/></a>\n'
followStr += \
instance_title = get_config_param(base_dir, 'instanceTitle')
follow_str = html_header_with_external_style(css_filename,
instance_title, None)
follow_str += '<div class="follow">\n'
follow_str += ' <div class="followAvatar">\n'
follow_str += ' <center>\n'
follow_str += ' <a href="' + follow_actor + '">\n'
follow_str += \
' <img loading="lazy" src="' + follow_profile_url + '"/></a>\n'
follow_str += \
' <p class="followText">' + translate['Stop following'] + \
' ' + get_nickname_from_actor(followActor) + \
'@' + followDomain + ' ?</p>\n'
followStr += ' <form method="POST" action="' + \
originPathStr + '/unfollowconfirm">\n'
followStr += ' <input type="hidden" name="actor" value="' + \
followActor + '">\n'
followStr += \
' ' + get_nickname_from_actor(follow_actor) + \
'@' + follow_domain + ' ?</p>\n'
follow_str += ' <form method="POST" action="' + \
origin_path_str + '/unfollowconfirm">\n'
follow_str += ' <input type="hidden" name="actor" value="' + \
follow_actor + '">\n'
follow_str += \
' <button type="submit" class="button" name="submitYes">' + \
translate['Yes'] + '</button>\n'
followStr += \
' <a href="' + originPathStr + '"><button class="button">' + \
follow_str += \
' <a href="' + origin_path_str + '"><button class="button">' + \
translate['No'] + '</button></a>\n'
followStr += ' </form>\n'
followStr += '</center>\n'
followStr += '</div>\n'
followStr += '</div>\n'
followStr += html_footer()
return followStr
follow_str += ' </form>\n'
follow_str += '</center>\n'
follow_str += '</div>\n'
follow_str += '</div>\n'
follow_str += html_footer()
return follow_str
def html_confirm_unblock(css_cache: {}, translate: {}, base_dir: str,
originPathStr: str,
blockActor: str,
blockProfileUrl: str) -> str:
origin_path_str: str,
block_actor: str,
block_profile_url: str) -> str:
"""Asks to confirm unblocking an actor
"""
blockDomain, port = get_domain_from_actor(blockActor)
block_domain, _ = get_domain_from_actor(block_actor)
set_custom_background(base_dir, 'block-background', 'follow-background')
@ -283,30 +286,31 @@ def html_confirm_unblock(css_cache: {}, translate: {}, base_dir: str,
if os.path.isfile(base_dir + '/follow.css'):
css_filename = base_dir + '/follow.css'
instanceTitle = get_config_param(base_dir, 'instanceTitle')
blockStr = html_header_with_external_style(css_filename,
instanceTitle, None)
blockStr += '<div class="block">\n'
blockStr += ' <div class="blockAvatar">\n'
blockStr += ' <center>\n'
blockStr += ' <a href="' + blockActor + '">\n'
blockStr += ' <img loading="lazy" src="' + blockProfileUrl + '"/></a>\n'
blockStr += \
instance_title = get_config_param(base_dir, 'instanceTitle')
block_str = html_header_with_external_style(css_filename,
instance_title, None)
block_str += '<div class="block">\n'
block_str += ' <div class="blockAvatar">\n'
block_str += ' <center>\n'
block_str += ' <a href="' + block_actor + '">\n'
block_str += \
' <img loading="lazy" src="' + block_profile_url + '"/></a>\n'
block_str += \
' <p class="blockText">' + translate['Stop blocking'] + ' ' + \
get_nickname_from_actor(blockActor) + '@' + blockDomain + ' ?</p>\n'
blockStr += ' <form method="POST" action="' + \
originPathStr + '/unblockconfirm">\n'
blockStr += ' <input type="hidden" name="actor" value="' + \
blockActor + '">\n'
blockStr += \
get_nickname_from_actor(block_actor) + '@' + block_domain + ' ?</p>\n'
block_str += ' <form method="POST" action="' + \
origin_path_str + '/unblockconfirm">\n'
block_str += ' <input type="hidden" name="actor" value="' + \
block_actor + '">\n'
block_str += \
' <button type="submit" class="button" name="submitYes">' + \
translate['Yes'] + '</button>\n'
blockStr += \
' <a href="' + originPathStr + '"><button class="button">' + \
block_str += \
' <a href="' + origin_path_str + '"><button class="button">' + \
translate['No'] + '</button></a>\n'
blockStr += ' </form>\n'
blockStr += '</center>\n'
blockStr += '</div>\n'
blockStr += '</div>\n'
blockStr += html_footer()
return blockStr
block_str += ' </form>\n'
block_str += '</center>\n'
block_str += '</div>\n'
block_str += '</div>\n'
block_str += html_footer()
return block_str

View File

@ -1500,7 +1500,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
announceJsonObject = None
if post_json_object['type'] == 'Announce':
announceJsonObject = post_json_object.copy()
blockedCache = {}
blocked_cache = {}
post_jsonAnnounce = \
download_announce(session, base_dir, http_prefix,
nickname, domain, post_json_object,
@ -1512,7 +1512,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
system_language,
domain_full, person_cache,
signing_priv_key_pem,
blockedCache)
blocked_cache)
if not post_jsonAnnounce:
# if the announce could not be downloaded then mark it as rejected
announcedPostId = remove_id_ending(post_json_object['id'])