Skip to content

Commit 96f8f06

Browse files
committed
Disconnect online users by delete API
Signed-off-by: James Tsai <jamesscamel@gmail.com>
1 parent cf1a25a commit 96f8f06

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/note/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const { Note, User } = require('../models')
77
const { newCheckViewPermission, errorForbidden, responseCodiMD, errorNotFound, errorInternalError } = require('../response')
88
const { updateHistory, historyDelete } = require('../history')
99
const { actionPublish, actionSlide, actionInfo, actionDownload, actionPDF, actionGist, actionRevision, actionPandoc } = require('./noteActions')
10+
const realtime = require('../realtime/realtime')
1011

1112
async function getNoteById (noteId, { includeUser } = { includeUser: false }) {
1213
const id = await Note.parseNoteIdAsync(noteId)
@@ -246,7 +247,14 @@ const deleteNote = async (req, res) => {
246247
logger.error('Delete note failed: Make sure the noteId and ownerId are correct.')
247248
return errorNotFound(req, res)
248249
}
250+
249251
historyDelete(req, res)
252+
253+
if (realtime.isNoteExistsInPool(noteId)) {
254+
const note = realtime.getNoteFromNotePool(noteId)
255+
realtime.disconnectSocketOnNote(note)
256+
}
257+
250258
res.send({
251259
status: 'ok'
252260
})

0 commit comments

Comments
 (0)