Bubble [main]

Updated for GmCapsule v0.5 API changes

0df59c3ee9b132227fb8e5f8803b1921a78fa857
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