Browse Source

Add federation master switch

pull/38/head
Dashie der otter 3 months ago
parent
commit
e84a0f81cc
Signed by: Dashie <dashie@sigpipe.me> GPG Key ID: C2D57B325840B755
3 changed files with 9 additions and 0 deletions
  1. 2
    0
      config.py.sample
  2. 6
    0
      tasks.py
  3. 1
    0
      tests/config_test.py

+ 2
- 0
config.py.sample View File

@@ -21,6 +21,8 @@ CELERY_RESULT_BACKEND = "redis://127.0.0.1:6379/0"
21 21
 AP_DOMAIN = "localhost"
22 22
 SERVER_NAME = AP_DOMAIN
23 23
 BASE_URL = "https://" + AP_DOMAIN
24
+# Should we enable federation
25
+AP_ENABLED = True
24 26
 
25 27
 SQLALCHEMY_DATABASE_URI = \
26 28
     'postgresql+psycopg2://postgres@database/reel2bits'

+ 6
- 0
tasks.py View File

@@ -278,6 +278,9 @@ def finish_post_to_outbox(self, iri: str) -> None:
278 278
 
279 279
 @celery.task(bind=True, max_retries=3)
280 280
 def post_to_remote_inbox(self, payload: str, to: str) -> None:
281
+    if not current_app.config["AP_ENABLED"]:
282
+        return  # not federating if not enabled
283
+
281 284
     current_app.logger.debug(f"post_to_remote_inbox {payload}")
282 285
 
283 286
     ap_actor = json.loads(payload)["actor"]
@@ -323,6 +326,9 @@ def post_to_remote_inbox(self, payload: str, to: str) -> None:
323 326
 
324 327
 @celery.task(bind=True, max_retries=3)
325 328
 def forward_activity(self, iri: str) -> None:
329
+    if not current_app.config["AP_ENABLED"]:
330
+        return  # not federating if not enabled
331
+
326 332
     try:
327 333
         activity = ap.fetch_remote_activity(iri)
328 334
         backend = ap.get_backend()

+ 1
- 0
tests/config_test.py View File

@@ -55,3 +55,4 @@ BCRYPT_LOG_ROUNDS = 4
55 55
 AP_DOMAIN = "localhost"
56 56
 SERVER_NAME = AP_DOMAIN
57 57
 BASE_URL = "https://" + AP_DOMAIN
58
+AP_ENABLED = True

Loading…
Cancel
Save