diff --git a/lib/realtime/realtime.ts b/lib/realtime/realtime.ts index 0ca01e51d7..112035f7d9 100644 --- a/lib/realtime/realtime.ts +++ b/lib/realtime/realtime.ts @@ -24,6 +24,7 @@ import {CursorData, RealtimeClientConnection} from "./realtimeClientConnection"; import {UpdateDirtyNoteJob} from "./realtimeUpdateDirtyNoteJob"; import {CleanDanglingUserJob} from "./realtimeCleanDanglingUserJob"; import {SaveRevisionJob} from "./realtimeSaveRevisionJob"; +import SocketRequest = SocketIO.SocketRequest; export interface RealtimeUserData { @@ -497,7 +498,7 @@ export function emitRefresh(socket: SocketIO.Socket): void { socket.emit('refresh', out) } -export function checkViewPermission(req, note: RealtimeNoteData): boolean { +export function checkViewPermission(req: SocketRequest, note: RealtimeNoteData): boolean { if (note.permission === 'private') { if (req.user && req.user.logged_in && req.user.id === note.owner) { return true diff --git a/typings/socket.io/index.d.ts b/typings/socket.io/index.d.ts index fb6ca268a9..4e2cb1441e 100644 --- a/typings/socket.io/index.d.ts +++ b/typings/socket.io/index.d.ts @@ -10,9 +10,17 @@ declare namespace SocketIO { } | any } + export interface SocketRequest { + user?: { + logged_in: boolean + id: string + } + } + export interface Socket { origin?: any noteId?: string + request: SocketRequest | any } }