From 0df59c3ee9b132227fb8e5f8803b1921a78fa857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= Date: Sat, 17 Jun 2023 10:57:16 +0300 Subject: [PATCH] Updated for GmCapsule v0.5 API changes Check if background work can be started. --- 50_bubble.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/50_bubble.py b/50_bubble.py index 7e8f062..47774df 100644 --- a/50_bubble.py +++ b/50_bubble.py @@ -619,8 +619,8 @@ when the administrator assigns at least one moderator to it. return make_feed_page(session) -def init(capsule): - cfg = capsule.config() +def init(context): + cfg = context.config() try: mod_cfg = cfg.section('bubble') @@ -636,15 +636,16 @@ def init(capsule): port = cfg.section('server').getint('port', 1965) for hostname in hostnames: - responder = Bubble(capsule, hostname, port, path, mod_cfg) - capsule.add(path + '*', responder, hostname, protocol='gemini') - capsule.add(path + '*', responder, hostname, protocol='titan') + responder = Bubble(context, hostname, port, path, mod_cfg) + context.add(path + '*', responder, hostname, protocol='gemini') + context.add(path + '*', responder, hostname, protocol='titan') - emailer = Emailer(capsule, hostnames[0], port, mod_cfg) - emailer.start() + if context.is_background_work_allowed(): + emailer = Emailer(context, hostnames[0], port, mod_cfg) + emailer.start() - fetcher = RepoFetcher(capsule, mod_cfg) - fetcher.start() + fetcher = RepoFetcher(context, mod_cfg) + fetcher.start() except KeyError: pass