refactor: remove async.waterfall
parent
f35a0f430a
commit
222dccaf67
@ -1,27 +1,22 @@
|
|||||||
|
/* eslint-disable no-await-in-loop */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
const async = require('async');
|
|
||||||
|
|
||||||
const groups = require('../../groups');
|
const groups = require('../../groups');
|
||||||
const db = require('../../database');
|
const db = require('../../database');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'Give deleted post viewing privilege to moderators on all categories',
|
name: 'Give deleted post viewing privilege to moderators on all categories',
|
||||||
timestamp: Date.UTC(2018, 5, 8),
|
timestamp: Date.UTC(2018, 5, 8),
|
||||||
method: function (callback) {
|
method: async function () {
|
||||||
db.getSortedSetRange('categories:cid', 0, -1, (err, cids) => {
|
const { progress } = this;
|
||||||
if (err) {
|
const cids = await db.getSortedSetRange('categories:cid', 0, -1);
|
||||||
return callback(err);
|
for (const cid of cids) {
|
||||||
|
const uids = await db.getSortedSetRange(`group:cid:${cid}:privileges:moderate:members`, 0, -1);
|
||||||
|
for (const uid of uids) {
|
||||||
|
await groups.join(`cid:${cid}:privileges:posts:view_deleted`, uid);
|
||||||
}
|
}
|
||||||
async.eachSeries(cids, (cid, next) => {
|
progress.incr();
|
||||||
async.waterfall([
|
}
|
||||||
async.apply(db.getSortedSetRange.bind(db), `group:cid:${cid}:privileges:moderate:members`, 0, -1),
|
|
||||||
function (uids, next) {
|
|
||||||
async.eachSeries(uids, (uid, next) => groups.join(`cid:${cid}:privileges:posts:view_deleted`, uid, next), next);
|
|
||||||
},
|
|
||||||
], next);
|
|
||||||
}, callback);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,36 +1,28 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const async = require('async');
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'Navigation item visibility groups',
|
name: 'Navigation item visibility groups',
|
||||||
timestamp: Date.UTC(2018, 10, 10),
|
timestamp: Date.UTC(2018, 10, 10),
|
||||||
method: function (callback) {
|
method: async function () {
|
||||||
const navigationAdmin = require('../../navigation/admin');
|
const navigationAdmin = require('../../navigation/admin');
|
||||||
|
|
||||||
async.waterfall([
|
const data = await navigationAdmin.get();
|
||||||
function (next) {
|
data.forEach((navItem) => {
|
||||||
navigationAdmin.get(next);
|
if (navItem && navItem.properties) {
|
||||||
},
|
navItem.groups = [];
|
||||||
function (data, next) {
|
if (navItem.properties.adminOnly) {
|
||||||
data.forEach((navItem) => {
|
navItem.groups.push('administrators');
|
||||||
if (navItem && navItem.properties) {
|
} else if (navItem.properties.globalMod) {
|
||||||
navItem.groups = [];
|
navItem.groups.push('Global Moderators');
|
||||||
if (navItem.properties.adminOnly) {
|
}
|
||||||
navItem.groups.push('administrators');
|
|
||||||
} else if (navItem.properties.globalMod) {
|
|
||||||
navItem.groups.push('Global Moderators');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (navItem.properties.loggedIn) {
|
if (navItem.properties.loggedIn) {
|
||||||
navItem.groups.push('registered-users');
|
navItem.groups.push('registered-users');
|
||||||
} else if (navItem.properties.guestOnly) {
|
} else if (navItem.properties.guestOnly) {
|
||||||
navItem.groups.push('guests');
|
navItem.groups.push('guests');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
navigationAdmin.save(data, next);
|
await navigationAdmin.save(data);
|
||||||
},
|
|
||||||
], callback);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue