Don't expire idempotency cache for five minutes.
authorlain <lain@soykaf.club>
Fri, 4 May 2018 19:15:39 +0000 (21:15 +0200)
committerlain <lain@soykaf.club>
Fri, 4 May 2018 19:15:39 +0000 (21:15 +0200)
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
test/web/mastodon_api/mastodon_api_controller_test.exs

index e2243538a361f02cf82cb72dd993840d5a7da022..bbd16482a52bca3d4a74c98cd823b957492f077e 100644 (file)
@@ -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
 
index 432dca28a4aa6224eb562dfc1b1942faa7c5ad4d..69a0299acf19bd37251a8b777ed88296f689e12e 100644 (file)
@@ -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)