aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/plugs/federating_plug.ex
blob: 4dc4e927920a9f55af1dbdadbecaf3a442d310e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Pleroma: A lightweight social networking server
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Web.FederatingPlug do
  import Plug.Conn

  def init(options) do
    options
  end

  def call(conn, _opts) do
    if Pleroma.Config.get([:instance, :federating]) do
      conn
    else
      conn
      |> put_status(404)
      |> Phoenix.Controller.put_view(Pleroma.Web.ErrorView)
      |> Phoenix.Controller.render("404.json")
      |> halt()
    end
  end
end