Commit 90c4bed0 authored by lain's avatar lain
Browse files

Don't expire idempotency cache for five minutes.

parent fcd3eca1
Pipeline #1615 passed with stages
in 4 minutes and 37 seconds
......@@ -288,6 +288,8 @@ def post_status(%{assigns: %{user: user}} = conn, %{"status" => _} = params) 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
......
......@@ -75,6 +75,10 @@ test "posting a status", %{conn: conn} 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)
......
  • 5 minutes is pretty short. I would have gone 24h to be truly safe.

Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment