fix timeout in poll notification processor

This commit is contained in:
Hazelnoot 2025-10-23 13:08:29 -04:00
parent 68a3b4293c
commit b39926f117

View file

@ -41,17 +41,18 @@ export class EndedPollNotificationProcessorService {
const votes = await this.pollVotesRepository.createQueryBuilder('vote') const votes = await this.pollVotesRepository.createQueryBuilder('vote')
.select('vote.userId') .select('vote.userId')
.groupBy('vote.userId')
.where('vote.noteId = :noteId', { noteId: note.id }) .where('vote.noteId = :noteId', { noteId: note.id })
.innerJoinAndSelect('vote.user', 'user') .getRawMany() as { vote_userId: string }[];
.andWhere('user.host IS NULL')
.getMany();
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 users = await this.cacheService.findUsersById(userIds);
const profile = await this.cacheService.userProfileCache.fetch(userId);
if (profile.userHost === null) { for (const user of users.values()) {
this.notificationService.createNotification(userId, 'pollEnded', { if (user.host == null) {
this.notificationService.createNotification(user.id, 'pollEnded', {
noteId: note.id, noteId: note.id,
}); });
} }