Files
task-stream/libs/api/tracker/application/src/lib/commands/assign-issue.command-handler.ts
2026-10-03 13:40:26 +02:00

24 lines
813 B
TypeScript

import { CommandHandler, ICommandHandler } from '@nestjs/cqrs';
import { CommandResult, ack } from './command-result';
import { AssignIssueCommand } from './assign-issue.command';
import { WriteAccess } from './write-access';
@CommandHandler(AssignIssueCommand)
export class AssignIssueCommandHandler
implements ICommandHandler<AssignIssueCommand>
{
constructor(private readonly access: WriteAccess) {}
async execute(command: AssignIssueCommand): Promise<CommandResult> {
const { issue, project } = await this.access.issueForContributor(
command.issueId,
command.actorId,
);
if (command.assigneeId)
this.access.assertAssignable(project, command.assigneeId);
issue.assign(command.actorId, command.assigneeId);
await issue.commitAndWait();
return ack(issue);
}
}