diff options
| author | dakkar <dakkar@thenautilus.net> | 2024-11-27 11:57:19 +0000 |
|---|---|---|
| committer | dakkar <dakkar@thenautilus.net> | 2024-11-27 11:57:19 +0000 |
| commit | 1f53eb2ed15d079492adac70d4501c78936d4e29 (patch) | |
| tree | 8080b371c52efc4c80cf8cc861f642cec01433ce /packages/backend/src/core | |
| parent | merge: Add aliases to webfinger request. (!778) (diff) | |
| download | sharkey-1f53eb2ed15d079492adac70d4501c78936d4e29.tar.gz sharkey-1f53eb2ed15d079492adac70d4501c78936d4e29.tar.bz2 sharkey-1f53eb2ed15d079492adac70d4501c78936d4e29.zip | |
better poll editing - fixes #668
* editing _just the poll_ is now recognised as an actual change to the
note
* the "poll ended" notification job is now replaced (with potentially
the new expiry time)
Diffstat (limited to 'packages/backend/src/core')
| -rw-r--r-- | packages/backend/src/core/NoteCreateService.ts | 1 | ||||
| -rw-r--r-- | packages/backend/src/core/NoteEditService.ts | 8 |
2 files changed, 6 insertions, 3 deletions
diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index 892a929c41..35a2d8e290 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -629,6 +629,7 @@ export class NoteCreateService implements OnApplicationShutdown { this.queueService.endedPollNotificationQueue.add(note.id, { noteId: note.id, }, { + jobId: `pollEnd:${note.id}`, delay, removeOnComplete: true, }); diff --git a/packages/backend/src/core/NoteEditService.ts b/packages/backend/src/core/NoteEditService.ts index e5e3c38cd3..406d134420 100644 --- a/packages/backend/src/core/NoteEditService.ts +++ b/packages/backend/src/core/NoteEditService.ts @@ -471,8 +471,9 @@ export class NoteEditService implements OnApplicationShutdown { const poll = await this.pollsRepository.findOneBy({ noteId: oldnote.id }); 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 }); 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 await this.db.transaction(async transactionalEntityManager => { await transactionalEntityManager.update(MiNote, oldnote.id, note); @@ -605,10 +606,11 @@ export class NoteEditService implements OnApplicationShutdown { if (data.poll && data.poll.expiresAt) { 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, { noteId: note.id, }, { + jobId: `pollEnd:${note.id}`, delay, removeOnComplete: true, }); |