From b39926f117eee6b522f3bca3e8b896dabacf228b Mon Sep 17 00:00:00 2001 From: Hazelnoot Date: Thu, 23 Oct 2025 13:08:29 -0400 Subject: [PATCH] fix timeout in poll notification processor --- .../EndedPollNotificationProcessorService.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/backend/src/queue/processors/EndedPollNotificationProcessorService.ts b/packages/backend/src/queue/processors/EndedPollNotificationProcessorService.ts index 34180e5f2b..f6dbabf2e7 100644 --- a/packages/backend/src/queue/processors/EndedPollNotificationProcessorService.ts +++ b/packages/backend/src/queue/processors/EndedPollNotificationProcessorService.ts @@ -41,17 +41,18 @@ export class EndedPollNotificationProcessorService { const votes = await this.pollVotesRepository.createQueryBuilder('vote') .select('vote.userId') + .groupBy('vote.userId') .where('vote.noteId = :noteId', { noteId: note.id }) - .innerJoinAndSelect('vote.user', 'user') - .andWhere('user.host IS NULL') - .getMany(); + .getRawMany() as { vote_userId: string }[]; - const userIds = [...new Set([note.userId, ...votes.map(v => v.userId)])]; + const userIds = new Set(votes.map(v => v.vote_userId)); + userIds.add(note.id); - for (const userId of userIds) { - const profile = await this.cacheService.userProfileCache.fetch(userId); - if (profile.userHost === null) { - this.notificationService.createNotification(userId, 'pollEnded', { + const users = await this.cacheService.findUsersById(userIds); + + for (const user of users.values()) { + if (user.host == null) { + this.notificationService.createNotification(user.id, 'pollEnded', { noteId: note.id, }); }