Skip to content

Commit

Permalink
[ZARS-645][ADD] rework status check for tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
af-ak committed Dec 4, 2023
1 parent ae3e694 commit 903e89a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/modules/comment/comment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { ValidationGroup } from './enums/validation-group.enum';
import { Answer } from './schema/answer.schema';
import { validateIsDoneAccess } from './utils/is-done-access.util';
import { ProposalCrudService } from '../proposal/services/proposal-crud.service';
import { ProposalStatus } from '../proposal/enums/proposal-status.enum';

@Injectable()
export class CommentService {
Expand Down Expand Up @@ -142,9 +143,18 @@ export class CommentService {
const filter: FilterQuery<Comment> = {
...commentReference,
};

if (user.singleKnownRole === Role.Researcher) {
const projection = { status: 1 };
const proposal = await this.proposalCrudService.findDocument(
commentReference.referenceDocumentId,
user,
projection,
false,
);

if (user.singleKnownRole === Role.Researcher && proposal.status === ProposalStatus.Rework) {
filter.type = { $in: [CommentType.ProposalMessageToOwner, CommentType.ProposalTask] };
} else if (user.singleKnownRole === Role.Researcher) {
filter.type = { $in: [CommentType.ProposalMessageToOwner] };
} else if (user.isFromLocation) {
filter.type = { $in: [CommentType.ProposalMessageToLocation, CommentType.ProposalTaskFdpg] };
filter.locations = { $in: [user.miiLocation, MiiLocation.VirtualAll] };
Expand Down

0 comments on commit 903e89a

Please sign in to comment.