Implement ADD_OWNER notification with pending_owner metadata

This commit is contained in:
yflory
2019-08-30 16:41:48 +02:00
parent 738030e8c0
commit 9822c28f3b
8 changed files with 231 additions and 32 deletions

View File

@@ -259,6 +259,32 @@ define([
cb(false);
};
// Hide duplicates when receiving an ADD_OWNER notification:
var addOwners = {};
handlers['ADD_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.href || !content.title || !content.channel) {
console.log('Remove invalid notification');
return void cb(true);
}
var channel = content.channel;
if (addOwners[channel]) { return void cb(true); }
addOwners[channel] = true;
cb(false);
};
removeHandlers['ADD_OWNER'] = function (ctx, box, data) {
var channel = data.content.channel;
if (addOwners[channel]) {
delete addOwners[channel];
}
};
return {
add: function (ctx, box, data, cb) {
/**