mirror of https://gitlab.com/bashrc2/epicyon
Revoking granted feature authorizations
parent
d5d5ff3f21
commit
531e755f7d
|
|
@ -299,10 +299,13 @@ def store_feature_authorization(base_dir: str, nickname: str, domain: str,
|
||||||
accounts_dir: str = acct_dir(base_dir, nickname, domain)
|
accounts_dir: str = acct_dir(base_dir, nickname, domain)
|
||||||
if not is_a_dir(accounts_dir + '/stamps'):
|
if not is_a_dir(accounts_dir + '/stamps'):
|
||||||
makedir(accounts_dir + '/stamps')
|
makedir(accounts_dir + '/stamps')
|
||||||
|
if not is_a_dir(accounts_dir + '/stamps/granted'):
|
||||||
|
makedir(accounts_dir + '/stamps/granted')
|
||||||
stamp_number = featured_item['featureAuthorization'].split('/stamps/')[1]
|
stamp_number = featured_item['featureAuthorization'].split('/stamps/')[1]
|
||||||
if '/' in stamp_number:
|
if '/' in stamp_number:
|
||||||
stamp_number = stamp_number.split('/')[0]
|
stamp_number = stamp_number.split('/')[0]
|
||||||
feature_authorization_filename = accounts_dir + '/stamps/' + stamp_number
|
feature_authorization_filename = \
|
||||||
|
accounts_dir + '/stamps/granted/' + stamp_number
|
||||||
if not is_a_file(feature_authorization_filename):
|
if not is_a_file(feature_authorization_filename):
|
||||||
return False
|
return False
|
||||||
return save_json(featured_item, feature_authorization_filename)
|
return save_json(featured_item, feature_authorization_filename)
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ def get_feature_authorization(self, calling_domain: str,
|
||||||
return
|
return
|
||||||
# does the stamp exist?
|
# does the stamp exist?
|
||||||
account_dir = acct_dir(base_dir, nickname, domain)
|
account_dir = acct_dir(base_dir, nickname, domain)
|
||||||
stamp_filename = account_dir + '/stamps/' + stamp_number
|
stamp_filename = account_dir + '/stamps/granted/' + stamp_number
|
||||||
if not is_a_file(stamp_filename):
|
if not is_a_file(stamp_filename):
|
||||||
return
|
return
|
||||||
# load the stamp from file
|
# load the stamp from file
|
||||||
|
|
|
||||||
|
|
@ -1941,37 +1941,27 @@ def _receive_delete_feature_authorization(handle: str, base_dir: str,
|
||||||
return False
|
return False
|
||||||
if http_prefix + '://' + domain not in message_json['object']['id']:
|
if http_prefix + '://' + domain not in message_json['object']['id']:
|
||||||
return False
|
return False
|
||||||
if '/stamps/' not in message_json['object']['id']:
|
|
||||||
return False
|
|
||||||
stamp_number = message_json['object']['id'].split('/stamps/')[1]
|
|
||||||
if '/' in stamp_number:
|
|
||||||
stamp_number = stamp_number.split('/')[0]
|
|
||||||
if not stamp_number.isdigit():
|
|
||||||
return False
|
|
||||||
handle_nickname = handle.split('@')[0]
|
handle_nickname = handle.split('@')[0]
|
||||||
handle_domain = handle.split('@')[1]
|
handle_domain = handle.split('@')[1]
|
||||||
account_dir = acct_dir(base_dir, handle_nickname, handle_domain)
|
account_dir = acct_dir(base_dir, handle_nickname, handle_domain)
|
||||||
stamp_filename = account_dir + '/stamps/' + stamp_number
|
|
||||||
if not is_a_file(stamp_filename):
|
|
||||||
return False
|
|
||||||
stamp_json = load_json(stamp_filename)
|
|
||||||
if not stamp_json:
|
|
||||||
return False
|
|
||||||
# the featured url is typically an actor
|
# the featured url is typically an actor
|
||||||
featured_url = stamp_json['object']
|
featured_url = message_json['object']['interactionTarget']
|
||||||
if featured_url != message_json['object']['interactionTarget']:
|
granted_filename = \
|
||||||
return False
|
account_dir + '/stamps/granted/' + featured_url.replace('/', '#')
|
||||||
if erase_file(stamp_filename,
|
if is_a_file(granted_filename):
|
||||||
"EX: unable to remove feature authorization " +
|
if erase_file(granted_filename,
|
||||||
stamp_filename):
|
"EX: unable to remove feature authorization " +
|
||||||
if debug:
|
granted_filename):
|
||||||
print('Revoked feature authorization ' + stamp_filename)
|
if debug:
|
||||||
|
print('Revoked feature authorization ' + granted_filename)
|
||||||
# remove link from featured collections
|
# remove link from featured collections
|
||||||
collection_filename: str = account_dir + '/featured_collections.txt'
|
collection_filename: str = account_dir + '/featured_collections.txt'
|
||||||
collections_text = load_string(collection_filename,
|
collections_text = ''
|
||||||
'EX: unable to load ' +
|
if text_in_file(featured_url, collection_filename, True):
|
||||||
'featured_collections.txt of ' +
|
collections_text = load_string(collection_filename,
|
||||||
handle_nickname)
|
'EX: unable to load ' +
|
||||||
|
'featured_collections.txt of ' +
|
||||||
|
handle_nickname)
|
||||||
if collections_text:
|
if collections_text:
|
||||||
if not collections_text.endswith('\n'):
|
if not collections_text.endswith('\n'):
|
||||||
collections_text += '\n'
|
collections_text += '\n'
|
||||||
|
|
@ -1997,8 +1987,6 @@ def _receive_delete_feature_authorization(handle: str, base_dir: str,
|
||||||
if debug:
|
if debug:
|
||||||
print('Unauthorized link removed from featured collections ' +
|
print('Unauthorized link removed from featured collections ' +
|
||||||
featured_url + ' ' + collection_filename)
|
featured_url + ' ' + collection_filename)
|
||||||
if debug:
|
|
||||||
print('feature authorization stamp removed ' + stamp_filename)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue