Load buy sites from file

main
Bob Mottram 2023-01-13 15:16:08 +00:00
parent 2f9a0c7792
commit 9d844e641b
2 changed files with 13 additions and 1 deletions

View File

@ -178,6 +178,7 @@ from webapp_podcast import html_podcast_episode
from webapp_theme_designer import html_theme_designer from webapp_theme_designer import html_theme_designer
from webapp_minimalbutton import set_minimal from webapp_minimalbutton import set_minimal
from webapp_minimalbutton import is_minimal from webapp_minimalbutton import is_minimal
from webapp_utils import load_buy_sites
from webapp_utils import get_default_path from webapp_utils import get_default_path
from webapp_utils import get_avatar_image_url from webapp_utils import get_avatar_image_url
from webapp_utils import html_hashtag_blocked from webapp_utils import html_hashtag_blocked
@ -22983,7 +22984,7 @@ def run_daemon(max_hashtags: int,
assert not scan_themes_for_scripts(base_dir) assert not scan_themes_for_scripts(base_dir)
# permitted sites from which the buy button may be displayed # permitted sites from which the buy button may be displayed
httpd.buy_sites = {} httpd.buy_sites = load_buy_sites(base_dir)
# which accounts should minimize all attached images by default # which accounts should minimize all attached images by default
httpd.min_images_for_accounts = load_min_images_for_accounts(base_dir) httpd.min_images_for_accounts = load_min_images_for_accounts(base_dir)

View File

@ -2136,3 +2136,14 @@ def get_buy_links(post_json_object: str, translate: {}, buy_sites: {}) -> {}:
links[site.title()] = item['href'] links[site.title()] = item['href']
continue continue
return links return links
def load_buy_sites(base_dir: str) -> {}:
"""Loads domains from which buying is permitted
"""
buy_sites_filename = base_dir + '/accounts/buy_sites.txt'
if os.path.isfile(buy_sites_filename):
buy_sites_json = load_json(buy_sites_filename)
if buy_sites_json:
return buy_sites_json
return {}