Browse Source

Add federation master switch

pull/38/head
Dashie der otter 7 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"
AP_DOMAIN = "localhost"
SERVER_NAME = AP_DOMAIN
BASE_URL = "https://" + AP_DOMAIN
# Should we enable federation
AP_ENABLED = True

SQLALCHEMY_DATABASE_URI = \
'postgresql+psycopg2://postgres@database/reel2bits'

+ 6
- 0
tasks.py View File

@@ -278,6 +278,9 @@ def finish_post_to_outbox(self, iri: str) -> None:

@celery.task(bind=True, max_retries=3)
def post_to_remote_inbox(self, payload: str, to: str) -> None:
if not current_app.config["AP_ENABLED"]:
return # not federating if not enabled

current_app.logger.debug(f"post_to_remote_inbox {payload}")

ap_actor = json.loads(payload)["actor"]
@@ -323,6 +326,9 @@ def post_to_remote_inbox(self, payload: str, to: str) -> None:

@celery.task(bind=True, max_retries=3)
def forward_activity(self, iri: str) -> None:
if not current_app.config["AP_ENABLED"]:
return # not federating if not enabled

try:
activity = ap.fetch_remote_activity(iri)
backend = ap.get_backend()

+ 1
- 0
tests/config_test.py View File

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

Loading…
Cancel
Save