issue observers Наблюдатели задачи видят её и комментируют, но не редактируют. - таблица issue_observer, наблюдатели — часть сущности Issue - видимость: reporter, assignee или наблюдатель (задачи, история, SSE) - правка/удаление задачи и вложений — только reporter/assignee (403 наблюдателю) - observers в create/update, DELETE /issues/:id/observers/me, фильтр role - история изменений и уведомления новым наблюдателям Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
46903e9ec5
commit
b1f6b61994
54 files changed
+901
-69
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { ISSUE_REPOSITORY, type IIssueRepository } from '../../../domain/repositories/issue.repository.interface.js';
|
||||
import { IssueNotFoundException } from '../../../domain/exceptions/issue-not-found.exception.js';
|
||||
import { IssueEventsService } from '../../services/issue-events.service.js';
|
||||
import { IssueApplicationMapper } from '../../mappers/issue-application.mapper.js';
|
||||
import { UnobserveIssueCommand } from './unobserve-issue.command.js';
|
||||
|
||||
/**
|
||||
* Наблюдатель сам отписывается от задачи. Редактировать задачу он не может,
|
||||
* поэтому это отдельная операция, а не часть UpdateIssueUseCase.
|
||||
* Повторный вызов (или вызов не наблюдателем) ничего не меняет.
|
||||
*/
|
||||
@Injectable()
|
||||
export class UnobserveIssueUseCase {
|
||||
constructor(
|
||||
@Inject(ISSUE_REPOSITORY)
|
||||
private readonly issueRepository: IIssueRepository,
|
||||
private readonly issueEventsService: IssueEventsService,
|
||||
) {}
|
||||
|
||||
async execute(command: UnobserveIssueCommand): Promise<void> {
|
||||
const issue = await this.issueRepository.findById(command.id, command.userId);
|
||||
|
||||
if (!issue) {
|
||||
throw new IssueNotFoundException(command.id);
|
||||
}
|
||||
|
||||
if (!issue.observers.includes(command.userId)) return;
|
||||
|
||||
issue.removeObserver(command.userId);
|
||||
await this.issueRepository.update(issue, command.userId);
|
||||
|
||||
this.issueEventsService.emitIssueUpdated(IssueApplicationMapper.toDto(issue));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user