aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/web.ex
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2020-05-08 21:37:55 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2020-05-08 21:37:55 +0300
commitb2924ab1fbba4e6add15030cf8444d2d3f0cfe0c (patch)
tree000420341c4397cb7e380ff6fa52bb023700476a /lib/pleroma/web/web.ex
parentd5cdc907e3fda14c2ce78ddbb124739441330ecc (diff)
parent570940a3fd8d5a2fb600656432dfc01304161221 (diff)
downloadpleroma-b2924ab1fbba4e6add15030cf8444d2d3f0cfe0c.tar.gz
Merge remote-tracking branch 'remotes/origin/develop' into restricted-relations-embedding
Diffstat (limited to 'lib/pleroma/web/web.ex')
-rw-r--r--lib/pleroma/web/web.ex10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/pleroma/web/web.ex b/lib/pleroma/web/web.ex
index 08e42a7e5..4f9281851 100644
--- a/lib/pleroma/web/web.ex
+++ b/lib/pleroma/web/web.ex
@@ -200,11 +200,17 @@ defmodule Pleroma.Web do
@impl Plug
@doc """
- If marked as skipped, returns `conn`, otherwise calls `perform/2`.
+ Before-plug hook that
+ * ensures the plug is not skipped
+ * processes `:if_func` / `:unless_func` functional pre-run conditions
+ * adds plug to the list of called plugs and calls `perform/2` if checks are passed
+
Note: multiple invocations of the same plug (with different or same options) are allowed.
"""
def call(%Plug.Conn{} = conn, options) do
- if PlugHelper.plug_skipped?(conn, __MODULE__) do
+ if PlugHelper.plug_skipped?(conn, __MODULE__) ||
+ (options[:if_func] && !options[:if_func].(conn)) ||
+ (options[:unless_func] && options[:unless_func].(conn)) do
conn
else
conn =