validate using org_id
All checks were successful
Build and Publish / build-release (push) Successful in 1m21s

This commit is contained in:
2026-05-15 14:16:43 -05:00
parent c371191bd8
commit 81a89c0151
2 changed files with 4 additions and 41 deletions

View File

@@ -218,29 +218,10 @@ defmodule CustomerServiceWeb.CustomerController do
end
end
defp dispatch_and_return(conn, command, %CustomerId{} = customer_id) do
defp dispatch_and_return(conn, command, %CustomerId{org_id: org_id} = customer_id) do
case CustomerService.CommandedApp.dispatch(command, consistency: :strong) do
:ok ->
case CustomerQueries.get_customer(to_string(customer_id)) do
{:ok, customer} ->
conn |> put_status(:ok) |> json(%{data: customer_json(customer)})
{:error, :not_found} ->
conn
|> put_status(:internal_server_error)
|> json(%{error: "customer 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, customer_id_string)
when is_binary(customer_id_string) do
case CustomerService.CommandedApp.dispatch(command, consistency: :strong) do
:ok ->
case CustomerQueries.get_customer(customer_id_string) do
case CustomerQueries.get_customer(org_id, to_string(customer_id)) do
{:ok, customer} ->
conn |> put_status(:ok) |> json(%{data: customer_json(customer)})