mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
09c2df6be1
commit
0cb9a946b2
77
utils.py
77
utils.py
|
@ -4991,43 +4991,46 @@ def get_quote_toot_url(post_json_object: str) -> str:
|
||||||
return remove_html(quote_url)
|
return remove_html(quote_url)
|
||||||
|
|
||||||
# More correct ActivityPub implementation - adding a Link tag
|
# More correct ActivityPub implementation - adding a Link tag
|
||||||
if post_json_object['object'].get('tag'):
|
if not post_json_object['object'].get('tag'):
|
||||||
if isinstance(post_json_object['object']['tag'], list):
|
return ''
|
||||||
for item in post_json_object['object']['tag']:
|
|
||||||
if not isinstance(item, dict):
|
if not isinstance(post_json_object['object']['tag'], list):
|
||||||
continue
|
return ''
|
||||||
if item.get('rel'):
|
|
||||||
mk_quote = False
|
for item in post_json_object['object']['tag']:
|
||||||
if isinstance(item['rel'], list):
|
if not isinstance(item, dict):
|
||||||
for rel_str in item['rel']:
|
continue
|
||||||
if not isinstance(rel_str, str):
|
if item.get('rel'):
|
||||||
continue
|
mk_quote = False
|
||||||
if '_misskey_quote' in rel_str:
|
if isinstance(item['rel'], list):
|
||||||
mk_quote = True
|
for rel_str in item['rel']:
|
||||||
elif isinstance(item['rel'], str):
|
if not isinstance(rel_str, str):
|
||||||
if '_misskey_quote' in item['rel']:
|
continue
|
||||||
mk_quote = True
|
if '_misskey_quote' in rel_str:
|
||||||
if mk_quote:
|
mk_quote = True
|
||||||
if item.get('href'):
|
elif isinstance(item['rel'], str):
|
||||||
if isinstance(item['href'], str):
|
if '_misskey_quote' in item['rel']:
|
||||||
if resembles_url(item['href']):
|
mk_quote = True
|
||||||
return remove_html(item['href'])
|
if mk_quote and item.get('href'):
|
||||||
if not item.get('type'):
|
if isinstance(item['href'], str):
|
||||||
continue
|
if resembles_url(item['href']):
|
||||||
if not item.get('mediaType'):
|
return remove_html(item['href'])
|
||||||
continue
|
if not item.get('type'):
|
||||||
if not isinstance(item['type'], str):
|
continue
|
||||||
continue
|
if not item.get('mediaType'):
|
||||||
if item['type'] != 'Link':
|
continue
|
||||||
continue
|
if not isinstance(item['type'], str):
|
||||||
if not isinstance(item['mediaType'], str):
|
continue
|
||||||
continue
|
if item['type'] != 'Link':
|
||||||
if 'json' not in item['mediaType']:
|
continue
|
||||||
continue
|
if not isinstance(item['mediaType'], str):
|
||||||
if item.get('href'):
|
continue
|
||||||
if isinstance(item['href'], str):
|
if 'json' not in item['mediaType']:
|
||||||
if resembles_url(item['href']):
|
continue
|
||||||
return remove_html(item['href'])
|
if item.get('href'):
|
||||||
|
if isinstance(item['href'], str):
|
||||||
|
if resembles_url(item['href']):
|
||||||
|
return remove_html(item['href'])
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue