validate using org_id
All checks were successful
Build and Publish / build-release (push) Successful in 1m21s
All checks were successful
Build and Publish / build-release (push) Successful in 1m21s
This commit is contained in:
@@ -176,28 +176,10 @@ defmodule CustomerServiceWeb.LeadController do
|
||||
end
|
||||
end
|
||||
|
||||
defp dispatch_and_return(conn, command, %LeadId{} = lead_id) do
|
||||
defp dispatch_and_return(conn, command, %LeadId{org_id: org_id} = lead_id) do
|
||||
case CustomerService.CommandedApp.dispatch(command, consistency: :strong) do
|
||||
:ok ->
|
||||
case LeadQueries.get_lead(to_string(lead_id)) do
|
||||
{:ok, lead} ->
|
||||
conn |> put_status(:ok) |> json(%{data: lead_json(lead)})
|
||||
|
||||
{:error, :not_found} ->
|
||||
conn
|
||||
|> put_status(:internal_server_error)
|
||||
|> json(%{error: "lead created but not found in projection"})
|
||||
end
|
||||
|
||||
{:error, reason} ->
|
||||
conn |> put_status(:unprocessable_entity) |> json(%{error: inspect(reason)})
|
||||
end
|
||||
end
|
||||
|
||||
defp dispatch_and_return(conn, command, lead_id_string) when is_binary(lead_id_string) do
|
||||
case CustomerService.CommandedApp.dispatch(command, consistency: :strong) do
|
||||
:ok ->
|
||||
case LeadQueries.get_lead(lead_id_string) do
|
||||
case LeadQueries.get_lead(org_id, to_string(lead_id)) do
|
||||
{:ok, lead} ->
|
||||
conn |> put_status(:ok) |> json(%{data: lead_json(lead)})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user