From: lain Date: Fri, 4 May 2018 19:15:39 +0000 (+0200) Subject: Don't expire idempotency cache for five minutes. X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=90c4bed0af40911e0f8a28743814e4c07e91e9ae;p=akkoma Don't expire idempotency cache for five minutes. --- diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index e2243538a..bbd16482a 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -288,6 +288,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do fallback: fn _ -> CommonAPI.post(user, params) end ) + Cachex.expire(:user_cache, "idem:#{idempotency_key}", :timer.seconds(5 * 60)) + render(conn, StatusView, "status.json", %{activity: activity, for: user, as: :activity}) end diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 432dca28a..69a0299ac 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -75,6 +75,10 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do "sensitive" => "false" }) + {:ok, ttl} = Cachex.ttl(:user_cache, "idem:#{idempotency_key}") + # 5 Minutes + assert ttl > :timer.seconds(5 * 60 - 1) + assert %{"content" => "cofe", "id" => id, "spoiler_text" => "2hu", "sensitive" => false} = json_response(conn_one, 200)