Add notifications when removed from owners or pending_owners
This commit is contained in:
parent
d190b8acd0
commit
4708d59a65
@ -203,25 +203,53 @@ define([
|
|||||||
if (ed === edPublic) { me = true; }
|
if (ed === edPublic) { me = true; }
|
||||||
return ed;
|
return ed;
|
||||||
}).filter(function (x) { return x; });
|
}).filter(function (x) { return x; });
|
||||||
|
NThen(function (waitFor) {
|
||||||
|
var msg = me ?
|
||||||
|
"Are you sure? You're going to give up on your rights, this can't be undone!" :
|
||||||
|
"Are you sure?"; // XXX
|
||||||
|
UI.confirm(msg, waitFor(function (yes) {
|
||||||
|
if (!yes) {
|
||||||
|
waitFor.abort();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}).nThen(function (waitFor) {
|
||||||
// Send the command
|
// Send the command
|
||||||
var send = function () {
|
|
||||||
sframeChan.query('Q_SET_PAD_METADATA', {
|
sframeChan.query('Q_SET_PAD_METADATA', {
|
||||||
channel: channel,
|
channel: channel,
|
||||||
command: pending ? 'RM_PENDING_OWNERS' : 'RM_OWNERS',
|
command: pending ? 'RM_PENDING_OWNERS' : 'RM_OWNERS',
|
||||||
value: toRemove
|
value: toRemove
|
||||||
}, function (err, res) {
|
}, waitFor(function (err, res) {
|
||||||
err = err || (res && res.error);
|
err = err || (res && res.error);
|
||||||
if (err) { return void UI.warn('ERROR' + err); } // XXX
|
if (err) {
|
||||||
redrawAll();
|
waitFor.abort();
|
||||||
|
return void UI.warn('ERROR' + err);
|
||||||
|
} // XXX
|
||||||
UI.log('DONE'); // XXX
|
UI.log('DONE'); // XXX
|
||||||
|
}));
|
||||||
|
}).nThen(function (waitFor) {
|
||||||
|
sel.forEach(function (el) {
|
||||||
|
var friend = friends[$(el).attr('data-curve')];
|
||||||
|
if (!friend) { return; }
|
||||||
|
common.mailbox.sendTo("RM_OWNER", {
|
||||||
|
channel: channel,
|
||||||
|
title: data.title,
|
||||||
|
pending: pending,
|
||||||
|
user: {
|
||||||
|
displayName: user.name,
|
||||||
|
avatar: user.avatar,
|
||||||
|
profile: user.profile,
|
||||||
|
notifications: user.notifications,
|
||||||
|
curvePublic: user.curvePublic,
|
||||||
|
edPublic: priv.edPublic
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
channel: friend.notifications,
|
||||||
|
curvePublic: friend.curvePublic
|
||||||
|
}, waitFor());
|
||||||
});
|
});
|
||||||
};
|
}).nThen(function () {
|
||||||
var msg = me ?
|
redrawAll();
|
||||||
"Are you sure? You're going to give up on your rights, this can't be undone!" :
|
|
||||||
"Are you sure?"; // XXX
|
|
||||||
UI.confirm(msg, function (yes) {
|
|
||||||
if (!yes) { return; }
|
|
||||||
send();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$div.append(h('p', removeButton));
|
$div.append(h('p', removeButton));
|
||||||
|
|||||||
@ -252,6 +252,24 @@ define([
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
handlers['RM_OWNER'] = function (common, data) {
|
||||||
|
var content = data.content;
|
||||||
|
var msg = content.msg;
|
||||||
|
|
||||||
|
// Display the notification
|
||||||
|
var name = Util.fixHTML(msg.content.user.displayName) || Messages.anonymous;
|
||||||
|
var title = Util.fixHTML(msg.content.title);
|
||||||
|
Messages.owner_removed = '{0} has removed your ownership of <b>{1}</b>'; // XXX
|
||||||
|
Messages.owner_removedPending = '{0} has removed your pending ownership of <b>{1}</b>'; // XXX
|
||||||
|
var key = 'owner_removed' + (msg.content.pending ? 'Pending' : '');
|
||||||
|
content.getFormatText = function () {
|
||||||
|
return Messages._getKey(key, [name, title]);
|
||||||
|
};
|
||||||
|
if (!content.archived) {
|
||||||
|
content.dismissHandler = defaultDismiss(common, data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// NOTE: don't forget to fixHTML everything returned by "getFormatText"
|
// NOTE: don't forget to fixHTML everything returned by "getFormatText"
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -267,7 +267,6 @@ define([
|
|||||||
handlers['ADD_OWNER'] = function (ctx, box, data, cb) {
|
handlers['ADD_OWNER'] = function (ctx, box, data, cb) {
|
||||||
var msg = data.msg;
|
var msg = data.msg;
|
||||||
var content = msg.content;
|
var content = msg.content;
|
||||||
console.log(msg);
|
|
||||||
|
|
||||||
if (msg.author !== content.user.curvePublic) { return void cb(true); }
|
if (msg.author !== content.user.curvePublic) { return void cb(true); }
|
||||||
if (!content.href || !content.title || !content.channel) {
|
if (!content.href || !content.title || !content.channel) {
|
||||||
@ -278,7 +277,10 @@ console.log(msg);
|
|||||||
var channel = content.channel;
|
var channel = content.channel;
|
||||||
|
|
||||||
if (addOwners[channel]) { return void cb(true); }
|
if (addOwners[channel]) { return void cb(true); }
|
||||||
addOwners[channel] = true;
|
addOwners[channel] = {
|
||||||
|
type: box.type,
|
||||||
|
hash: data.hash
|
||||||
|
};
|
||||||
|
|
||||||
cb(false);
|
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 {
|
return {
|
||||||
add: function (ctx, box, data, cb) {
|
add: function (ctx, box, data, cb) {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -477,7 +477,7 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
sframeChan.on('Q_ACCEPT_OWNERSHIP', function (data, cb) {
|
sframeChan.on('Q_ACCEPT_OWNERSHIP', function (data, cb) {
|
||||||
var data = {
|
var _data = {
|
||||||
password: data.password,
|
password: data.password,
|
||||||
href: data.href,
|
href: data.href,
|
||||||
channel: data.channel,
|
channel: data.channel,
|
||||||
@ -486,7 +486,7 @@ define([
|
|||||||
expire: data.metadata.expire,
|
expire: data.metadata.expire,
|
||||||
forceSave: true
|
forceSave: true
|
||||||
};
|
};
|
||||||
Cryptpad.setPadTitle(data, function (err) {
|
Cryptpad.setPadTitle(_data, function (err) {
|
||||||
cb({error: err});
|
cb({error: err});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user