handle application_id correctly
All checks were successful
Build and Publish / build-release (push) Successful in 1m24s

This commit is contained in:
2026-04-17 12:44:02 -05:00
parent 571cc94711
commit 1187b8e1a8
4 changed files with 74 additions and 15 deletions

View File

@@ -5,12 +5,19 @@ defmodule WorkloadService.Events do
"""
alias WorkloadService.Aggregates.TaskId
alias WorkloadService.Aggregates.ApplicationId
defmacro __using__(_opts) do
quote do
defimpl Commanded.Serialization.JsonDecoder do
def decode(%{id: %{org_id: org_id, type: type, task_id: task_id}} = event) do
%{event | id: TaskId.new(org_id, type, task_id)}
event = %{event | id: TaskId.new(org_id, type, task_id)}
if Map.has_key?(event, :application_id) && is_map(event.application_id) do
%{event | application_id: ApplicationId.parse!(event.application_id)}
else
event
end
end
def decode(event), do: event