running eslint again

This commit is contained in:
Julian Lam
2017-02-24 12:47:46 -05:00
parent 72e77772db
commit ddea9f534e
26 changed files with 356 additions and 359 deletions

View File

@@ -72,7 +72,7 @@ module.exports = function (Categories) {
next(null, category);
},
function (category, next) {
plugins.fireHook('action:category.create', {category: category});
plugins.fireHook('action:category.create', { category: category });
next(null, category);
},
], callback);
@@ -143,14 +143,14 @@ module.exports = function (Categories) {
plugins.fireHook('filter:categories.copyPrivilegesFrom', {
privileges: privileges.privilegeList,
fromCid: fromCid,
toCid: toCid
toCid: toCid,
}, next);
},
function (data, next) {
async.each(data.privileges, function (privilege, next) {
copyPrivilege(privilege, data.fromCid, data.toCid, next);
}, next);
}
},
], callback);
};

View File

@@ -30,7 +30,7 @@ module.exports = function (Categories) {
purgeCategory(cid, next);
},
function (next) {
plugins.fireHook('action:category.delete', {cid: cid, uid: uid});
plugins.fireHook('action:category.delete', { cid: cid, uid: uid });
next();
},
], callback);

View File

@@ -124,7 +124,7 @@ helpers.getUserDataByUserSlug = function (userslug, callerUID, callback) {
other: !isSelf,
moderator: isModerator,
globalMod: isGlobalModerator,
admin: isAdmin
admin: isAdmin,
});
userData.sso = results.sso.associations;
@@ -174,7 +174,7 @@ function filterLinks(links, states) {
other: true,
moderator: true,
globalMod: true,
admin: true
admin: true,
}, link.visibility);
// Iterate through states and permit if every test passes (or is not defined)

View File

@@ -127,12 +127,10 @@ function getUsers(set, section, min, max, req, res, next) {
count: function (next) {
if (byScore) {
db.sortedSetCount(set, min, max, next);
} else if (set === 'users:banned' || set === 'users:notvalidated') {
db.sortedSetCard(set, next);
} else {
if (set === 'users:banned' || set === 'users:notvalidated') {
db.sortedSetCard(set, next);
} else {
db.getObjectField('global', 'userCount', next);
}
db.getObjectField('global', 'userCount', next);
}
},
users: function (next) {

View File

@@ -330,7 +330,7 @@ authenticationController.onSuccessfulLogin = function (req, uid, callback) {
// Force session check for all connected socket.io clients with the same session id
sockets.in('sess_' + req.sessionID).emit('checkSession', uid);
plugins.fireHook('action:user.loggedIn', {uid: uid, req: req});
plugins.fireHook('action:user.loggedIn', { uid: uid, req: req });
callback();
});
};

View File

@@ -8,7 +8,7 @@ var flags = require('../flags');
var analytics = require('../analytics');
var modsController = {
flags: {}
flags: {},
};
modsController.flags.list = function (req, res, next) {
@@ -58,7 +58,7 @@ modsController.flags.list = function (req, res, next) {
async.parallel({
flags: async.apply(flags.list, filters, req.uid),
analytics: async.apply(analytics.getDailyStatsForSet, 'analytics:flags', Date.now(), 30),
categories: async.apply(categories.buildForSelect, req.uid)
categories: async.apply(categories.buildForSelect, req.uid),
}, function (err, data) {
if (err) {
return next(err);
@@ -92,7 +92,7 @@ modsController.flags.list = function (req, res, next) {
categories: data.categories,
hasFilter: hasFilter,
filters: filters,
title: '[[pages:flags]]'
title: '[[pages:flags]]',
});
});
});
@@ -103,7 +103,7 @@ modsController.flags.detail = function (req, res, next) {
isAdminOrGlobalMod: async.apply(user.isAdminOrGlobalMod, req.uid),
moderatedCids: async.apply(user.getModeratedCids, req.uid),
flagData: async.apply(flags.get, req.params.flagId),
assignees: async.apply(user.getAdminsandGlobalModsandModerators)
assignees: async.apply(user.getAdminsandGlobalModsandModerators),
}, function (err, results) {
if (err || !results.flagData) {
return next(err || new Error('[[error:invalid-data]]'));
@@ -122,7 +122,7 @@ modsController.flags.detail = function (req, res, next) {
return memo;
}, {}),
title: '[[pages:flag-details, ' + req.params.flagId + ']]'
title: '[[pages:flag-details, ' + req.params.flagId + ']]',
}));
});
};

