Add a buy button for support links on videos

main
Bob Mottram 2023-10-29 20:00:43 +00:00
parent b829e9a348
commit 450a1da8b6
2 changed files with 18 additions and 8 deletions

View File

@ -177,13 +177,23 @@ def convert_video_to_note(base_dir: str, nickname: str, domain: str,
} }
if post_json_object.get('support'): if post_json_object.get('support'):
if isinstance(post_json_object['support'], str): support_str = post_json_object['support']
if not dangerous_markup(post_json_object['support'], if isinstance(support_str, str):
False, []): if not dangerous_markup(support_str, False, []):
if not is_filtered(base_dir, nickname, domain, if not is_filtered(base_dir, nickname, domain, support_str,
post_json_object['support'],
system_language): system_language):
new_post['object']['support'] = \ new_post['object']['support'] = support_str
post_json_object['support'] # if this is a link
if ' ' not in support_str and \
'://' in support_str and \
'.' in support_str:
# add a buy link
new_post['object']['attachment'].append({
'type': 'Link',
'mediaType': 'html',
'href': support_str,
'rel': 'support',
'name': 'Support'
})
return new_post return new_post

View File

@ -2319,7 +2319,7 @@ def get_buy_links(post_json_object: str, translate: {}, buy_sites: {}) -> {}:
if item.get('rel'): if item.get('rel'):
if isinstance(item['rel'], str): if isinstance(item['rel'], str):
if item['rel'] in ('payment', 'pay', 'donate', 'donation', if item['rel'] in ('payment', 'pay', 'donate', 'donation',
'buy', 'purchase'): 'buy', 'purchase', 'support'):
links[item_name] = remove_html(item['href']) links[item_name] = remove_html(item['href'])
continue continue
if buy_sites: if buy_sites: