diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d328bc0d..ca7f4662f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,11 @@ for an example fix. * The `clientReady` server-side hook is deprecated; use the new `userJoin` hook instead. + * The `userLeave` server-side hook's context properties have changed: + * `auth`: Deprecated. + * `author`: Deprecated; use the new `authorId` property instead. + * `readonly`: Deprecated; use the new `readOnly` property instead. + * `rev`: Deprecated. ### Notable enhancements @@ -41,6 +46,7 @@ * `clientVars` was added to the context for the `postAceInit` client-side hook. Plugins should use this instead of the `clientVars` global variable. * New `userJoin` server-side hook. + * The `userLeave` server-side hook has a new `socket` context property. # 1.8.14 diff --git a/doc/api/hooks_server-side.md b/doc/api/hooks_server-side.md index 8f22478e4..4836c4b73 100644 --- a/doc/api/hooks_server-side.md +++ b/doc/api/hooks_server-side.md @@ -840,20 +840,11 @@ certain actions after a pad has been edited. Context properties: -* `auth`: Object containing information used for authentication, provided by the - user. Properties: - * `padID`: Pad identifier requested by the user. Unlike the `padId` property - described below, this might be a read-only pad ID. - * `sessionID`: Copied from the client's `sessionID` cookie, which should be - the value returned from the `createSession()` HTTP API. This will be nullish - if `createSession()` isn't used or the portal doesn't set the `sessionID` - cookie. - * `token`: User-supplied token. -* `author`: The user's author ID. +* `authorId`: The user's author ID. * `padId`: The pad's real (not read-only) identifier. +* `readOnly`: If truthy, the user only has read-only access. * `readOnlyPadId`: The pad's read-only identifier. -* `readonly`: If truthy, the user only has read-only access. -* `rev`: The last revision that was sent to the client. +* `socket`: The socket.io Socket object. Example: diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index 65ba11803..e38d77160 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -150,7 +150,12 @@ exports.handleDisconnect = async (socket) => { }, }, }); - await hooks.aCallAll('userLeave', session); + await hooks.aCallAll('userLeave', { + ...session, // For backwards compatibility. + authorId: session.author, + readOnly: session.readonly, + socket, + }); }; /**