diff options
author | John McLear <john@mclear.co.uk> | 2014-08-08 16:45:20 +0100 |
---|---|---|
committer | John McLear <john@mclear.co.uk> | 2014-08-08 16:45:20 +0100 |
commit | e34a4ea4ee5939d0e38436299793793763b198be (patch) | |
tree | ec8efd0c465fd163172426a5395a3198a2c43ade | |
parent | 49bba7dfe230c31b990691b1e109be8845cfa705 (diff) | |
parent | 2f8b860e698fd8f0bba29ce1fd438ea29397313c (diff) | |
download | etherpad-lite-e34a4ea4ee5939d0e38436299793793763b198be.zip |
Merge pull request #2218 from simong/userLeave-hook
Added a `userLeave` hook that gets called when a user leaves a pad
-rw-r--r-- | doc/api/hooks_server-side.md | 17 | ||||
-rw-r--r-- | src/node/handler/PadMessageHandler.js | 3 |
2 files changed, 20 insertions, 0 deletions
diff --git a/doc/api/hooks_server-side.md b/doc/api/hooks_server-side.md index 51026140..435872ea 100644 --- a/doc/api/hooks_server-side.md +++ b/doc/api/hooks_server-side.md @@ -263,3 +263,20 @@ exports.exportFileName = function(hook, padId, callback){ callback("newFileName"+padId); } ``` + +## userLeave +Called from src/node/handler/PadMessageHandler.js + +This in context: + +1. session (including the pad id and author id) + +This hook gets called when an author leaves a pad. This is useful if you want to perform certain actions after a pad has been edited + +Example: + +``` +exports.userLeave = function(hook, session, callback) { + console.log('%s left pad %s', session.author, session.padId); +}; +``` diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index 26eb17a6..e1ac994e 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -145,6 +145,9 @@ exports.handleDisconnect = function(client) //Go trough all user that are still on the pad, and send them the USER_LEAVE message client.broadcast.to(session.padId).json.send(messageToTheOtherUsers); + + // Allow plugins to hook into users leaving the pad + hooks.callAll("userLeave", session); }); } |