Skip to content

Commit

Permalink
fix: getParticipants if NEVER
Browse files Browse the repository at this point in the history
  • Loading branch information
Morphclue committed Feb 17, 2024
1 parent 3d921e6 commit 7bb1908
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions apps/backend/src/poll/poll/poll.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,20 @@ export class PollService implements OnModuleInit {
if (!poll) {
throw new NotFoundException(id);
}

const participants = await this.participantModel.find({
poll: new Types.ObjectId(id),
token: poll.settings.showResult === ShowResultOptions.NEVER ? token : {$ne: token},
}).select(readParticipantSelect).exec();
const currentParticipant = await this.participantModel.find({
poll: new Types.ObjectId(id),
token,
}).exec();
return [...participants, ...currentParticipant];

if (await this.isAdmin(id, token) || poll.settings.showResult !== ShowResultOptions.NEVER) {
const participants = await this.participantModel.find({
poll: new Types.ObjectId(id),
token: {$ne: token},
}).select(readParticipantSelect).exec();
return [...participants, ...currentParticipant];
}

return [...currentParticipant];
}

async findAllParticipants(poll: Types.ObjectId): Promise<Participant[]> {
Expand Down

0 comments on commit 7bb1908

Please sign in to comment.