prevent duplicated owners in metadata amendments
This commit is contained in:
parent
a3a7bcbe35
commit
1c37ec7aee
11
lib/deduplicate.js
Normal file
11
lib/deduplicate.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// remove duplicate elements in an array
|
||||||
|
module.exports = function (O) {
|
||||||
|
// make a copy of the original array
|
||||||
|
var A = O.slice();
|
||||||
|
for (var i = 0; i < A.length; i++) {
|
||||||
|
for (var j = i + 1; j < A.length; j++) {
|
||||||
|
if (A[i] === A[j]) { A.splice(j--, 1); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return A;
|
||||||
|
};
|
||||||
@ -1,5 +1,7 @@
|
|||||||
var Meta = module.exports;
|
var Meta = module.exports;
|
||||||
|
|
||||||
|
var deduplicate = require("./deduplicate");
|
||||||
|
|
||||||
/* Metadata fields:
|
/* Metadata fields:
|
||||||
|
|
||||||
* channel <STRING>
|
* channel <STRING>
|
||||||
@ -64,7 +66,7 @@ commands.RESET_OWNERS = function (meta, args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// overwrite the existing owners with the new one
|
// overwrite the existing owners with the new one
|
||||||
meta.owners = args;
|
meta.owners = deduplicate(args);
|
||||||
};
|
};
|
||||||
|
|
||||||
commands.UPDATE_EXPIRATION = function () {
|
commands.UPDATE_EXPIRATION = function () {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user