mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-23 19:47:03 -04:00
feat: handle note deletion and permission change via event system
Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
77615f0878
commit
865c70b942
4 changed files with 27 additions and 15 deletions
|
@ -5,9 +5,11 @@
|
|||
*/
|
||||
import { Optional } from '@mrdrogdrog/optional';
|
||||
import { BeforeApplicationShutdown, Inject, Injectable } from '@nestjs/common';
|
||||
import { OnEvent } from '@nestjs/event-emitter';
|
||||
import { SchedulerRegistry } from '@nestjs/schedule';
|
||||
|
||||
import appConfiguration, { AppConfig } from '../../config/app.config';
|
||||
import { NoteEvent } from '../../events';
|
||||
import { ConsoleLoggerService } from '../../logger/console-logger.service';
|
||||
import { Note } from '../../notes/note.entity';
|
||||
import { RevisionsService } from '../../revisions/revisions.service';
|
||||
|
@ -101,4 +103,20 @@ export class RealtimeNoteService implements BeforeApplicationShutdown {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
@OnEvent(NoteEvent.PERMISSION_CHANGE)
|
||||
public handleNotePermissionChanged(noteId: Note['id']): void {
|
||||
const realtimeNote = this.realtimeNoteStore.find(noteId);
|
||||
if (realtimeNote) {
|
||||
realtimeNote.announcePermissionChange();
|
||||
}
|
||||
}
|
||||
|
||||
@OnEvent(NoteEvent.DELETION)
|
||||
public handleNoteDeleted(noteId: Note['id']): void {
|
||||
const realtimeNote = this.realtimeNoteStore.find(noteId);
|
||||
if (realtimeNote) {
|
||||
realtimeNote.announceNoteDeletion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue