server: re-fetch poll votes before end notif
This commit is contained in:
parent
650869e2f7
commit
6ce067af56
1 changed files with 5 additions and 0 deletions
|
@ -2,6 +2,8 @@ import Bull from 'bull';
|
||||||
import { Notes, PollVotes } from '@/models/index.js';
|
import { Notes, PollVotes } from '@/models/index.js';
|
||||||
import { EndedPollNotificationJobData } from '@/queue/types.js';
|
import { EndedPollNotificationJobData } from '@/queue/types.js';
|
||||||
import { createNotification } from '@/services/create-notification.js';
|
import { createNotification } from '@/services/create-notification.js';
|
||||||
|
import { Resolver } from '@/remote/activitypub/resolver.js';
|
||||||
|
import { updateQuestion } from '@/remote/activitypub/models/question.js';
|
||||||
|
|
||||||
export async function endedPollNotification(job: Bull.Job<EndedPollNotificationJobData>, done: any): Promise<void> {
|
export async function endedPollNotification(job: Bull.Job<EndedPollNotificationJobData>, done: any): Promise<void> {
|
||||||
const note = await Notes.findOneBy({ id: job.data.noteId });
|
const note = await Notes.findOneBy({ id: job.data.noteId });
|
||||||
|
@ -10,6 +12,9 @@ export async function endedPollNotification(job: Bull.Job<EndedPollNotificationJ
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get the (final) numbers of votes
|
||||||
|
await updateQuestion(note.uri, new Resolver());
|
||||||
|
|
||||||
const votes = await PollVotes.createQueryBuilder('vote')
|
const votes = await PollVotes.createQueryBuilder('vote')
|
||||||
.select('vote.userId')
|
.select('vote.userId')
|
||||||
.where('vote.noteId = :noteId', { noteId: note.id })
|
.where('vote.noteId = :noteId', { noteId: note.id })
|
||||||
|
|
Loading…
Reference in a new issue