mirror of https://gitlab.com/bashrc2/epicyon
Snake case
parent
ee5cbb2c5d
commit
a5dcac8679
|
@ -81,7 +81,7 @@ def _getMastoApiV1Account(base_dir: str, nickname: str, domain: str) -> {}:
|
||||||
return mastoAccountJson
|
return mastoAccountJson
|
||||||
|
|
||||||
|
|
||||||
def mastoApiV1Response(path: str, callingDomain: str,
|
def mastoApiV1Response(path: str, calling_domain: str,
|
||||||
uaStr: str,
|
uaStr: str,
|
||||||
authorized: bool,
|
authorized: bool,
|
||||||
http_prefix: str,
|
http_prefix: str,
|
||||||
|
@ -112,7 +112,7 @@ def mastoApiV1Response(path: str, callingDomain: str,
|
||||||
'masto API account sent for ' + nickname + ' ' + uaStr
|
'masto API account sent for ' + nickname + ' ' + uaStr
|
||||||
|
|
||||||
# information about where the request is coming from
|
# information about where the request is coming from
|
||||||
callingInfo = ' ' + uaStr + ', ' + callingDomain
|
callingInfo = ' ' + uaStr + ', ' + calling_domain
|
||||||
|
|
||||||
# Parts of the api which don't need authorization
|
# Parts of the api which don't need authorization
|
||||||
mastoId = _getMastApiV1Id(path)
|
mastoId = _getMastApiV1Id(path)
|
||||||
|
@ -207,10 +207,10 @@ def mastoApiV1Response(path: str, callingDomain: str,
|
||||||
get_config_param(base_dir, 'instanceDescription')
|
get_config_param(base_dir, 'instanceDescription')
|
||||||
instanceTitle = get_config_param(base_dir, 'instanceTitle')
|
instanceTitle = get_config_param(base_dir, 'instanceTitle')
|
||||||
|
|
||||||
if callingDomain.endswith('.onion') and onion_domain:
|
if calling_domain.endswith('.onion') and onion_domain:
|
||||||
domain_full = onion_domain
|
domain_full = onion_domain
|
||||||
http_prefix = 'http'
|
http_prefix = 'http'
|
||||||
elif (callingDomain.endswith('.i2p') and i2p_domain):
|
elif (calling_domain.endswith('.i2p') and i2p_domain):
|
||||||
domain_full = i2p_domain
|
domain_full = i2p_domain
|
||||||
http_prefix = 'http'
|
http_prefix = 'http'
|
||||||
|
|
||||||
|
|
10
shares.py
10
shares.py
|
@ -1485,7 +1485,7 @@ def createSharedItemFederationToken(base_dir: str,
|
||||||
def authorizeSharedItems(shared_items_federated_domains: [],
|
def authorizeSharedItems(shared_items_federated_domains: [],
|
||||||
base_dir: str,
|
base_dir: str,
|
||||||
originDomainFull: str,
|
originDomainFull: str,
|
||||||
callingDomainFull: str,
|
calling_domainFull: str,
|
||||||
authHeader: str,
|
authHeader: str,
|
||||||
debug: bool,
|
debug: bool,
|
||||||
tokensJson: {} = None) -> bool:
|
tokensJson: {} = None) -> bool:
|
||||||
|
@ -1525,16 +1525,16 @@ def authorizeSharedItems(shared_items_federated_domains: [],
|
||||||
tokensJson = load_json(tokensFilename, 1, 2)
|
tokensJson = load_json(tokensFilename, 1, 2)
|
||||||
if not tokensJson:
|
if not tokensJson:
|
||||||
return False
|
return False
|
||||||
if not tokensJson.get(callingDomainFull):
|
if not tokensJson.get(calling_domainFull):
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: shared item federation token ' +
|
print('DEBUG: shared item federation token ' +
|
||||||
'check failed for ' + callingDomainFull)
|
'check failed for ' + calling_domainFull)
|
||||||
return False
|
return False
|
||||||
if not constantTimeStringCheck(tokensJson[callingDomainFull],
|
if not constantTimeStringCheck(tokensJson[calling_domainFull],
|
||||||
providedToken):
|
providedToken):
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: shared item federation token ' +
|
print('DEBUG: shared item federation token ' +
|
||||||
'mismatch for ' + callingDomainFull)
|
'mismatch for ' + calling_domainFull)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
18
utils.py
18
utils.py
|
@ -2859,18 +2859,18 @@ def has_object_dict(post_json_object: {}) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def getAltPath(actor: str, domain_full: str, callingDomain: str) -> str:
|
def getAltPath(actor: str, domain_full: str, calling_domain: str) -> str:
|
||||||
"""Returns alternate path from the actor
|
"""Returns alternate path from the actor
|
||||||
eg. https://clearnetdomain/path becomes http://oniondomain/path
|
eg. https://clearnetdomain/path becomes http://oniondomain/path
|
||||||
"""
|
"""
|
||||||
postActor = actor
|
post_actor = actor
|
||||||
if callingDomain not in actor and domain_full in actor:
|
if calling_domain not in actor and domain_full in actor:
|
||||||
if callingDomain.endswith('.onion') or \
|
if calling_domain.endswith('.onion') or \
|
||||||
callingDomain.endswith('.i2p'):
|
calling_domain.endswith('.i2p'):
|
||||||
postActor = \
|
post_actor = \
|
||||||
'http://' + callingDomain + actor.split(domain_full)[1]
|
'http://' + calling_domain + actor.split(domain_full)[1]
|
||||||
print('Changed POST domain from ' + actor + ' to ' + postActor)
|
print('Changed POST domain from ' + actor + ' to ' + post_actor)
|
||||||
return postActor
|
return post_actor
|
||||||
|
|
||||||
|
|
||||||
def get_actor_property_url(actor_json: {}, property_name: str) -> str:
|
def get_actor_property_url(actor_json: {}, property_name: str) -> str:
|
||||||
|
|
|
@ -35,7 +35,7 @@ def htmlCalendarDeleteConfirm(cssCache: {}, translate: {}, base_dir: str,
|
||||||
path: str, http_prefix: str,
|
path: str, http_prefix: str,
|
||||||
domain_full: str, postId: str, postTime: str,
|
domain_full: str, postId: str, postTime: str,
|
||||||
year: int, monthNumber: int,
|
year: int, monthNumber: int,
|
||||||
dayNumber: int, callingDomain: str) -> str:
|
dayNumber: int, calling_domain: str) -> str:
|
||||||
"""Shows a screen asking to confirm the deletion of a calendar event
|
"""Shows a screen asking to confirm the deletion of a calendar event
|
||||||
"""
|
"""
|
||||||
nickname = getNicknameFromActor(path)
|
nickname = getNicknameFromActor(path)
|
||||||
|
@ -68,7 +68,7 @@ def htmlCalendarDeleteConfirm(cssCache: {}, translate: {}, base_dir: str,
|
||||||
deletePostStr += ' <p class="followText">' + \
|
deletePostStr += ' <p class="followText">' + \
|
||||||
translate['Delete this event'] + '</p>'
|
translate['Delete this event'] + '</p>'
|
||||||
|
|
||||||
postActor = getAltPath(actor, domain_full, callingDomain)
|
postActor = getAltPath(actor, domain_full, calling_domain)
|
||||||
deletePostStr += \
|
deletePostStr += \
|
||||||
' <form method="POST" action="' + postActor + '/rmpost">\n'
|
' <form method="POST" action="' + postActor + '/rmpost">\n'
|
||||||
deletePostStr += ' <input type="hidden" name="year" value="' + \
|
deletePostStr += ' <input type="hidden" name="year" value="' + \
|
||||||
|
|
|
@ -29,7 +29,7 @@ def htmlConfirmDelete(cssCache: {},
|
||||||
session, base_dir: str, messageId: str,
|
session, base_dir: str, messageId: str,
|
||||||
http_prefix: str, project_version: str,
|
http_prefix: str, project_version: str,
|
||||||
cached_webfingers: {}, person_cache: {},
|
cached_webfingers: {}, person_cache: {},
|
||||||
callingDomain: str,
|
calling_domain: str,
|
||||||
yt_replace_domain: str,
|
yt_replace_domain: str,
|
||||||
twitter_replacement_domain: str,
|
twitter_replacement_domain: str,
|
||||||
show_published_date_only: bool,
|
show_published_date_only: bool,
|
||||||
|
@ -85,7 +85,7 @@ def htmlConfirmDelete(cssCache: {},
|
||||||
' <p class="followText">' + \
|
' <p class="followText">' + \
|
||||||
translate['Delete this post?'] + '</p>'
|
translate['Delete this post?'] + '</p>'
|
||||||
|
|
||||||
postActor = getAltPath(actor, domain_full, callingDomain)
|
postActor = getAltPath(actor, domain_full, calling_domain)
|
||||||
deletePostStr += \
|
deletePostStr += \
|
||||||
' <form method="POST" action="' + postActor + '/rmpost">\n'
|
' <form method="POST" action="' + postActor + '/rmpost">\n'
|
||||||
deletePostStr += \
|
deletePostStr += \
|
||||||
|
@ -108,7 +108,7 @@ def htmlConfirmDelete(cssCache: {},
|
||||||
|
|
||||||
def htmlConfirmRemoveSharedItem(cssCache: {}, translate: {}, base_dir: str,
|
def htmlConfirmRemoveSharedItem(cssCache: {}, translate: {}, base_dir: str,
|
||||||
actor: str, itemID: str,
|
actor: str, itemID: str,
|
||||||
callingDomain: str,
|
calling_domain: str,
|
||||||
sharesFileType: str) -> str:
|
sharesFileType: str) -> str:
|
||||||
"""Shows a screen asking to confirm the removal of a shared item
|
"""Shows a screen asking to confirm the removal of a shared item
|
||||||
"""
|
"""
|
||||||
|
@ -149,7 +149,7 @@ def htmlConfirmRemoveSharedItem(cssCache: {}, translate: {}, base_dir: str,
|
||||||
sharesStr += \
|
sharesStr += \
|
||||||
' <p class="followText">' + translate['Remove'] + \
|
' <p class="followText">' + translate['Remove'] + \
|
||||||
' ' + sharedItemDisplayName + ' ?</p>\n'
|
' ' + sharedItemDisplayName + ' ?</p>\n'
|
||||||
postActor = getAltPath(actor, domain_full, callingDomain)
|
postActor = getAltPath(actor, domain_full, calling_domain)
|
||||||
if sharesFileType == 'shares':
|
if sharesFileType == 'shares':
|
||||||
endpoint = 'rmshare'
|
endpoint = 'rmshare'
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -134,12 +134,12 @@ def _matchSharedItem(searchStrLowerList: [],
|
||||||
|
|
||||||
|
|
||||||
def _htmlSearchResultSharePage(actor: str, domain_full: str,
|
def _htmlSearchResultSharePage(actor: str, domain_full: str,
|
||||||
callingDomain: str, pageNumber: int,
|
calling_domain: str, pageNumber: int,
|
||||||
searchStrLower: str, translate: {},
|
searchStrLower: str, translate: {},
|
||||||
previous: bool) -> str:
|
previous: bool) -> str:
|
||||||
"""Returns the html for the previous button on shared items search results
|
"""Returns the html for the previous button on shared items search results
|
||||||
"""
|
"""
|
||||||
postActor = getAltPath(actor, domain_full, callingDomain)
|
postActor = getAltPath(actor, domain_full, calling_domain)
|
||||||
# previous page link, needs to be a POST
|
# previous page link, needs to be a POST
|
||||||
if previous:
|
if previous:
|
||||||
pageNumber -= 1
|
pageNumber -= 1
|
||||||
|
@ -172,7 +172,7 @@ def _htmlSearchResultSharePage(actor: str, domain_full: str,
|
||||||
def _htmlSharesResult(base_dir: str,
|
def _htmlSharesResult(base_dir: str,
|
||||||
sharesJson: {}, pageNumber: int, resultsPerPage: int,
|
sharesJson: {}, pageNumber: int, resultsPerPage: int,
|
||||||
searchStrLowerList: [], currPage: int, ctr: int,
|
searchStrLowerList: [], currPage: int, ctr: int,
|
||||||
callingDomain: str, http_prefix: str, domain_full: str,
|
calling_domain: str, http_prefix: str, domain_full: str,
|
||||||
contactNickname: str, actor: str,
|
contactNickname: str, actor: str,
|
||||||
resultsExist: bool, searchStrLower: str, translate: {},
|
resultsExist: bool, searchStrLower: str, translate: {},
|
||||||
sharesFileType: str) -> (bool, int, int, str):
|
sharesFileType: str) -> (bool, int, int, str):
|
||||||
|
@ -196,7 +196,7 @@ def _htmlSharesResult(base_dir: str,
|
||||||
# show the previous page button
|
# show the previous page button
|
||||||
sharedItemsForm += \
|
sharedItemsForm += \
|
||||||
_htmlSearchResultSharePage(actor, domain_full,
|
_htmlSearchResultSharePage(actor, domain_full,
|
||||||
callingDomain,
|
calling_domain,
|
||||||
pageNumber,
|
pageNumber,
|
||||||
searchStrLower,
|
searchStrLower,
|
||||||
translate, True)
|
translate, True)
|
||||||
|
@ -208,7 +208,7 @@ def _htmlSharesResult(base_dir: str,
|
||||||
# show the next page button
|
# show the next page button
|
||||||
sharedItemsForm += \
|
sharedItemsForm += \
|
||||||
_htmlSearchResultSharePage(actor, domain_full,
|
_htmlSearchResultSharePage(actor, domain_full,
|
||||||
callingDomain,
|
calling_domain,
|
||||||
pageNumber,
|
pageNumber,
|
||||||
searchStrLower,
|
searchStrLower,
|
||||||
translate, False)
|
translate, False)
|
||||||
|
@ -223,7 +223,7 @@ def htmlSearchSharedItems(cssCache: {}, translate: {},
|
||||||
resultsPerPage: int,
|
resultsPerPage: int,
|
||||||
http_prefix: str,
|
http_prefix: str,
|
||||||
domain_full: str, actor: str,
|
domain_full: str, actor: str,
|
||||||
callingDomain: str,
|
calling_domain: str,
|
||||||
shared_items_federated_domains: [],
|
shared_items_federated_domains: [],
|
||||||
sharesFileType: str) -> str:
|
sharesFileType: str) -> str:
|
||||||
"""Search results for shared items
|
"""Search results for shared items
|
||||||
|
@ -269,7 +269,7 @@ def htmlSearchSharedItems(cssCache: {}, translate: {},
|
||||||
resultsPerPage,
|
resultsPerPage,
|
||||||
searchStrLowerList,
|
searchStrLowerList,
|
||||||
currPage, ctr,
|
currPage, ctr,
|
||||||
callingDomain, http_prefix,
|
calling_domain, http_prefix,
|
||||||
domain_full,
|
domain_full,
|
||||||
contactNickname,
|
contactNickname,
|
||||||
actor, resultsExist,
|
actor, resultsExist,
|
||||||
|
@ -307,7 +307,7 @@ def htmlSearchSharedItems(cssCache: {}, translate: {},
|
||||||
resultsPerPage,
|
resultsPerPage,
|
||||||
searchStrLowerList,
|
searchStrLowerList,
|
||||||
currPage, ctr,
|
currPage, ctr,
|
||||||
callingDomain, http_prefix,
|
calling_domain, http_prefix,
|
||||||
domain_full,
|
domain_full,
|
||||||
contactNickname,
|
contactNickname,
|
||||||
actor, resultsExist,
|
actor, resultsExist,
|
||||||
|
|
Loading…
Reference in New Issue