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

19 lines
720 B
TypeScript

import { CommandHandler, ICommandHandler } from '@nestjs/cqrs';
import { CommandResult, ack } from './command-result';
import { RemoveProjectMemberCommand } from './remove-project-member.command';
import { WriteAccess } from './write-access';
@CommandHandler(RemoveProjectMemberCommand)
export class RemoveProjectMemberCommandHandler
implements ICommandHandler<RemoveProjectMemberCommand>
{
constructor(private readonly access: WriteAccess) {}
async execute(command: RemoveProjectMemberCommand): Promise<CommandResult> {
const project = await this.access.project(command.projectId);
project.removeMember(command.actorId, command.userId);
await project.commitAndWait();
return ack(project);
}
}