Snake case

merge-requests/30/head
Bob Mottram 2022-01-02 14:51:02 +00:00
parent 0d4088705f
commit 6326203952
10 changed files with 614 additions and 607 deletions

View File

@ -2200,21 +2200,21 @@ if args.followers:
signing_priv_key_pem = None signing_priv_key_pem = None
if args.secure_mode: if args.secure_mode:
signing_priv_key_pem = get_instance_actor_key(base_dir, domain) signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
wfRequest = webfinger_handle(session, handle, wf_request = webfinger_handle(session, handle,
http_prefix, cached_webfingers, http_prefix, cached_webfingers,
hostDomain, __version__, debug, False, hostDomain, __version__, debug, False,
signing_priv_key_pem) signing_priv_key_pem)
if not wfRequest: if not wf_request:
print('Unable to webfinger ' + handle) print('Unable to webfinger ' + handle)
sys.exit() sys.exit()
if not isinstance(wfRequest, dict): if not isinstance(wf_request, dict):
print('Webfinger for ' + handle + ' did not return a dict. ' + print('Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest)) str(wf_request))
sys.exit() sys.exit()
personUrl = None personUrl = None
if wfRequest.get('errors'): if wf_request.get('errors'):
print('wfRequest error: ' + str(wfRequest['errors'])) print('wf_request error: ' + str(wf_request['errors']))
if has_users_path(args.followers): if has_users_path(args.followers):
personUrl = originalActor personUrl = originalActor
else: else:
@ -2225,7 +2225,7 @@ if args.followers:
'Accept': 'application/activity+json; profile="' + profileStr + '"' 'Accept': 'application/activity+json; profile="' + profileStr + '"'
} }
if not personUrl: if not personUrl:
personUrl = get_user_url(wfRequest, 0, args.debug) personUrl = get_user_url(wf_request, 0, args.debug)
if nickname == domain: if nickname == domain:
personUrl = personUrl.replace('/users/', '/actor/') personUrl = personUrl.replace('/users/', '/actor/')
personUrl = personUrl.replace('/accounts/', '/actor/') personUrl = personUrl.replace('/accounts/', '/actor/')

1033
follow.py

File diff suppressed because it is too large Load Diff

46
like.py
View File

