Don't expire idempotency cache for five minutes.
This commit is contained in:
		
							parent
							
								
									fcd3eca167
								
							
						
					
					
						commit
						90c4bed0af
					
				
					 2 changed files with 6 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -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)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue