In the end I just used after_action, the only “issue” was to update an attribute that was just created but not persisted to db yet.
This did the magic
|> Ash.Changeset.force_set_argument(:email_response, email_response)
case Mailer.deliver(email) do
{:ok, resp} ->
case resp do
{status, body} when is_integer(status) and is_binary(body) ->
email_response = %{status: status, response: Jason.decode!(body)}
updated_changeset =
Ash.Changeset.for_update(result, :update, %{})
|> Ash.Changeset.force_set_argument(:email_response, email_response)
IO.inspect(updated_changeset)
case Eppa.Accounts.update(updated_changeset) do
{:ok, updated_result} ->
IO.inspect(updated_result,
label: "Registro actualizado con email_response"
)
{:ok, result}
{:error, err} ->
IO.inspect(err, label: "Error al actualizar email_response")
{:error, err}
end
other ->
other
end
{:error, reason} ->
IO.inspect(reason, label: "Error al enviar correo")
{:ok, %{error: reason}}
end


















