comments implement
This commit is contained in:
1 parent
9e0bef2527
commit
4b6ecfbf5d
41 files changed
+1350
-13
No files matched your search
+28
@@ -0,0 +1,28 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { filter, type Observable } from 'rxjs';
|
||||
import { ISSUE_REPOSITORY, type IIssueRepository } from '../../../../issue/domain/repositories/issue.repository.interface.js';
|
||||
import { IssueNotFoundException } from '../../../../issue/domain/exceptions/issue-not-found.exception.js';
|
||||
import { WatchIssueCommentsQuery } from './watch-issue-comments.query.js';
|
||||
import { type CommentEvent, CommentEventsService } from '../../services/comment-events.service.js';
|
||||
|
||||
/**
|
||||
* Поток событий комментариев одной задачи для SSE. Доступ к задаче
|
||||
* проверяется один раз — при подключении.
|
||||
*/
|
||||
@Injectable()
|
||||
export class WatchIssueCommentsUseCase {
|
||||
constructor(
|
||||
@Inject(ISSUE_REPOSITORY)
|
||||
private readonly issueRepository: IIssueRepository,
|
||||
private readonly commentEventsService: CommentEventsService,
|
||||
) {}
|
||||
|
||||
async execute(query: WatchIssueCommentsQuery): Promise<Observable<CommentEvent>> {
|
||||
const issue = await this.issueRepository.findById(query.issueId, query.userId);
|
||||
if (!issue) {
|
||||
throw new IssueNotFoundException(query.issueId);
|
||||
}
|
||||
|
||||
return this.commentEventsService.onEvents().pipe(filter((event) => event.comment.issueId === query.issueId));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user