From 7bed350a23c8028d279214f1a0b1c344300af133 Mon Sep 17 00:00:00 2001
From: William Pitcock <nenolod@dereferenced.org>
Date: Mon, 6 Aug 2018 06:18:15 +0000
Subject: [PATCH] config: allow relaying to be disabled

---
 config/config.exs         |  1 +
 lib/pleroma/web/router.ex | 11 +++++++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/config/config.exs b/config/config.exs
index 3a7301348..f3102aea3 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -59,6 +59,7 @@ config :pleroma, :instance,
   upload_limit: 16_000_000,
   registrations_open: true,
   federating: true,
+  allow_relay: true,
   rewrite_policy: Pleroma.Web.ActivityPub.MRF.NoOpPolicy,
   public: true,
   quarantined_instances: []
diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex
index 1f9bccf55..fc9d2d988 100644
--- a/lib/pleroma/web/router.ex
+++ b/lib/pleroma/web/router.ex
@@ -5,6 +5,7 @@ defmodule Pleroma.Web.Router do
 
   @instance Application.get_env(:pleroma, :instance)
   @federating Keyword.get(@instance, :federating)
+  @allow_relay Keyword.get(@instance, :allow_relay)
   @public Keyword.get(@instance, :public)
   @registrations_open Keyword.get(@instance, :registrations_open)
 
@@ -318,10 +319,12 @@ defmodule Pleroma.Web.Router do
   end
 
   if @federating do
-    scope "/", Pleroma.Web.ActivityPub do
-      # XXX: not really ostatus either
-      pipe_through(:ostatus)
-      get("/", ActivityPubController, :relay)
+    if @allow_relay do
+      scope "/", Pleroma.Web.ActivityPub do
+        # XXX: not really ostatus either
+        pipe_through(:ostatus)
+        get("/", ActivityPubController, :relay)
+      end
     end
 
     scope "/", Pleroma.Web.ActivityPub do