@ -198,31 +198,31 @@ def send_like_via_server(base_dir: str, session,
handle = http_prefix + '://' + fromDomainFull + '/@' + fromNickname handle = http_prefix + '://' + fromDomainFull + '/@' + fromNickname
# lookup the inbox for the To handle # lookup the inbox for the To handle
wfRequest = webfinger_handle(session, handle, http_prefix, wf_request = webfinger_handle(session, handle, http_prefix,
cached_webfingers, cached_webfingers,
fromDomain, project_version, debug, False, fromDomain, project_version, debug, False,
signing_priv_key_pem) signing_priv_key_pem)
if not wfRequest: if not wf_request:
if debug: if debug:
print('DEBUG: like webfinger failed for ' + handle) print('DEBUG: like webfinger failed for ' + handle)
return 1 return 1
if not isinstance(wfRequest, dict): if not isinstance(wf_request, dict):
print('WARN: like webfinger for ' + handle + print('WARN: like webfinger for ' + handle +
' did not return a dict. ' + str(wfRequest)) ' did not return a dict. ' + str(wf_request))
return 1 return 1
postToBox = 'outbox' postToBox = 'outbox'
# get the actor inbox for the To handle # get the actor inbox for the To handle
originDomain = fromDomain originDomain = fromDomain
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl, (inboxUrl, _, _, fromPersonId, _, _,
displayName, _) = get_person_box(signing_priv_key_pem, _, _) = get_person_box(signing_priv_key_pem,
originDomain, originDomain,
base_dir, session, wfRequest, base_dir, session, wf_request,
person_cache, person_cache,
project_version, http_prefix, project_version, http_prefix,
fromNickname, fromDomain, fromNickname, fromDomain,
postToBox, 72873) postToBox, 72873)
if not inboxUrl: if not inboxUrl:
if debug: if debug:
@ -285,18 +285,18 @@ def send_undo_like_via_server(base_dir: str, session,
handle = http_prefix + '://' + fromDomainFull + '/@' + fromNickname handle = http_prefix + '://' + fromDomainFull + '/@' + fromNickname
# lookup the inbox for the To handle # lookup the inbox for the To handle
wfRequest = webfinger_handle(session, handle, http_prefix, wf_request = webfinger_handle(session, handle, http_prefix,
cached_webfingers, cached_webfingers,
fromDomain, project_version, debug, False, fromDomain, project_version, debug, False,
signing_priv_key_pem) signing_priv_key_pem)
if not wfRequest: if not wf_request:
if debug: if debug:
print('DEBUG: unlike webfinger failed for ' + handle) print('DEBUG: unlike webfinger failed for ' + handle)
return 1 return 1
if not isinstance(wfRequest, dict): if not isinstance(wf_request, dict):
if debug: if debug:
print('WARN: unlike webfinger for ' + handle + print('WARN: unlike webfinger for ' + handle +
' did not return a dict. ' + str(wfRequest)) ' did not return a dict. ' + str(wf_request))
return 1 return 1
postToBox = 'outbox' postToBox = 'outbox'
@ -306,7 +306,7 @@ def send_undo_like_via_server(base_dir: str, session,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl, (inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = get_person_box(signing_priv_key_pem, displayName, _) = get_person_box(signing_priv_key_pem,
originDomain, originDomain,
base_dir, session, wfRequest, base_dir, session, wf_request,
person_cache, project_version, person_cache, project_version,
http_prefix, fromNickname, http_prefix, fromNickname,
fromDomain, postToBox, fromDomain, postToBox,

View File

@ -60,26 +60,26 @@ def _update_moved_handle(base_dir: str, nickname: str, domain: str,
return ctr return ctr
if handle.startswith('@'): if handle.startswith('@'):
handle = handle[1:] handle = handle[1:]
wfRequest = webfinger_handle(session, handle, wf_request = webfinger_handle(session, handle,
http_prefix, cached_webfingers, http_prefix, cached_webfingers,
domain, __version__, debug, False, domain, __version__, debug, False,
signing_priv_key_pem) signing_priv_key_pem)
if not wfRequest: if not wf_request:
print('updateMovedHandle unable to webfinger ' + handle) print('updateMovedHandle unable to webfinger ' + handle)
return ctr return ctr
if not isinstance(wfRequest, dict): if not isinstance(wf_request, dict):
print('updateMovedHandle webfinger for ' + handle + print('updateMovedHandle webfinger for ' + handle +
' did not return a dict. ' + str(wfRequest)) ' did not return a dict. ' + str(wf_request))
return ctr return ctr
personUrl = None personUrl = None
if wfRequest.get('errors'): if wf_request.get('errors'):
print('wfRequest error: ' + str(wfRequest['errors'])) print('wf_request error: ' + str(wf_request['errors']))
return ctr return ctr
if not personUrl: if not personUrl:
personUrl = get_user_url(wfRequest, 0, debug) personUrl = get_user_url(wf_request, 0, debug)
if not personUrl: if not personUrl:
return ctr return ctr

View File

@ -1523,7 +1523,7 @@ def get_actor_json(hostDomain: str, handle: str, http: bool, gnunet: bool,
nickname = domain nickname = domain
personUrl = None personUrl = None
wfRequest = None wf_request = None
if '://' in originalActor and \ if '://' in originalActor and \
originalActor.lower().endswith('/actor'): originalActor.lower().endswith('/actor'):
@ -1536,27 +1536,27 @@ def get_actor_json(hostDomain: str, handle: str, http: bool, gnunet: bool,
personUrl = originalActor personUrl = originalActor
else: else:
handle = nickname + '@' + domain handle = nickname + '@' + domain
wfRequest = webfinger_handle(session, handle, wf_request = webfinger_handle(session, handle,
http_prefix, cached_webfingers, http_prefix, cached_webfingers,
hostDomain, __version__, debug, hostDomain, __version__, debug,
group_account, signing_priv_key_pem) group_account, signing_priv_key_pem)
if not wfRequest: if not wf_request:
if not quiet: if not quiet:
print('get_actor_json Unable to webfinger ' + handle) print('get_actor_json Unable to webfinger ' + handle)
return None, None return None, None
if not isinstance(wfRequest, dict): if not isinstance(wf_request, dict):
if not quiet: if not quiet:
print('get_actor_json Webfinger for ' + handle + print('get_actor_json Webfinger for ' + handle +
' did not return a dict. ' + str(wfRequest)) ' did not return a dict. ' + str(wf_request))
return None, None return None, None
if not quiet: if not quiet:
pprint(wfRequest) pprint(wf_request)
if wfRequest.get('errors'): if wf_request.get('errors'):
if not quiet or debug: if not quiet or debug:
print('get_actor_json wfRequest error: ' + print('get_actor_json wf_request error: ' +
str(wfRequest['errors'])) str(wf_request['errors']))
if has_users_path(handle): if has_users_path(handle):
personUrl = originalActor personUrl = originalActor
else: else:
@ -1568,8 +1568,8 @@ def get_actor_json(hostDomain: str, handle: str, http: bool, gnunet: bool,
headersList = ( headersList = (
"activity+json", "ld+json", "jrd+json" "activity+json", "ld+json", "jrd+json"
) )
if not personUrl and wfRequest: if not personUrl and wf_request:
personUrl = get_user_url(wfRequest, 0, debug) personUrl = get_user_url(wf_request, 0, debug)
if nickname == domain: if nickname == domain:
paths = get_user_paths() paths = get_user_paths()
for userPath in paths: for userPath in paths:

10
pgp.py
View File

@ -556,19 +556,19 @@ def pgp_public_key_upload(base_dir: str, session,
print('actor update is ' + str(actorUpdate)) print('actor update is ' + str(actorUpdate))
# lookup the inbox for the To handle # lookup the inbox for the To handle
wfRequest = \ wf_request = \
webfinger_handle(session, handle, http_prefix, cached_webfingers, webfinger_handle(session, handle, http_prefix, cached_webfingers,
domain, __version__, debug, False, domain, __version__, debug, False,
signing_priv_key_pem) signing_priv_key_pem)
if not wfRequest: if not wf_request:
if debug: if debug:
print('DEBUG: pgp actor update webfinger failed for ' + print('DEBUG: pgp actor update webfinger failed for ' +
handle) handle)
return None return None
if not isinstance(wfRequest, dict): if not isinstance(wf_request, dict):
if debug: if debug:
print('WARN: Webfinger for ' + handle + print('WARN: Webfinger for ' + handle +
' did not return a dict. ' + str(wfRequest)) ' did not return a dict. ' + str(wf_request))
return None return None
postToBox = 'outbox' postToBox = 'outbox'
@ -577,7 +577,7 @@ def pgp_public_key_upload(base_dir: str, session,
originDomain = domain originDomain = domain
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl, (inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = get_person_box(signing_priv_key_pem, originDomain, displayName, _) = get_person_box(signing_priv_key_pem, originDomain,
base_dir, session, wfRequest, base_dir, session, wf_request,
person_cache, person_cache,
__version__, http_prefix, nickname, __version__, http_prefix, nickname,
domain, postToBox, 35725) domain, postToBox, 35725)

View File

@ -609,18 +609,18 @@ def send_share_via_server(base_dir, session,
handle = http_prefix + '://' + fromDomainFull + '/@' + fromNickname handle = http_prefix + '://' + fromDomainFull + '/@' + fromNickname
# lookup the inbox for the To handle # lookup the inbox for the To handle
wfRequest = \ wf_request = \
webfinger_handle(session, handle, http_prefix, webfinger_handle(session, handle, http_prefix,
cached_webfingers, cached_webfingers,
fromDomain, project_version, debug, False, fromDomain, project_version, debug, False,
signing_priv_key_pem) signing_priv_key_pem)
if not wfRequest: if not wf_request:
if debug: if debug:
print('DEBUG: share webfinger failed for ' + handle) print('DEBUG: share webfinger failed for ' + handle)
return 1 return 1
if not isinstance(wfRequest, dict): if not isinstance(wf_request, dict):
print('WARN: share webfinger for ' + handle + print('WARN: share webfinger for ' + handle +
' did not return a dict. ' + str(wfRequest)) ' did not return a dict. ' + str(wf_request))
return 1 return 1
postToBox = 'outbox' postToBox = 'outbox'
@ -630,7 +630,7 @@ def send_share_via_server(base_dir, session,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl, (inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = get_person_box(signing_priv_key_pem, displayName, _) = get_person_box(signing_priv_key_pem,
originDomain, originDomain,
base_dir, session, wfRequest, base_dir, session, wf_request,
person_cache, project_version, person_cache, project_version,
http_prefix, fromNickname, http_prefix, fromNickname,
fromDomain, postToBox, fromDomain, postToBox,
@ -714,17 +714,17 @@ def send_undo_share_via_server(base_dir: str, session,
handle = http_prefix + '://' + fromDomainFull + '/@' + fromNickname handle = http_prefix + '://' + fromDomainFull + '/@' + fromNickname
# lookup the inbox for the To handle # lookup the inbox for the To handle
wfRequest = \ wf_request = \
webfinger_handle(session, handle, http_prefix, cached_webfingers, webfinger_handle(session, handle, http_prefix, cached_webfingers,
fromDomain, project_version, debug, False, fromDomain, project_version, debug, False,
signing_priv_key_pem) signing_priv_key_pem)
if not wfRequest: if not wf_request:
if debug: if debug:
print('DEBUG: unshare webfinger failed for ' + handle) print('DEBUG: unshare webfinger failed for ' + handle)
return 1 return 1
if not isinstance(wfRequest, dict): if not isinstance(wf_request, dict):
print('WARN: unshare webfinger for ' + handle + print('WARN: unshare webfinger for ' + handle +
' did not return a dict. ' + str(wfRequest)) ' did not return a dict. ' + str(wf_request))
return 1 return 1
postToBox = 'outbox' postToBox = 'outbox'
@ -734,7 +734,7 @@ def send_undo_share_via_server(base_dir: str, session,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl, (inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = get_person_box(signing_priv_key_pem, displayName, _) = get_person_box(signing_priv_key_pem,
originDomain, originDomain,
base_dir, session, wfRequest, base_dir, session, wf_request,
person_cache, project_version, person_cache, project_version,
http_prefix, fromNickname, http_prefix, fromNickname,
fromDomain, postToBox, fromDomain, postToBox,
@ -829,18 +829,18 @@ def send_wanted_via_server(base_dir, session,
handle = http_prefix + '://' + fromDomainFull + '/@' + fromNickname handle = http_prefix + '://' + fromDomainFull + '/@' + fromNickname
# lookup the inbox for the To handle # lookup the inbox for the To handle
wfRequest = \ wf_request = \
webfinger_handle(session, handle, http_prefix, webfinger_handle(session, handle, http_prefix,
cached_webfingers, cached_webfingers,
fromDomain, project_version, debug, False, fromDomain, project_version, debug, False,
signing_priv_key_pem) signing_priv_key_pem)
if not wfRequest: if not wf_request:
if debug: if debug:
print('DEBUG: share webfinger failed for ' + handle) print('DEBUG: share webfinger failed for ' + handle)
return 1 return 1
if not isinstance(wfRequest, dict): if not isinstance(wf_request, dict):
print('WARN: wanted webfinger for ' + handle + print('WARN: wanted webfinger for ' + handle +
' did not return a dict. ' + str(wfRequest)) ' did not return a dict. ' + str(wf_request))
return 1 return 1
postToBox = 'outbox' postToBox = 'outbox'
@ -850,7 +850,7 @@ def send_wanted_via_server(base_dir, session,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl, (inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = get_person_box(signing_priv_key_pem, displayName, _) = get_person_box(signing_priv_key_pem,
originDomain, originDomain,
base_dir, session, wfRequest, base_dir, session, wf_request,
person_cache, project_version, person_cache, project_version,
http_prefix, fromNickname, http_prefix, fromNickname,
fromDomain, postToBox, fromDomain, postToBox,
@ -934,17 +934,17 @@ def send_undo_wanted_via_server(base_dir: str, session,
handle = http_prefix + '://' + fromDomainFull + '/@' + fromNickname handle = http_prefix + '://' + fromDomainFull + '/@' + fromNickname
# lookup the inbox for the To handle # lookup the inbox for the To handle
wfRequest = \ wf_request = \
webfinger_handle(session, handle, http_prefix, cached_webfingers, webfinger_handle(session, handle, http_prefix, cached_webfingers,
fromDomain, project_version, debug, False, fromDomain, project_version, debug, False,
signing_priv_key_pem) signing_priv_key_pem)
if not wfRequest: if not wf_request:
if debug: if debug:
print('DEBUG: unwant webfinger failed for ' + handle) print('DEBUG: unwant webfinger failed for ' + handle)
return 1 return 1
if not isinstance(wfRequest, dict): if not isinstance(wf_request, dict):
print('WARN: unwant webfinger for ' + handle + print('WARN: unwant webfinger for ' + handle +
' did not return a dict. ' + str(wfRequest)) ' did not return a dict. ' + str(wf_request))
return 1 return 1
postToBox = 'outbox' postToBox = 'outbox'
@ -954,7 +954,7 @@ def send_undo_wanted_via_server(base_dir: str, session,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl, (inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = get_person_box(signing_priv_key_pem, displayName, _) = get_person_box(signing_priv_key_pem,
originDomain, originDomain,
base_dir, session, wfRequest, base_dir, session, wf_request,
person_cache, project_version, person_cache, project_version,
http_prefix, fromNickname, http_prefix, fromNickname,
fromDomain, postToBox, fromDomain, postToBox,

View File

@ -207,18 +207,18 @@ def send_skill_via_server(base_dir: str, session, nickname: str, password: str,
handle = http_prefix + '://' + domain_full + '/@' + nickname handle = http_prefix + '://' + domain_full + '/@' + nickname
# lookup the inbox for the To handle # lookup the inbox for the To handle
wfRequest = \ wf_request = \
webfinger_handle(session, handle, http_prefix, webfinger_handle(session, handle, http_prefix,
cached_webfingers, cached_webfingers,
domain, project_version, debug, False, domain, project_version, debug, False,
signing_priv_key_pem) signing_priv_key_pem)
if not wfRequest: if not wf_request:
if debug: if debug:
print('DEBUG: skill webfinger failed for ' + handle) print('DEBUG: skill webfinger failed for ' + handle)
return 1 return 1
if not isinstance(wfRequest, dict): if not isinstance(wf_request, dict):
print('WARN: skill webfinger for ' + handle + print('WARN: skill webfinger for ' + handle +
' did not return a dict. ' + str(wfRequest)) ' did not return a dict. ' + str(wf_request))
return 1 return 1
postToBox = 'outbox' postToBox = 'outbox'
@ -228,7 +228,7 @@ def send_skill_via_server(base_dir: str, session, nickname: str, password: str,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl, (inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = get_person_box(signing_priv_key_pem, displayName, _) = get_person_box(signing_priv_key_pem,
originDomain, originDomain,
base_dir, session, wfRequest, base_dir, session, wf_request,
person_cache, project_version, person_cache, project_version,
http_prefix, nickname, domain, http_prefix, nickname, domain,
postToBox, 76121) postToBox, 76121)

View File

@ -51,23 +51,23 @@ def instances_graph(base_dir: str, handles: str,
domain_full = get_full_domain(domain, port) domain_full = get_full_domain(domain, port)
handle = http_prefix + "://" + domain_full + "/@" + nickname handle = http_prefix + "://" + domain_full + "/@" + nickname
wfRequest = \ wf_request = \
webfinger_handle(session, handle, http_prefix, webfinger_handle(session, handle, http_prefix,
cached_webfingers, cached_webfingers,
domain, project_version, debug, False, domain, project_version, debug, False,
signing_priv_key_pem) signing_priv_key_pem)
if not wfRequest: if not wf_request:
return dotGraphStr + '}\n' return dotGraphStr + '}\n'
if not isinstance(wfRequest, dict): if not isinstance(wf_request, dict):
print('Webfinger for ' + handle + ' did not return a dict. ' + print('Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest)) str(wf_request))
return dotGraphStr + '}\n' return dotGraphStr + '}\n'
originDomain = None originDomain = None
(personUrl, pubKeyId, pubKey, personId, shaedInbox, avatarUrl, (personUrl, pubKeyId, pubKey, personId, shaedInbox, avatarUrl,
displayName, _) = get_person_box(signing_priv_key_pem, displayName, _) = get_person_box(signing_priv_key_pem,
originDomain, originDomain,
base_dir, session, wfRequest, base_dir, session, wf_request,
person_cache, person_cache,
project_version, http_prefix, project_version, http_prefix,
nickname, domain, 'outbox', nickname, domain, 'outbox',

View File

@ -33,7 +33,7 @@ from session import create_session
def html_moderation(css_cache: {}, default_timeline: str, def html_moderation(css_cache: {}, default_timeline: str,
recent_posts_cache: {}, max_recent_posts: int, recent_posts_cache: {}, max_recent_posts: int,
translate: {}, pageNumber: int, itemsPerPage: int, translate: {}, pageNumber: int, itemsPerPage: int,
session, base_dir: str, wfRequest: {}, person_cache: {}, session, base_dir: str, wf_request: {}, person_cache: {},
nickname: str, domain: str, port: int, inboxJson: {}, nickname: str, domain: str, port: int, inboxJson: {},
allow_deletion: bool, allow_deletion: bool,
http_prefix: str, project_version: str, http_prefix: str, project_version: str,
@ -63,7 +63,7 @@ def html_moderation(css_cache: {}, default_timeline: str,
recent_posts_cache, max_recent_posts, recent_posts_cache, max_recent_posts,
translate, pageNumber, translate, pageNumber,
itemsPerPage, session, base_dir, itemsPerPage, session, base_dir,
wfRequest, person_cache, wf_request, person_cache,
nickname, domain, port, inboxJson, 'moderation', nickname, domain, port, inboxJson, 'moderation',
allow_deletion, http_prefix, allow_deletion, http_prefix,
project_version, True, False, project_version, True, False,