Merge branch 'legal-boilerplate' into 'develop'
[akkoma] / lib / pleroma / plugs / federating_plug.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.FederatingPlug do
6 import Plug.Conn
7
8 def init(options) do
9 options
10 end
11
12 def call(conn, _opts) do
13 if Keyword.get(Application.get_env(:pleroma, :instance), :federating) do
14 conn
15 else
16 conn
17 |> put_status(404)
18 |> Phoenix.Controller.put_view(Pleroma.Web.ErrorView)
19 |> Phoenix.Controller.render("404.json")
20 |> halt()
21 end
22 end
23 end