diff --git a/apps/core/src/modules/note/note.service.ts b/apps/core/src/modules/note/note.service.ts index cafe8548..0907e90b 100644 --- a/apps/core/src/modules/note/note.service.ts +++ b/apps/core/src/modules/note/note.service.ts @@ -201,10 +201,10 @@ export class NoteService { } scheduleManager.schedule(async () => { - this.eventManager.emit(EventBusEvents.CleanAggregateCache, null, { - scope: EventScope.TO_SYSTEM, - }) await Promise.all([ + this.eventManager.emit(EventBusEvents.CleanAggregateCache, null, { + scope: EventScope.TO_SYSTEM, + }), this.imageService.saveImageDimensionsFromMarkdownText( updated.text, updated.images, @@ -223,37 +223,40 @@ export class NoteService { .exec() }, ), - async () => { - if (!updated) { - return - } - - this.eventManager.broadcast(BusinessEvents.NOTE_UPDATE, updated, { - scope: EventScope.TO_SYSTEM, - }) - - if (updated.password || updated.hide || updated.secret) { - return - } - this.eventManager.broadcast( - BusinessEvents.NOTE_UPDATE, - { - ...updated, - text: await this.textMacrosService.replaceTextMacro( - updated.text, - updated, - ), - }, - { - scope: EventScope.TO_VISITOR, - }, - ) - }, ]) }) + + await this.boardcaseNoteUpdateEvent(updated) + return updated } + private async boardcaseNoteUpdateEvent(updated: NoteModel) { + if (!updated) { + return + } + this.eventManager.broadcast(BusinessEvents.NOTE_UPDATE, updated, { + scope: EventScope.TO_SYSTEM, + }) + + if (updated.password || updated.hide || updated.secret) { + return + } + this.eventManager.broadcast( + BusinessEvents.NOTE_UPDATE, + { + ...updated, + text: await this.textMacrosService.replaceTextMacro( + updated.text, + updated, + ), + }, + { + scope: EventScope.TO_VISITOR, + }, + ) + } + async deleteById(id: string) { const doc = await this.noteModel.findById(id) if (!doc) { diff --git a/apps/core/src/modules/user/user.controller.ts b/apps/core/src/modules/user/user.controller.ts index c33d8b6c..0b1b3a15 100644 --- a/apps/core/src/modules/user/user.controller.ts +++ b/apps/core/src/modules/user/user.controller.ts @@ -54,13 +54,14 @@ export class UserController { @CurrentUserToken() token: string, ) { await this.userService.recordFootstep(ipLocation.ip) + const singedToken = await this.authService.jwtServicePublic.sign(user.id, { + ip: ipLocation.ip, + ua: ipLocation.agent, + }) + + this.authService.jwtServicePublic.revokeToken(token, 6000) return { - token: await this.authService.jwtServicePublic - .sign(user.id, { - ip: ipLocation.ip, - ua: ipLocation.agent, - }) - .then(() => this.authService.jwtServicePublic.revokeToken(token, 6000)), + token: singedToken, } }