X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Fplugs%2Fidempotency_plug.ex;h=9ac8f3647098dd76de1e2d3bcaa7ed7637cc0974;hb=ac3b5037219f75c0dcec424052dab2e2e65149bd;hp=f413970751bc4361423af16a7cfe90fb8fca74dc;hpb=2501793f819813d792fdae493fb0f1e65c6cc7b3;p=akkoma
diff --git a/lib/pleroma/web/plugs/idempotency_plug.ex b/lib/pleroma/web/plugs/idempotency_plug.ex
index f41397075..9ac8f3647 100644
--- a/lib/pleroma/web/plugs/idempotency_plug.ex
+++ b/lib/pleroma/web/plugs/idempotency_plug.ex
@@ -1,13 +1,15 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
-defmodule Pleroma.Plugs.IdempotencyPlug do
+defmodule Pleroma.Web.Plugs.IdempotencyPlug do
import Phoenix.Controller, only: [json: 2]
import Plug.Conn
@behaviour Plug
+ @cachex Pleroma.Config.get([:cachex, :provider], Cachex)
+
@impl true
def init(opts), do: opts
@@ -25,7 +27,7 @@ defmodule Pleroma.Plugs.IdempotencyPlug do
def call(conn, _), do: conn
def process_request(conn, key) do
- case Cachex.get(:idempotency_cache, key) do
+ case @cachex.get(:idempotency_cache, key) do
{:ok, nil} ->
cache_resposnse(conn, key)
@@ -43,7 +45,7 @@ defmodule Pleroma.Plugs.IdempotencyPlug do
content_type = get_content_type(conn)
record = {request_id, content_type, conn.status, conn.resp_body}
- {:ok, _} = Cachex.put(:idempotency_cache, key, record)
+ {:ok, _} = @cachex.put(:idempotency_cache, key, record)
conn
|> put_resp_header("idempotency-key", key)