2019-12-03 11:29:51 +01:00
|
|
|
# Portions of this file are derived from Pleroma:
|
|
|
|
# Pleroma: A lightweight social networking server
|
|
|
|
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-01-23 00:55:07 +01:00
|
|
|
defmodule Mobilizon.Federation.Plugs.Federating do
|
2019-12-03 11:29:51 +01:00
|
|
|
@moduledoc """
|
|
|
|
Restrict ActivityPub routes when not federating
|
|
|
|
"""
|
2020-01-23 00:55:07 +01:00
|
|
|
|
2019-12-03 11:29:51 +01:00
|
|
|
import Plug.Conn
|
|
|
|
|
|
|
|
def init(options) do
|
|
|
|
options
|
|
|
|
end
|
|
|
|
|
|
|
|
def call(conn, _opts) do
|
|
|
|
if Mobilizon.Config.get([:instance, :federating]) do
|
|
|
|
conn
|
|
|
|
else
|
|
|
|
conn
|
|
|
|
|> put_status(404)
|
|
|
|
|> Phoenix.Controller.put_view(MobilizonWeb.ErrorView)
|
|
|
|
|> Phoenix.Controller.render("404.json")
|
|
|
|
|> halt()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|