@@ -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) {
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user