diff options
author | lain <lain@soykaf.club> | 2019-12-09 15:10:05 +0000 |
---|---|---|
committer | lain <lain@soykaf.club> | 2019-12-09 15:10:05 +0000 |
commit | 0d2c13a119302d0d217a7cb61c28a01c620b1b61 (patch) | |
tree | 0c9e56997cf99a4f81679bbf1c01c2d13533996b | |
parent | b3c80b840445e4041042e140e3e2f58faa32f4f9 (diff) | |
parent | 3c45ed4f4752bb2dce3ca2e9a153cb278df685fb (diff) | |
download | pleroma-0d2c13a119302d0d217a7cb61c28a01c620b1b61.tar.gz pleroma-0d2c13a119302d0d217a7cb61c28a01c620b1b61.zip |
Merge branch 'fix/otp-parsers' into 'develop'
OTP: Fix runtime upload limit config being ignored
Closes #1109
See merge request pleroma/pleroma!2045
-rw-r--r-- | lib/pleroma/plugs/parsers_plug.ex | 21 | ||||
-rw-r--r-- | lib/pleroma/web/endpoint.ex | 9 |
2 files changed, 22 insertions, 8 deletions
diff --git a/lib/pleroma/plugs/parsers_plug.ex b/lib/pleroma/plugs/parsers_plug.ex new file mode 100644 index 000000000..2e493ce0e --- /dev/null +++ b/lib/pleroma/plugs/parsers_plug.ex @@ -0,0 +1,21 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Plugs.Parsers do + @moduledoc "Initializes Plug.Parsers with upload limit set at boot time" + + @behaviour Plug + + def init(_opts) do + Plug.Parsers.init( + parsers: [:urlencoded, :multipart, :json], + pass: ["*/*"], + json_decoder: Jason, + length: Pleroma.Config.get([:instance, :upload_limit]), + body_reader: {Pleroma.Web.Plugs.DigestPlug, :read_body, []} + ) + end + + defdelegate call(conn, opts), to: Plug.Parsers +end diff --git a/lib/pleroma/web/endpoint.ex b/lib/pleroma/web/endpoint.ex index 49735b5c2..bbea31682 100644 --- a/lib/pleroma/web/endpoint.ex +++ b/lib/pleroma/web/endpoint.ex @@ -61,14 +61,7 @@ defmodule Pleroma.Web.Endpoint do plug(Plug.RequestId) plug(Plug.Logger) - plug( - Plug.Parsers, - parsers: [:urlencoded, :multipart, :json], - pass: ["*/*"], - json_decoder: Jason, - length: Pleroma.Config.get([:instance, :upload_limit]), - body_reader: {Pleroma.Web.Plugs.DigestPlug, :read_body, []} - ) + plug(Pleroma.Plugs.Parsers) plug(Plug.MethodOverride) plug(Plug.Head) |