View File

@@ -24,13 +24,13 @@ Flags.get = function (flagId, callback) {
async.apply(async.parallel, {
base: async.apply(db.getObject.bind(db), 'flag:' + flagId),
history: async.apply(Flags.getHistory, flagId),
notes: async.apply(Flags.getNotes, flagId)
notes: async.apply(Flags.getNotes, flagId),
}),
function (data, next) {
// Second stage
async.parallel({
userObj: async.apply(user.getUserFields, data.base.uid, ['username', 'userslug', 'picture']),
targetObj: async.apply(Flags.getTarget, data.base.type, data.base.targetId, data.base.uid)
targetObj: async.apply(Flags.getTarget, data.base.type, data.base.targetId, data.base.uid),
}, function (err, payload) {
// Final object return construction
next(err, Object.assign(data.base, {
@@ -39,10 +39,10 @@ Flags.get = function (flagId, callback) {
target: payload.targetObj,
history: data.history,
notes: data.notes,
reporter: payload.userObj
reporter: payload.userObj,
}));
});
}
},
], callback);
};
@@ -63,44 +63,44 @@ Flags.list = function (filters, uid, callback) {
});
} else {
// Empty array, do nothing
return;
}
};
if (Object.keys(filters).length > 0) {
for (var type in filters) {
switch (type) {
case 'type':
prepareSets('flags:byType:', filters[type]);
break;
case 'type':
prepareSets('flags:byType:', filters[type]);
break;
case 'state':
prepareSets('flags:byState:', filters[type]);
break;
case 'reporterId':
prepareSets('flags:byReporter:', filters[type]);
break;
case 'assignee':
prepareSets('flags:byAssignee:', filters[type]);
break;
case 'state':
prepareSets('flags:byState:', filters[type]);
break;
case 'targetUid':
prepareSets('flags:byTargetUid:', filters[type]);
break;
case 'reporterId':
prepareSets('flags:byReporter:', filters[type]);
break;
case 'cid':
prepareSets('flags:byCid:', filters[type]);
break;
case 'assignee':
prepareSets('flags:byAssignee:', filters[type]);
break;
case 'quick':
switch (filters.quick) {
case 'mine':
sets.push('flags:byAssignee:' + uid);
break;
}
case 'targetUid':
prepareSets('flags:byTargetUid:', filters[type]);
break;
case 'cid':
prepareSets('flags:byCid:', filters[type]);
break;
case 'quick':
switch (filters.quick) {
case 'mine':
sets.push('flags:byAssignee:' + uid);
break;
}
break;
}
}
}
@@ -147,38 +147,38 @@ Flags.list = function (filters, uid, callback) {
username: userObj.username,
picture: userObj.picture,
'icon:bgColor': userObj['icon:bgColor'],
'icon:text': userObj['icon:text']
}
'icon:text': userObj['icon:text'],
},
}));
});
}
},
], function (err, flagObj) {
if (err) {
return next(err);
}
switch(flagObj.state) {
case 'open':
flagObj.labelClass = 'info';
break;
case 'wip':
flagObj.labelClass = 'warning';
break;
case 'resolved':
flagObj.labelClass = 'success';
break;
case 'rejected':
flagObj.labelClass = 'danger';
break;
switch (flagObj.state) {
case 'open':
flagObj.labelClass = 'info';
break;
case 'wip':
flagObj.labelClass = 'warning';
break;
case 'resolved':
flagObj.labelClass = 'success';
break;
case 'rejected':
flagObj.labelClass = 'danger';
break;
}
next(null, Object.assign(flagObj, {
target_readable: flagObj.type.charAt(0).toUpperCase() + flagObj.type.slice(1) + ' ' + flagObj.targetId,
datetimeISO: new Date(parseInt(flagObj.datetime, 10)).toISOString()
datetimeISO: new Date(parseInt(flagObj.datetime, 10)).toISOString(),
}));
});
}, next);
}
}, next);
},
], callback);
};
@@ -186,7 +186,7 @@ Flags.validate = function (payload, callback) {
async.parallel({
targetExists: async.apply(Flags.targetExists, payload.type, payload.id),
target: async.apply(Flags.getTarget, payload.type, payload.id, payload.uid),
reporter: async.apply(user.getUserData, payload.uid)
reporter: async.apply(user.getUserData, payload.uid),
}, function (err, data) {
if (err) {
return callback(err);
@@ -199,42 +199,42 @@ Flags.validate = function (payload, callback) {
}
switch (payload.type) {
case 'post':
privileges.posts.canEdit(payload.id, payload.uid, function (err, editable) {
if (err) {
return callback(err);
}
case 'post':
privileges.posts.canEdit(payload.id, payload.uid, function (err, editable) {
if (err) {
return callback(err);
}
var minimumReputation = utils.isNumber(meta.config['privileges:flag']) ? parseInt(meta.config['privileges:flag'], 10) : 1;
var minimumReputation = utils.isNumber(meta.config['privileges:flag']) ? parseInt(meta.config['privileges:flag'], 10) : 1;
// Check if reporter meets rep threshold (or can edit the target post, in which case threshold does not apply)
if (!editable.flag && parseInt(data.reporter.reputation, 10) < minimumReputation) {
return callback(new Error('[[error:not-enough-reputation-to-flag]]'));
}
if (!editable.flag && parseInt(data.reporter.reputation, 10) < minimumReputation) {
return callback(new Error('[[error:not-enough-reputation-to-flag]]'));
}
callback();
});
break;
case 'user':
privileges.users.canEdit(payload.uid, payload.id, function (err, editable) {
if (err) {
return callback(err);
}
callback();
});
break;
var minimumReputation = utils.isNumber(meta.config['privileges:flag']) ? parseInt(meta.config['privileges:flag'], 10) : 1;
case 'user':
privileges.users.canEdit(payload.uid, payload.id, function (err, editable) {
if (err) {
return callback(err);
}
var minimumReputation = utils.isNumber(meta.config['privileges:flag']) ? parseInt(meta.config['privileges:flag'], 10) : 1;
// Check if reporter meets rep threshold (or can edit the target user, in which case threshold does not apply)
if (!editable && parseInt(data.reporter.reputation, 10) < minimumReputation) {
return callback(new Error('[[error:not-enough-reputation-to-flag]]'));
}
if (!editable && parseInt(data.reporter.reputation, 10) < minimumReputation) {
return callback(new Error('[[error:not-enough-reputation-to-flag]]'));
}
callback();
});
break;
default:
callback(new Error('[[error:invalid-data]]'));
break;
}
callback();
});
break;
default:
callback(new Error('[[error:invalid-data]]'));
break;
}
});
};
@@ -252,7 +252,7 @@ Flags.getNotes = function (flagId, callback) {
uid: noteObj[0],
content: noteObj[1],
datetime: note.score,
datetimeISO: new Date(parseInt(note.score, 10)).toISOString()
datetimeISO: new Date(parseInt(note.score, 10)).toISOString(),
};
} catch (e) {
return next(e);
@@ -271,7 +271,7 @@ Flags.getNotes = function (flagId, callback) {
return note;
}));
});
}
},
], callback);
};
@@ -296,7 +296,7 @@ Flags.create = function (type, id, uid, reason, timestamp, callback) {
// Extra data for zset insertion
async.apply(Flags.getTargetUid, type, id),
async.apply(Flags.getTargetCid, type, id)
async.apply(Flags.getTargetCid, type, id),
], function (err, checks) {
if (err) {
return next(err);
@@ -309,9 +309,8 @@ Flags.create = function (type, id, uid, reason, timestamp, callback) {
return next(new Error('[[error:already-flagged]]'));
} else if (!checks[1]) {
return next(new Error('[[error:invalid-data]]'));
} else {
next();
}
next();
});
},
async.apply(db.incrObjectField, 'global', 'nextFlagId'),
@@ -323,13 +322,13 @@ Flags.create = function (type, id, uid, reason, timestamp, callback) {
targetId: id,
description: reason,
uid: uid,
datetime: timestamp
datetime: timestamp,
}),
async.apply(db.sortedSetAdd.bind(db), 'flags:datetime', timestamp, flagId), // by time, the default
async.apply(db.sortedSetAdd.bind(db), 'flags:byReporter:' + uid, timestamp, flagId), // by reporter
async.apply(db.sortedSetAdd.bind(db), 'flags:byType:' + type, timestamp, flagId), // by flag type
async.apply(db.sortedSetAdd.bind(db), 'flags:hash', flagId, [type, id, uid].join(':')), // save zset for duplicate checking
async.apply(analytics.increment, 'flags') // some fancy analytics
async.apply(analytics.increment, 'flags'), // some fancy analytics
];
if (targetUid) {
@@ -341,20 +340,20 @@ Flags.create = function (type, id, uid, reason, timestamp, callback) {
if (type === 'post') {
tasks.push(async.apply(db.sortedSetAdd.bind(db), 'flags:byPid:' + id, timestamp, flagId)); // by target pid
}
async.parallel(tasks, function (err, data) {
if (err) {
return next(err);
}
if (doHistoryAppend) {
Flags.update(flagId, uid, { "state": "open" });
Flags.update(flagId, uid, { state: 'open' });
}
next(null, flagId);
});
},
async.apply(Flags.get)
async.apply(Flags.get),
], callback);
};
@@ -368,72 +367,72 @@ Flags.getTarget = function (type, id, uid, callback) {
function (exists, next) {
if (exists) {
switch (type) {
case 'post':
async.waterfall([
async.apply(posts.getPostsByPids, [id], uid),
function (posts, next) {
topics.addPostData(posts, uid, next);
}
], function (err, posts) {
next(err, posts[0]);
});
break;
case 'post':
async.waterfall([
async.apply(posts.getPostsByPids, [id], uid),
function (posts, next) {
topics.addPostData(posts, uid, next);
},
], function (err, posts) {
next(err, posts[0]);
});
break;
case 'user':
user.getUsersData([id], function (err, users) {
next(err, users ? users[0] : undefined);
});
break;
case 'user':
user.getUsersData([id], function (err, users) {
next(err, users ? users[0] : undefined);
});
break;
default:
next(new Error('[[error:invalid-data]]'));
break;
default:
next(new Error('[[error:invalid-data]]'));
break;
}
} else {
// Target used to exist (otherwise flag creation'd fail), but no longer
next(null, {});
}
}
},
], callback);
};
Flags.targetExists = function (type, id, callback) {
switch (type) {
case 'post':
posts.exists(id, callback);
break;
case 'user':
user.exists(id, callback);
break;
case 'post':
posts.exists(id, callback);
break;
default:
callback(new Error('[[error:invalid-data]]'));
break;
case 'user':
user.exists(id, callback);
break;
default:
callback(new Error('[[error:invalid-data]]'));
break;
}
};
Flags.getTargetUid = function (type, id, callback) {
switch (type) {
case 'post':
posts.getPostField(id, 'uid', callback);
break;
default:
setImmediate(callback, null, id);
break;
case 'post':
posts.getPostField(id, 'uid', callback);
break;
default:
setImmediate(callback, null, id);
break;
}
};
Flags.getTargetCid = function (type, id, callback) {
switch (type) {
case 'post':
posts.getCidByPid(id, callback);
break;
case 'post':
posts.getCidByPid(id, callback);
break;
default:
setImmediate(callback, null, id);
break;
default:
setImmediate(callback, null, id);
break;
}
};
@@ -453,14 +452,14 @@ Flags.update = function (flagId, uid, changeset, callback) {
} else {
// Add tasks as necessary
switch (prop) {
case 'state':
tasks.push(async.apply(db.sortedSetAdd.bind(db), 'flags:byState:' + changeset[prop], now, flagId));
tasks.push(async.apply(db.sortedSetRemove.bind(db), 'flags:byState:' + current[prop], flagId));
break;
case 'assignee':
tasks.push(async.apply(db.sortedSetAdd.bind(db), 'flags:byAssignee:' + changeset[prop], now, flagId));
break;
case 'state':
tasks.push(async.apply(db.sortedSetAdd.bind(db), 'flags:byState:' + changeset[prop], now, flagId));
tasks.push(async.apply(db.sortedSetRemove.bind(db), 'flags:byState:' + current[prop], flagId));
break;
case 'assignee':
tasks.push(async.apply(db.sortedSetAdd.bind(db), 'flags:byAssignee:' + changeset[prop], now, flagId));
break;
}
}
}
@@ -483,7 +482,7 @@ Flags.update = function (flagId, uid, changeset, callback) {
async.parallel(tasks, function (err, data) {
return next(err);
});
}
},
], callback);
};
@@ -512,12 +511,12 @@ Flags.getHistory = function (flagId, callback) {
uid: entry.value[0],
fields: changeset,
datetime: entry.score,
datetimeISO: new Date(parseInt(entry.score, 10)).toISOString()
datetimeISO: new Date(parseInt(entry.score, 10)).toISOString(),
};
});
user.getUsersFields(uids, ['username', 'userslug', 'picture'], next);
}
},
], function (err, users) {
if (err) {
return callback(err);
@@ -564,8 +563,8 @@ Flags.appendNote = function (flagId, uid, note, datetime, callback) {
async.apply(db.sortedSetAdd, 'flag:' + flagId + ':notes', datetime, payload),
async.apply(Flags.appendHistory, flagId, uid, {
notes: null,
datetime: datetime
})
datetime: datetime,
}),
], callback);
};
@@ -576,88 +575,88 @@ Flags.notify = function (flagObj, uid, callback) {
}
switch (flagObj.type) {
case 'post':
async.parallel({
post: function (next) {
async.waterfall([
async.apply(posts.getPostData, flagObj.targetId),
async.apply(posts.parsePost)
], next);
},
title: async.apply(topics.getTitleByPid, flagObj.targetId),
admins: async.apply(groups.getMembers, 'administrators', 0, -1),
globalMods: async.apply(groups.getMembers, 'Global Moderators', 0, -1),
moderators: function (next) {
async.waterfall([
async.apply(posts.getCidByPid, flagObj.targetId),
function (cid, next) {
groups.getMembers('cid:' + cid + ':privileges:mods', 0, -1, next);
}
], next);
}
}, function (err, results) {
if (err) {
case 'post':
async.parallel({
post: function (next) {
async.waterfall([
async.apply(posts.getPostData, flagObj.targetId),
async.apply(posts.parsePost),
], next);
},
title: async.apply(topics.getTitleByPid, flagObj.targetId),
admins: async.apply(groups.getMembers, 'administrators', 0, -1),
globalMods: async.apply(groups.getMembers, 'Global Moderators', 0, -1),
moderators: function (next) {
async.waterfall([
async.apply(posts.getCidByPid, flagObj.targetId),
function (cid, next) {
groups.getMembers('cid:' + cid + ':privileges:mods', 0, -1, next);
},
], next);
},
}, function (err, results) {
if (err) {
return callback(err);
}
var title = S(results.title).decodeHTMLEntities().s;
var titleEscaped = title.replace(/%/g, '&#37;').replace(/,/g, '&#44;');
notifications.create({
bodyShort: '[[notifications:user_flagged_post_in, ' + flagObj.reporter.username + ', ' + titleEscaped + ']]',
bodyLong: flagObj.description,
pid: flagObj.targetId,
path: '/post/' + flagObj.targetId,
nid: 'flag:post:' + flagObj.targetId + ':uid:' + uid,
from: uid,
mergeId: 'notifications:user_flagged_post_in|' + flagObj.targetId,
topicTitle: results.title,
}, function (err, notification) {
if (err || !notification) {
return callback(err);
}
var title = S(results.title).decodeHTMLEntities().s;
var titleEscaped = title.replace(/%/g, '&#37;').replace(/,/g, '&#44;');
notifications.create({
bodyShort: '[[notifications:user_flagged_post_in, ' + flagObj.reporter.username + ', ' + titleEscaped + ']]',
bodyLong: flagObj.description,
pid: flagObj.targetId,
path: '/post/' + flagObj.targetId,
nid: 'flag:post:' + flagObj.targetId + ':uid:' + uid,
from: uid,
mergeId: 'notifications:user_flagged_post_in|' + flagObj.targetId,
topicTitle: results.title
}, function (err, notification) {
if (err || !notification) {
return callback(err);
}
plugins.fireHook('action:flag.create', {
flag: flagObj
});
notifications.push(notification, results.admins.concat(results.moderators).concat(results.globalMods), callback);
plugins.fireHook('action:flag.create', {
flag: flagObj,
});
notifications.push(notification, results.admins.concat(results.moderators).concat(results.globalMods), callback);
});
break;
});
break;
case 'user':
async.parallel({
admins: async.apply(groups.getMembers, 'administrators', 0, -1),
globalMods: async.apply(groups.getMembers, 'Global Moderators', 0, -1),
}, function (err, results) {
if (err) {
case 'user':
async.parallel({
admins: async.apply(groups.getMembers, 'administrators', 0, -1),
globalMods: async.apply(groups.getMembers, 'Global Moderators', 0, -1),
}, function (err, results) {
if (err) {
return callback(err);
}
notifications.create({
bodyShort: '[[notifications:user_flagged_user, ' + flagObj.reporter.username + ', ' + flagObj.target.username + ']]',
bodyLong: flagObj.description,
path: '/uid/' + flagObj.targetId,
nid: 'flag:user:' + flagObj.targetId + ':uid:' + uid,
from: uid,
mergeId: 'notifications:user_flagged_user|' + flagObj.targetId,
}, function (err, notification) {
if (err || !notification) {
return callback(err);
}
notifications.create({
bodyShort: '[[notifications:user_flagged_user, ' + flagObj.reporter.username + ', ' + flagObj.target.username + ']]',
bodyLong: flagObj.description,
path: '/uid/' + flagObj.targetId,
nid: 'flag:user:' + flagObj.targetId + ':uid:' + uid,
from: uid,
mergeId: 'notifications:user_flagged_user|' + flagObj.targetId
}, function (err, notification) {
if (err || !notification) {
return callback(err);
}
plugins.fireHook('action:flag.create', {
flag: flagObj
});
notifications.push(notification, results.admins.concat(results.globalMods), callback);
plugins.fireHook('action:flag.create', {
flag: flagObj,
});
notifications.push(notification, results.admins.concat(results.globalMods), callback);
});
break;
default:
callback(new Error('[[error:invalid-data]]'));
break;
});
break;
default:
callback(new Error('[[error:invalid-data]]'));
break;
}
};
module.exports = Flags;
module.exports = Flags;

View File

@@ -69,7 +69,7 @@ module.exports = function (Groups) {
async.series(tasks, next);
},
function (results, next) {
plugins.fireHook('action:group.create', {group: groupData});
plugins.fireHook('action:group.create', { group: groupData });
next(null, groupData);
},
], callback);

View File

@@ -42,7 +42,7 @@ module.exports = function (Groups) {
return callback(err);
}
Groups.resetCache();
plugins.fireHook('action:group.destroy', {group: groupObj});
plugins.fireHook('action:group.destroy', { group: groupObj });
callback();
});
});

View File

@@ -20,7 +20,7 @@ Minifier.js.minify = function (scripts, minify, callback) {
if (err) {
return next(err);
}
if (!exists) {
console.warn('[minifier] file not found, ' + script);
}
@@ -30,7 +30,7 @@ Minifier.js.minify = function (scripts, minify, callback) {
if (err) {
return callback(err);
}
if (minify) {
minifyScripts(scripts, callback);
} else {

View File

@@ -86,9 +86,8 @@ middleware.ensureSelfOrPrivileged = function (req, res, next) {
return next(err);
} else if (ok) {
return next();
} else {
controllers.helpers.notAllowed(req, res);
}
controllers.helpers.notAllowed(req, res);
});
} else {
controllers.helpers.notAllowed(req, res);

View File

@@ -155,7 +155,7 @@ var plugins = require('./plugins');
pid: pid,
};
data[field] = value;
plugins.fireHook('action:post.setFields', {data: data});
plugins.fireHook('action:post.setFields', { data: data });
callback();
});
};
@@ -166,7 +166,7 @@ var plugins = require('./plugins');
return callback(err);
}
data.pid = pid;
plugins.fireHook('action:post.setFields', {data: data});
plugins.fireHook('action:post.setFields', { data: data });
callback();
});
};

