add auth
Some checks failed
Build and Publish / build-release (push) Has been cancelled

This commit is contained in:
2026-05-15 10:19:57 -05:00
parent a06c5ece5d
commit c81b1673d4
20 changed files with 488 additions and 76 deletions

View File

@@ -44,6 +44,7 @@ defmodule WorkloadService.Aggregates.Task do
alias unquote(commands_module).CreateTask
alias unquote(commands_module).SubmitResponse
alias unquote(commands_module).RequestApproval
alias unquote(commands_module).ApproveSubmission
alias unquote(commands_module).CompleteTask
@@ -86,6 +87,18 @@ defmodule WorkloadService.Aggregates.Task do
end
end
@impl Aggregate
def execute(%__MODULE__{status: "draft"}, %RequestApproval{} = cmd) do
%WorkloadService.Events.ApprovalRequested{
id: cmd.id
}
end
@impl Aggregate
def execute(%__MODULE__{status: status}, %RequestApproval{}) do
{:error, {:invalid_state, "cannot request approval in state: #{status}"}}
end
@impl Aggregate
def execute(%__MODULE__{id: id, status: "draft"}, %ApproveSubmission{}) do
%WorkloadService.Events.SubmissionApproved{
@@ -141,6 +154,14 @@ defmodule WorkloadService.Aggregates.Task do
}
end
@impl Aggregate
def apply(%__MODULE__{} = agg, %WorkloadService.Events.ApprovalRequested{}) do
%{
agg
| status: "approval_requested"
}
end
@impl Aggregate
def apply(%__MODULE__{} = agg, %WorkloadService.Events.TaskCompleted{}) do
%{