PadMessageHandler: Modernize `userLeave` hook context properties

This commit is contained in:
Richard Hansen 2021-10-30 02:22:15 -04:00
parent a6d060d67b
commit 9aaf781548
3 changed files with 15 additions and 13 deletions

View File

@ -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

View File

@ -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:

View File

@ -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,
});
};
/**