Add notifications when removed from owners or pending_owners

This commit is contained in:
yflory
2019-09-02 18:46:52 +02:00
parent d190b8acd0
commit 4708d59a65
4 changed files with 82 additions and 16 deletions

View File

@@ -267,7 +267,6 @@ define([
handlers['ADD_OWNER'] = function (ctx, box, data, cb) {
var msg = data.msg;
var content = msg.content;
console.log(msg);
if (msg.author !== content.user.curvePublic) { return void cb(true); }
if (!content.href || !content.title || !content.channel) {
@@ -278,7 +277,10 @@ console.log(msg);
var channel = content.channel;
if (addOwners[channel]) { return void cb(true); }
addOwners[channel] = true;
addOwners[channel] = {
type: box.type,
hash: data.hash
};
cb(false);
};
@@ -289,6 +291,24 @@ console.log(msg);
}
};
handlers['RM_OWNER'] = function (ctx, box, data, cb) {
var msg = data.msg;
var content = msg.content;
if (msg.author !== content.user.curvePublic) { return void cb(true); }
if (!content.channel) {
console.log('Remove invalid notification');
return void cb(true);
}
var channel = content.channel;
if (addOwners[channel] && content.pending) {
return void cb(false, addOwners[channel]);
}
cb(false);
};
return {
add: function (ctx, box, data, cb) {
/**