diff --git a/daemon.py b/daemon.py index 4d23b3aee..86cdfd30b 100644 --- a/daemon.py +++ b/daemon.py @@ -178,6 +178,7 @@ from webapp_podcast import html_podcast_episode from webapp_theme_designer import html_theme_designer from webapp_minimalbutton import set_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_avatar_image_url 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) # 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 httpd.min_images_for_accounts = load_min_images_for_accounts(base_dir) diff --git a/webapp_utils.py b/webapp_utils.py index 7d8697990..2c9cf2b48 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -2136,3 +2136,14 @@ def get_buy_links(post_json_object: str, translate: {}, buy_sites: {}) -> {}: links[site.title()] = item['href'] continue 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 {}