forked from marcelklehr/ep_push2delete
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
56 lines (49 loc) · 1.47 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var eejs = require('ep_etherpad-lite/node/eejs')
var PadContext = require('ep_etherpad-lite/node/db/Pad')
var Pad = PadContext.Pad
/*
* Handle incoming delete requests from clients
*/
exports.handleMessage = function(hook_name, context, callback){
// Firstly ignore any request that aren't about chat
var isDeleteRequest = false;
if(context) {
if(context.message && context.message){
if(context.message.type === 'COLLABROOM'){
if(context.message.data){
if(context.message.data.type){
if(context.message.data.type === 'ep_push2delete'){
isDeleteRequest = true;
}
}
}
}
}
}
if(!isDeleteRequest){
return callback(false);
}
console.log('DELETION REQUEST!')
var packet = context.message.data;
/***
What's available in a packet?
* action -- The action IE chatPosition
* padId -- The padId of the pad both authors are on
***/
if(packet.action === 'deletePad'){
var pad = new Pad(packet.padId)
pad.remove(function(er) {
if(er) console.warn('ep_push2delete', er)
callback([null]);
})
}
}
exports.eejsBlock_mySettings = function(_hook_name, _args, cb) {
return cb();
};
exports.eejsBlock_mySettings.dropdowns = function(_hook_name, args, cb) {
let hiddenState = "display: inline !important;";
const ejsPath = 'ep_push2delete/templates/delete_button1.ejs';
args.content += eejs.require(ejsPath, {hidden: hiddenState});
return cb();
};