View File

@@ -106,7 +106,7 @@ module.exports = function (Posts) {
},
function (postData, next) {
postData.isMain = isMain;
plugins.fireHook('action:post.save', {post: _.clone(postData)});
plugins.fireHook('action:post.save', { post: _.clone(postData) });
next(null, postData);
},
], callback);

View File

@@ -65,7 +65,7 @@ module.exports = function (Posts) {
postData.cid = results.topic.cid;
postData.topic = results.topic;
plugins.fireHook('action:post.edit', {post: _.clone(postData), uid: data.uid});
plugins.fireHook('action:post.edit', { post: _.clone(postData), uid: data.uid });
cache.del(String(postData.pid));
pubsub.publish('post:edit', String(postData.pid));
@@ -136,7 +136,7 @@ module.exports = function (Posts) {
function (tags, next) {
topicData.tags = data.tags;
topicData.oldTitle = results.topic.title;
plugins.fireHook('action:topic.edit', {topic: topicData, uid: data.uid});
plugins.fireHook('action:topic.edit', { topic: topicData, uid: data.uid });
next(null, {
tid: tid,
cid: results.topic.cid,

View File

@@ -29,12 +29,12 @@ SocketFlags.create = function (socket, data, callback) {
async.apply(flags.validate, {
uid: socket.uid,
type: data.type,
id: data.id
id: data.id,
}),
function (next) {
// If we got here, then no errors occurred
flags.create(data.type, data.id, socket.uid, data.reason, next);
}
},
], function (err, flagObj) {
if (err) {
return callback(err);
@@ -56,7 +56,7 @@ SocketFlags.update = function (socket, data, callback) {
function (next) {
async.parallel([
async.apply(user.isAdminOrGlobalMod, socket.uid),
async.apply(user.isModeratorOfAnyCategory, socket.uid)
async.apply(user.isModeratorOfAnyCategory, socket.uid),
], function (err, results) {
next(err, results[0] || results[1]);
});
@@ -74,7 +74,7 @@ SocketFlags.update = function (socket, data, callback) {
flags.update(data.flagId, socket.uid, payload, next);
},
async.apply(flags.getHistory, data.flagId)
async.apply(flags.getHistory, data.flagId),
], callback);
};
@@ -87,7 +87,7 @@ SocketFlags.appendNote = function (socket, data, callback) {
function (next) {
async.parallel([
async.apply(user.isAdminOrGlobalMod, socket.uid),
async.apply(user.isModeratorOfAnyCategory, socket.uid)
async.apply(user.isModeratorOfAnyCategory, socket.uid),
], function (err, results) {
next(err, results[0] || results[1]);
});
@@ -101,10 +101,10 @@ SocketFlags.appendNote = function (socket, data, callback) {
},
function (next) {
async.parallel({
"notes": async.apply(flags.getNotes, data.flagId),
"history": async.apply(flags.getHistory, data.flagId)
notes: async.apply(flags.getNotes, data.flagId),
history: async.apply(flags.getHistory, data.flagId),
}, next);
}
},
], callback);
};

View File

@@ -95,7 +95,7 @@ module.exports = function (SocketTopics) {
var start = parseInt(data.after, 10);
var stop = start + 9;
topics.getUnreadTopics({cid: data.cid, uid: socket.uid, start: start, stop: stop, filter: data.filter}, callback);
topics.getUnreadTopics({ cid: data.cid, uid: socket.uid, start: start, stop: stop, filter: data.filter }, callback);
};
SocketTopics.loadMoreRecentTopics = function (socket, data, callback) {

View File

@@ -50,7 +50,7 @@ module.exports = function (SocketTopics) {
SocketTopics.markCategoryTopicsRead = function (socket, cid, callback) {
async.waterfall([
function (next) {
topics.getUnreadTids({cid: cid, uid: socket.uid, filter: ''}, next);
topics.getUnreadTids({ cid: cid, uid: socket.uid, filter: '' }, next);
},
function (tids, next) {
SocketTopics.markAsRead(socket, tids, next);

View File

@@ -82,7 +82,7 @@ module.exports = function (Topics) {
], next);
},
function (results, next) {
plugins.fireHook('action:topic.save', {topic: _.clone(topicData)});
plugins.fireHook('action:topic.save', { topic: _.clone(topicData) });
next(null, topicData.tid);
},
], callback);
@@ -174,7 +174,7 @@ module.exports = function (Topics) {
data.postData.index = 0;
analytics.increment(['topics', 'topics:byCid:' + data.topicData.cid]);
plugins.fireHook('action:topic.post', {topic: data.topicData, post: data.postData});
plugins.fireHook('action:topic.post', { topic: data.topicData, post: data.postData });
if (parseInt(uid, 10)) {
user.notifications.sendTopicNotificationToFollowers(uid, data.topicData, data.postData);
@@ -269,7 +269,7 @@ module.exports = function (Topics) {
Topics.notifyFollowers(postData, uid);
analytics.increment(['posts', 'posts:byCid:' + cid]);
plugins.fireHook('action:topic.reply', {post: _.clone(postData)});
plugins.fireHook('action:topic.reply', { post: _.clone(postData) });
next(null, postData);
},

View File

@@ -334,11 +334,11 @@ Upgrade.upgrade = function (callback) {
posts = posts.filter(function (post) {
return post.hasOwnProperty('flags');
});
async.each(posts, function (post, next) {
async.parallel({
uids: async.apply(db.getSortedSetRangeWithScores, 'pid:' + post.pid + ':flag:uids', 0, -1),
reasons: async.apply(db.getSortedSetRange, 'pid:' + post.pid + ':flag:uid:reason', 0, -1)
reasons: async.apply(db.getSortedSetRange, 'pid:' + post.pid + ':flag:uid:reason', 0, -1),
}, function (err, data) {
if (err) {
return next(err);
@@ -362,7 +362,7 @@ Upgrade.upgrade = function (callback) {
flags.update(flagObj.flagId, 1, {
state: post['flag:state'],
assignee: post['flag:assignee'],
datetime: datetime
datetime: datetime,
}, next);
} else {
setImmediate(next);
@@ -383,7 +383,7 @@ Upgrade.upgrade = function (callback) {
} else {
setImmediate(next);
}
}
},
], function (err) {
if (err && err.message === '[[error:already-flagged]]') {
// Already flagged, no need to parse, but not an error
@@ -407,7 +407,7 @@ Upgrade.upgrade = function (callback) {
winston.info('[2016/12/07] Migrating flags to new schema (#5232) - skipped!');
next();
}
}
},
// Add new schema updates here
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 24!!!
], function (err) {

View File

@@ -258,7 +258,7 @@ var meta = require('./meta');
async.parallel([
async.apply(User.isAdministrator, uid),
async.apply(User.isGlobalModerator, uid),
async.apply(User.isModeratorOfAnyCategory, uid)
async.apply(User.isModeratorOfAnyCategory, uid),
], function (err, results) {
callback(err, results ? results.some(Boolean) : false);
});

View File

@@ -140,7 +140,7 @@ module.exports = function (User) {
if (userNameChanged) {
User.notifications.sendNameChangeNotification(userData.uid, userData.username);
}
plugins.fireHook('action:user.create', {user: userData});
plugins.fireHook('action:user.create', { user: userData });
next(null, userData.uid);
},
], callback);