first commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs';
|
||||
import { CommandResult, ack } from './command-result';
|
||||
import { SetIssueReleaseCommand } from './set-issue-release.command';
|
||||
import { WriteAccess } from './write-access';
|
||||
|
||||
@CommandHandler(SetIssueReleaseCommand)
|
||||
export class SetIssueReleaseCommandHandler
|
||||
implements ICommandHandler<SetIssueReleaseCommand>
|
||||
{
|
||||
constructor(private readonly access: WriteAccess) {}
|
||||
|
||||
async execute(command: SetIssueReleaseCommand): Promise<CommandResult> {
|
||||
const { issue, project } = await this.access.issueForContributor(
|
||||
command.issueId,
|
||||
command.actorId,
|
||||
);
|
||||
// Neither the old nor the new release may be already shipped.
|
||||
if (issue.releaseId)
|
||||
await this.access.openReleaseOf(project, issue.releaseId);
|
||||
if (command.releaseId)
|
||||
await this.access.openReleaseOf(project, command.releaseId);
|
||||
issue.setRelease(command.actorId, command.releaseId);
|
||||
await issue.commitAndWait();
|
||||
return ack(issue);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user