From 54b00ff9893ccf31cab0aa13907d43462b45b738 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 27 Sep 2019 16:18:29 +0200 Subject: [PATCH] Add config option to disable federation Closes #148 Signed-off-by: Thomas Citharel --- config/config.exs | 2 ++ lib/service/activity_pub/utils.ex | 16 +++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/config/config.exs b/config/config.exs index be2bc7cca..85c698b0e 100644 --- a/config/config.exs +++ b/config/config.exs @@ -17,6 +17,8 @@ config :mobilizon, :instance, registrations_open: System.get_env("MOBILIZON_INSTANCE_REGISTRATIONS_OPEN") || false, repository: Mix.Project.config()[:source_url], allow_relay: true, + # Federation is to be activated with Mobilizon 1.0.0-beta.2 + federating: false, remote_limit: 100_000, upload_limit: 16_000_000, avatar_upload_limit: 2_000_000, diff --git a/lib/service/activity_pub/utils.ex b/lib/service/activity_pub/utils.ex index 565aafe9f..24e76bd0e 100644 --- a/lib/service/activity_pub/utils.ex +++ b/lib/service/activity_pub/utils.ex @@ -58,14 +58,16 @@ defmodule Mobilizon.Service.ActivityPub.Utils do def maybe_federate(%Activity{local: true} = activity) do Logger.debug("Maybe federate an activity") - priority = - case activity.data["type"] do - "Delete" -> 10 - "Create" -> 1 - _ -> 5 - end + if Mobilizon.Config.get!([:instance, :federating]) do + priority = + case activity.data["type"] do + "Delete" -> 10 + "Create" -> 1 + _ -> 5 + end - Federator.enqueue(:publish, activity, priority) + Federator.enqueue(:publish, activity, priority) + end :ok end