Attachment rather than tag

main
Bob Mottram 2023-01-13 21:43:14 +00:00
parent a9491491e7
commit dd299c636e
3 changed files with 10 additions and 7 deletions

View File

@ -1105,6 +1105,8 @@ def _attach_buy_link(post_json_object: {},
buy_str = 'Buy'
if translate.get(buy_str):
buy_str = translate[buy_str]
if 'attachment' not in post_json_object:
post_json_object['attachment'] = []
post_json_object['attachment'].append({
"type": "Link",
"name": buy_str,

View File

@ -2508,7 +2508,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
# html for the buy icon
buy_str = ''
if post_json_object['object'].get('tag'):
if 'attachment' not in post_json_object['object']:
post_json_object['object']['attachment'] = []
if not is_patch:
buy_links = get_buy_links(post_json_object, translate, buy_sites)
buy_str = _get_buy_footer(buy_links, translate)

View File

@ -2085,9 +2085,9 @@ def html_following_dropdown(base_dir: str, nickname: str,
def get_buy_links(post_json_object: str, translate: {}, buy_sites: {}) -> {}:
"""Returns any links to buy something from an external site
"""
if not post_json_object['object'].get('tag'):
if not post_json_object['object'].get('attachment'):
return {}
if not isinstance(post_json_object['object']['tag'], list):
if not isinstance(post_json_object['object']['attachment'], list):
return {}
links = {}
buy_strings = []
@ -2095,7 +2095,7 @@ def get_buy_links(post_json_object: str, translate: {}, buy_sites: {}) -> {}:
if translate.get(buy_str):
buy_str = translate[buy_str]
buy_strings += buy_str.lower()
for item in post_json_object['object']['tag']:
for item in post_json_object['object']['attachment']:
if not isinstance(item, dict):
continue
if not item.get('name'):