Store the mailbox of all the owners
This commit is contained in:
@@ -55,6 +55,13 @@ commands.RM_OWNERS = function (meta, args) {
|
||||
args.forEach(function (owner) {
|
||||
var index = meta.owners.indexOf(owner);
|
||||
if (index < 0) { return; }
|
||||
if (meta.mailbox) {
|
||||
if (typeof(meta.mailbox) === "string") {
|
||||
delete meta.mailbox;
|
||||
} else {
|
||||
delete meta.mailbox[owner];
|
||||
}
|
||||
}
|
||||
meta.owners.splice(index, 1);
|
||||
changed = true;
|
||||
});
|
||||
@@ -131,6 +138,40 @@ commands.RESET_OWNERS = function (meta, args) {
|
||||
return true;
|
||||
};
|
||||
|
||||
// ["ADD_MAILBOX", {"7eEqelGso3EBr5jHlei6av4r9w2B9XZiGGwA1EgZ-5I=": mailbox, ...}, 1561623439989]
|
||||
commands.ADD_MAILBOX = function (meta, args) {
|
||||
// expect a new array, even if it's empty
|
||||
if (!args || typeof(args) !== "object") {
|
||||
throw new Error('METADATA_INVALID_MAILBOX');
|
||||
}
|
||||
// assume there are owners to start
|
||||
if (!Array.isArray(meta.owners)) {
|
||||
throw new Error("METADATA_NONSENSE_OWNERS");
|
||||
}
|
||||
|
||||
var changed = false;
|
||||
|
||||
// For each mailbox we try to add, check if the associated edPublic is an owner
|
||||
// If they are, add or replace the mailbox
|
||||
Object.keys(args).forEach(function (edPublic) {
|
||||
if (meta.owners.indexOf(edPublic) === -1) { return; }
|
||||
|
||||
if (typeof(meta.mailbox) === "string") {
|
||||
var str = meta.mailbox;
|
||||
meta.mailbox = {};
|
||||
meta.mailbox[meta.owners[0]] = str;
|
||||
}
|
||||
|
||||
// Make sure mailbox is defined
|
||||
if (!meta.mailbox) { meta.mailbox = {}; }
|
||||
|
||||
meta.mailbox[edPublic] = args[edPublic];
|
||||
changed = true;
|
||||
});
|
||||
|
||||
return changed;
|
||||
};
|
||||
|
||||
commands.UPDATE_EXPIRATION = function () {
|
||||
throw new Error("E_NOT_IMPLEMENTED");
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user