first commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs';
|
||||
import { AddProjectMemberCommand } from './add-project-member.command';
|
||||
import { CommandResult, ack } from './command-result';
|
||||
import { WriteAccess } from './write-access';
|
||||
|
||||
@CommandHandler(AddProjectMemberCommand)
|
||||
export class AddProjectMemberCommandHandler
|
||||
implements ICommandHandler<AddProjectMemberCommand>
|
||||
{
|
||||
constructor(private readonly access: WriteAccess) {}
|
||||
|
||||
async execute(command: AddProjectMemberCommand): Promise<CommandResult> {
|
||||
const project = await this.access.project(command.projectId);
|
||||
await this.access.assertKnownActiveUser(
|
||||
command.userId,
|
||||
command.accessToken,
|
||||
);
|
||||
project.addMember(command.actorId, command.userId, command.role);
|
||||
await project.commitAndWait();
|
||||
return ack(project);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user