View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/783 Closes #668 Approved-by: Hazelnoot <acomputerdog@gmail.com> Approved-by: Marie <github@yuugi.dev>
This commit is contained in:
commit
3a020d53d1
2 changed files with 6 additions and 3 deletions
|
@ -629,6 +629,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
||||||
this.queueService.endedPollNotificationQueue.add(note.id, {
|
this.queueService.endedPollNotificationQueue.add(note.id, {
|
||||||
noteId: note.id,
|
noteId: note.id,
|
||||||
}, {
|
}, {
|
||||||
|
jobId: `pollEnd:${note.id}`,
|
||||||
delay,
|
delay,
|
||||||
removeOnComplete: true,
|
removeOnComplete: true,
|
||||||
});
|
});
|
||||||
|
|
|
@ -471,8 +471,9 @@ export class NoteEditService implements OnApplicationShutdown {
|
||||||
const poll = await this.pollsRepository.findOneBy({ noteId: oldnote.id });
|
const poll = await this.pollsRepository.findOneBy({ noteId: oldnote.id });
|
||||||
|
|
||||||
const oldPoll = poll ? { choices: poll.choices, multiple: poll.multiple, expiresAt: poll.expiresAt } : null;
|
const oldPoll = poll ? { choices: poll.choices, multiple: poll.multiple, expiresAt: poll.expiresAt } : null;
|
||||||
|
const pollChanged = data.poll != null && JSON.stringify(data.poll) !== JSON.stringify(oldPoll);
|
||||||
|
|
||||||
if (Object.keys(update).length > 0 || filesChanged) {
|
if (Object.keys(update).length > 0 || filesChanged || pollChanged) {
|
||||||
const exists = await this.noteEditRepository.findOneBy({ noteId: oldnote.id });
|
const exists = await this.noteEditRepository.findOneBy({ noteId: oldnote.id });
|
||||||
|
|
||||||
await this.noteEditRepository.insert({
|
await this.noteEditRepository.insert({
|
||||||
|
@ -544,7 +545,7 @@ export class NoteEditService implements OnApplicationShutdown {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.poll != null && JSON.stringify(data.poll) !== JSON.stringify(oldPoll)) {
|
if (pollChanged) {
|
||||||
// Start transaction
|
// Start transaction
|
||||||
await this.db.transaction(async transactionalEntityManager => {
|
await this.db.transaction(async transactionalEntityManager => {
|
||||||
await transactionalEntityManager.update(MiNote, oldnote.id, note);
|
await transactionalEntityManager.update(MiNote, oldnote.id, note);
|
||||||
|
@ -605,10 +606,11 @@ export class NoteEditService implements OnApplicationShutdown {
|
||||||
|
|
||||||
if (data.poll && data.poll.expiresAt) {
|
if (data.poll && data.poll.expiresAt) {
|
||||||
const delay = data.poll.expiresAt.getTime() - Date.now();
|
const delay = data.poll.expiresAt.getTime() - Date.now();
|
||||||
this.queueService.endedPollNotificationQueue.remove(note.id);
|
this.queueService.endedPollNotificationQueue.remove(`pollEnd:${note.id}`);
|
||||||
this.queueService.endedPollNotificationQueue.add(note.id, {
|
this.queueService.endedPollNotificationQueue.add(note.id, {
|
||||||
noteId: note.id,
|
noteId: note.id,
|
||||||
}, {
|
}, {
|
||||||
|
jobId: `pollEnd:${note.id}`,
|
||||||
delay,
|
delay,
|
||||||
removeOnComplete: true,
|
removeOnComplete: true,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue