spc-pleroma/lib/pleroma/plugs/federating_plug.ex

24 lines
540 B
Elixir
Raw Normal View History

# Pleroma: A lightweight social networking server
2020-03-03 22:44:49 +00:00
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
2018-11-05 14:19:03 +00:00
defmodule Pleroma.Web.FederatingPlug do
import Plug.Conn
def init(options) do
options
end
2018-12-09 09:12:48 +00:00
def call(conn, _opts) do
2019-05-30 08:33:58 +00:00
if Pleroma.Config.get([:instance, :federating]) do
2018-11-05 14:19:03 +00:00
conn
else
conn
|> put_status(404)
2018-12-16 16:49:42 +00:00
|> Phoenix.Controller.put_view(Pleroma.Web.ErrorView)
|> Phoenix.Controller.render("404.json")
2018-11-05 14:19:03 +00:00
|> halt()
end
end
end