Skip to content

Commit

Permalink
fix: update subcribers on comment (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
saimanoj authored Dec 9, 2024
1 parent 4adc1ff commit d0de412
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion apps/server/src/modules/issues/issues.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,11 +606,19 @@ export default class IssuesService {
* @returns The updated issue with the new subscriber IDs.
*/
async updateSubscribers(issueId: string, subscriberIds: string[]) {
const issue = await this.prisma.issue.findUnique({
where: { id: issueId },
select: { subscriberIds: true },
});

const allSubscriberIds = [...(issue.subscriberIds || []), ...subscriberIds];
const uniqueSubscriberIds = [...new Set(allSubscriberIds)];

return await this.prisma.issue.update({
where: { id: issueId },
data: {
subscriberIds: {
set: subscriberIds,
set: uniqueSubscriberIds,
},
},
});
Expand Down

0 comments on commit d0de412

Please sign in to comment.