mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-27 17:11:14 +01:00
fix(style): updated code to follow new eslint recommendations
Squashed commit of the following: commitf9ce878b26Author: Julian Lam <julian@nodebb.org> Date: Tue Aug 13 14:30:46 2019 -0400 fix(style): updated code to follow new eslint recommendations commit80dd370e41Author: Julian Lam <julian@nodebb.org> Date: Tue Aug 13 14:14:58 2019 -0400 fix(deps): update dependency sitemap to v4 Squashed commit of the following: commitf4dd9cabb2Author: Julian Lam <julian@nodebb.org> Date: Tue Aug 13 11:33:05 2019 -0400 fix: resolved breaking changes from sitemap v4 upgrade commit9043415ee1Merge:e3352b27272590b346Author: Julian Lam <julian@nodebb.org> Date: Tue Aug 13 11:09:55 2019 -0400 Merge branch 'master' into renovate/sitemap-4.x commite3352b272eAuthor: Renovate Bot <bot@renovateapp.com> Date: Mon Aug 12 07:59:05 2019 +0000 fix(deps): update dependency sitemap to v4 commit8e3c0cdcaeAuthor: Renovate Bot <bot@renovateapp.com> Date: Fri Aug 9 00:49:51 2019 +0000 fix(deps): update dependency commander to v3 commit2104449d38Author: Renovate Bot <bot@renovateapp.com> Date: Tue Aug 13 15:00:27 2019 +0000 fix(deps): update dependency mongodb to v3.3.0 commitd2937f446aAuthor: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Tue Aug 13 10:36:48 2019 -0400 feat: async/await admin/controllers commit1b97e8b199Author: Misty (Bot) <deploy@nodebb.org> Date: Tue Aug 13 09:28:39 2019 +0000 Latest translations and fallbacks commit69a48957a2Author: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Mon Aug 12 21:56:09 2019 -0400 feat: async/await commitb9b2a7e593Author: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Mon Aug 12 20:58:29 2019 -0400 feat: async/await refactor controllers/accounts commita8d43a1759Author: Baris Usakli <barisusakli@gmail.com> Date: Mon Aug 12 14:49:40 2019 -0400 feat: async/await controllers/accounts commit2f25aae57bAuthor: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Sun Aug 11 23:09:50 2019 -0400 fix: #7831, fix pagination convert to async/await commitc9e83f2374Author: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Sun Aug 11 00:14:35 2019 -0400 fix: remove empty line commit30be91b26cAuthor: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Sun Aug 11 00:13:41 2019 -0400 fix: remove useless catchs and empty line commit2e4a71c0b6Author: Renovate Bot <bot@renovateapp.com> Date: Sat Aug 10 06:51:50 2019 +0000 chore(deps): update dependency eslint-config-airbnb-base to v14
This commit is contained in:
@@ -43,6 +43,7 @@
|
|||||||
}],
|
}],
|
||||||
"no-else-return": [ "error", { "allowElseIf": true } ],
|
"no-else-return": [ "error", { "allowElseIf": true } ],
|
||||||
"operator-linebreak": [ "error", "after" ],
|
"operator-linebreak": [ "error", "after" ],
|
||||||
|
"arrow-parens": ["error", "as-needed"],
|
||||||
|
|
||||||
// ES6
|
// ES6
|
||||||
"prefer-rest-params": "off",
|
"prefer-rest-params": "off",
|
||||||
|
|||||||
@@ -135,7 +135,7 @@
|
|||||||
"@commitlint/config-angular": "8.1.0",
|
"@commitlint/config-angular": "8.1.0",
|
||||||
"coveralls": "3.0.5",
|
"coveralls": "3.0.5",
|
||||||
"eslint": "6.1.0",
|
"eslint": "6.1.0",
|
||||||
"eslint-config-airbnb-base": "13.2.0",
|
"eslint-config-airbnb-base": "14.0.0",
|
||||||
"eslint-plugin-import": "2.18.2",
|
"eslint-plugin-import": "2.18.2",
|
||||||
"grunt": "1.0.4",
|
"grunt": "1.0.4",
|
||||||
"grunt-contrib-watch": "1.1.0",
|
"grunt-contrib-watch": "1.1.0",
|
||||||
|
|||||||
@@ -579,6 +579,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
toggleTimeagoShorthand: function toggleTimeagoShorthand(callback) {
|
toggleTimeagoShorthand: function toggleTimeagoShorthand(callback) {
|
||||||
|
/* eslint "prefer-object-spread": "off" */
|
||||||
function toggle() {
|
function toggle() {
|
||||||
var tmp = assign({}, jQuery.timeago.settings.strings);
|
var tmp = assign({}, jQuery.timeago.settings.strings);
|
||||||
jQuery.timeago.settings.strings = assign({}, adaptor.timeagoShort);
|
jQuery.timeago.settings.strings = assign({}, adaptor.timeagoShort);
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ Categories.getCategories = async function (cids, uid) {
|
|||||||
Categories.getTagWhitelist = async function (cids) {
|
Categories.getTagWhitelist = async function (cids) {
|
||||||
const cachedData = {};
|
const cachedData = {};
|
||||||
|
|
||||||
const nonCachedCids = cids.filter((cid) => {
|
const nonCachedCids = cids.filter(cid => {
|
||||||
const data = cache.get('cid:' + cid + ':tag:whitelist');
|
const data = cache.get('cid:' + cid + ':tag:whitelist');
|
||||||
const isInCache = data !== undefined;
|
const isInCache = data !== undefined;
|
||||||
if (isInCache) {
|
if (isInCache) {
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ module.exports = function (Categories) {
|
|||||||
|
|
||||||
const bulkRemove = [];
|
const bulkRemove = [];
|
||||||
const bulkAdd = [];
|
const bulkAdd = [];
|
||||||
postData.forEach((post) => {
|
postData.forEach(post => {
|
||||||
bulkRemove.push(['cid:' + oldCid + ':uid:' + post.uid + ':pids', post.pid]);
|
bulkRemove.push(['cid:' + oldCid + ':uid:' + post.uid + ':pids', post.pid]);
|
||||||
bulkRemove.push(['cid:' + oldCid + ':uid:' + post.uid + ':pids:votes', post.pid]);
|
bulkRemove.push(['cid:' + oldCid + ':uid:' + post.uid + ':pids:votes', post.pid]);
|
||||||
bulkAdd.push(['cid:' + cid + ':uid:' + post.uid + ':pids', post.timestamp, post.pid]);
|
bulkAdd.push(['cid:' + cid + ':uid:' + post.uid + ':pids', post.timestamp, post.pid]);
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ function updatePackageFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var defaultPackageContents = JSON.parse(fs.readFileSync(packageDefaultFilePath, 'utf8'));
|
var defaultPackageContents = JSON.parse(fs.readFileSync(packageDefaultFilePath, 'utf8'));
|
||||||
var packageContents = Object.assign({}, oldPackageContents, defaultPackageContents, {
|
var packageContents = { ...oldPackageContents, ...defaultPackageContents, dependencies: { ...oldPackageContents.dependencies, ...defaultPackageContents.dependencies } };
|
||||||
dependencies: Object.assign({}, oldPackageContents.dependencies, defaultPackageContents.dependencies),
|
|
||||||
});
|
|
||||||
|
|
||||||
fs.writeFileSync(packageFilePath, JSON.stringify(packageContents, null, 2));
|
fs.writeFileSync(packageFilePath, JSON.stringify(packageContents, null, 2));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,13 +197,12 @@ function filterLinks(links, states) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Default visibility
|
// Default visibility
|
||||||
link.visibility = Object.assign({
|
link.visibility = { self: true,
|
||||||
self: true,
|
|
||||||
other: true,
|
other: true,
|
||||||
moderator: true,
|
moderator: true,
|
||||||
globalMod: true,
|
globalMod: true,
|
||||||
admin: true,
|
admin: true,
|
||||||
}, link.visibility);
|
...link.visibility };
|
||||||
|
|
||||||
var permit = Object.keys(states).some(function (state) {
|
var permit = Object.keys(states).some(function (state) {
|
||||||
return states[state] && link.visibility[state];
|
return states[state] && link.visibility[state];
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ authenticationController.registerComplete = function (req, res, next) {
|
|||||||
delete payload.uid;
|
delete payload.uid;
|
||||||
delete payload.returnTo;
|
delete payload.returnTo;
|
||||||
|
|
||||||
Object.keys(payload).forEach((prop) => {
|
Object.keys(payload).forEach(prop => {
|
||||||
if (typeof payload[prop] === 'boolean') {
|
if (typeof payload[prop] === 'boolean') {
|
||||||
payload[prop] = payload[prop] ? 1 : 0;
|
payload[prop] = payload[prop] ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ async function addTags(topicData, req, res) {
|
|||||||
|
|
||||||
async function addOGImageTags(res, topicData, postAtIndex) {
|
async function addOGImageTags(res, topicData, postAtIndex) {
|
||||||
const uploads = postAtIndex ? await posts.uploads.listWithSizes(postAtIndex.pid) : [];
|
const uploads = postAtIndex ? await posts.uploads.listWithSizes(postAtIndex.pid) : [];
|
||||||
const images = uploads.map((upload) => {
|
const images = uploads.map(upload => {
|
||||||
upload.name = nconf.get('url') + nconf.get('upload_url') + '/files/' + upload.name;
|
upload.name = nconf.get('url') + nconf.get('upload_url') + '/files/' + upload.name;
|
||||||
return upload;
|
return upload;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ unreadController.get = function (req, res, next) {
|
|||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
plugins.fireHook('filter:unread.getValidFilters', { filters: Object.assign({}, helpers.validFilters) }, next);
|
plugins.fireHook('filter:unread.getValidFilters', { filters: { ...helpers.validFilters } }, next);
|
||||||
},
|
},
|
||||||
function (data, _next) {
|
function (data, _next) {
|
||||||
if (!data.filters[filter]) {
|
if (!data.filters[filter]) {
|
||||||
@@ -98,7 +98,7 @@ unreadController.unreadTotal = function (req, res, next) {
|
|||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
plugins.fireHook('filter:unread.getValidFilters', { filters: Object.assign({}, helpers.validFilters) }, next);
|
plugins.fireHook('filter:unread.getValidFilters', { filters: { ...helpers.validFilters } }, next);
|
||||||
},
|
},
|
||||||
function (data, _next) {
|
function (data, _next) {
|
||||||
if (!data.filters[filter]) {
|
if (!data.filters[filter]) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ if (!databaseName) {
|
|||||||
var primaryDB = require('./' + databaseName);
|
var primaryDB = require('./' + databaseName);
|
||||||
|
|
||||||
primaryDB.parseIntFields = function (data, intFields, requestedFields) {
|
primaryDB.parseIntFields = function (data, intFields, requestedFields) {
|
||||||
intFields.forEach((field) => {
|
intFields.forEach(field => {
|
||||||
if (!requestedFields.length || requestedFields.includes(field)) {
|
if (!requestedFields.length || requestedFields.includes(field)) {
|
||||||
data[field] = parseInt(data[field], 10) || 0;
|
data[field] = parseInt(data[field], 10) || 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ module.exports = function (module) {
|
|||||||
|
|
||||||
const item = cachedData[key] || {};
|
const item = cachedData[key] || {};
|
||||||
const result = {};
|
const result = {};
|
||||||
fields.forEach((field) => {
|
fields.forEach(field => {
|
||||||
result[field] = item[field] !== undefined ? item[field] : null;
|
result[field] = item[field] !== undefined ? item[field] : null;
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ module.exports = function (module) {
|
|||||||
|
|
||||||
const item = cachedData[key] || {};
|
const item = cachedData[key] || {};
|
||||||
const result = {};
|
const result = {};
|
||||||
fields.forEach((field) => {
|
fields.forEach(field => {
|
||||||
result[field] = item[field] !== undefined ? item[field] : null;
|
result[field] = item[field] !== undefined ? item[field] : null;
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ module.exports = function (module) {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const batch = module.client.batch();
|
const batch = module.client.batch();
|
||||||
key.forEach((key) => {
|
key.forEach(key => {
|
||||||
batch[method]([key, start, stop, 'WITHSCORES']);
|
batch[method]([key, start, stop, 'WITHSCORES']);
|
||||||
});
|
});
|
||||||
let data = await helpers.execBatch(batch);
|
let data = await helpers.execBatch(batch);
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ Emailer.send = function (template, uid, params, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Combined passed-in payload with default values
|
// Combined passed-in payload with default values
|
||||||
params = Object.assign({}, Emailer._defaultPayload, params);
|
params = { ...Emailer._defaultPayload, ...params };
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
@@ -228,10 +228,9 @@ Emailer.sendToEmail = function (template, email, language, params, callback) {
|
|||||||
var lang = language || meta.config.defaultLang || 'en-GB';
|
var lang = language || meta.config.defaultLang || 'en-GB';
|
||||||
|
|
||||||
// Add some default email headers based on local configuration
|
// Add some default email headers based on local configuration
|
||||||
params.headers = Object.assign({
|
params.headers = { 'List-Id': '<' + [template, params.uid, getHostname()].join('.') + '>',
|
||||||
'List-Id': '<' + [template, params.uid, getHostname()].join('.') + '>',
|
|
||||||
'List-Unsubscribe': '<' + [nconf.get('url'), 'uid', params.uid, 'settings'].join('/') + '>',
|
'List-Unsubscribe': '<' + [nconf.get('url'), 'uid', params.uid, 'settings'].join('/') + '>',
|
||||||
}, params.headers);
|
...params.headers };
|
||||||
|
|
||||||
// Digests and notifications can be one-click unsubbed
|
// Digests and notifications can be one-click unsubbed
|
||||||
let payload = {
|
let payload = {
|
||||||
|
|||||||
16
src/flags.js
16
src/flags.js
@@ -93,17 +93,15 @@ Flags.get = function (flagId, callback) {
|
|||||||
targetObj: async.apply(Flags.getTarget, data.base.type, data.base.targetId, 0),
|
targetObj: async.apply(Flags.getTarget, data.base.type, data.base.targetId, 0),
|
||||||
}, function (err, payload) {
|
}, function (err, payload) {
|
||||||
// Final object return construction
|
// Final object return construction
|
||||||
next(err, Object.assign({
|
next(err, { state: 'open',
|
||||||
state: 'open',
|
...data.base,
|
||||||
}, data.base, {
|
|
||||||
description: validator.escape(data.base.description),
|
description: validator.escape(data.base.description),
|
||||||
datetimeISO: utils.toISOString(data.base.datetime),
|
datetimeISO: utils.toISOString(data.base.datetime),
|
||||||
target_readable: data.base.type.charAt(0).toUpperCase() + data.base.type.slice(1) + ' ' + data.base.targetId,
|
target_readable: data.base.type.charAt(0).toUpperCase() + data.base.type.slice(1) + ' ' + data.base.targetId,
|
||||||
target: payload.targetObj,
|
target: payload.targetObj,
|
||||||
history: data.history,
|
history: data.history,
|
||||||
notes: data.notes,
|
notes: data.notes,
|
||||||
reporter: payload.userObj,
|
reporter: payload.userObj });
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function (flagObj, next) {
|
function (flagObj, next) {
|
||||||
@@ -181,16 +179,14 @@ Flags.list = function (filters, uid, callback) {
|
|||||||
async.apply(db.getObject, 'flag:' + flagId),
|
async.apply(db.getObject, 'flag:' + flagId),
|
||||||
function (flagObj, next) {
|
function (flagObj, next) {
|
||||||
user.getUserFields(flagObj.uid, ['username', 'picture'], function (err, userObj) {
|
user.getUserFields(flagObj.uid, ['username', 'picture'], function (err, userObj) {
|
||||||
next(err, Object.assign({
|
next(err, { state: 'open',
|
||||||
state: 'open',
|
...flagObj,
|
||||||
}, flagObj, {
|
|
||||||
reporter: {
|
reporter: {
|
||||||
username: userObj.username,
|
username: userObj.username,
|
||||||
picture: userObj.picture,
|
picture: userObj.picture,
|
||||||
'icon:bgColor': userObj['icon:bgColor'],
|
'icon:bgColor': userObj['icon:bgColor'],
|
||||||
'icon:text': userObj['icon:text'],
|
'icon:text': userObj['icon:text'],
|
||||||
},
|
} });
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
], function (err, flagObj) {
|
], function (err, flagObj) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ var db = require('../database');
|
|||||||
var user = require('../user');
|
var user = require('../user');
|
||||||
|
|
||||||
module.exports = function (Messaging) {
|
module.exports = function (Messaging) {
|
||||||
Messaging.sendMessage = async (data) => {
|
Messaging.sendMessage = async data => {
|
||||||
await Messaging.checkContent(data.content);
|
await Messaging.checkContent(data.content);
|
||||||
const inRoom = await Messaging.isUserInRoom(data.uid, data.roomId);
|
const inRoom = await Messaging.isUserInRoom(data.uid, data.roomId);
|
||||||
if (!inRoom) {
|
if (!inRoom) {
|
||||||
@@ -16,7 +16,7 @@ module.exports = function (Messaging) {
|
|||||||
return await Messaging.addMessage(data);
|
return await Messaging.addMessage(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
Messaging.checkContent = async (content) => {
|
Messaging.checkContent = async content => {
|
||||||
if (!content) {
|
if (!content) {
|
||||||
throw new Error('[[error:invalid-chat-message]]');
|
throw new Error('[[error:invalid-chat-message]]');
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ module.exports = function (Messaging) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Messaging.addMessage = async (data) => {
|
Messaging.addMessage = async data => {
|
||||||
const mid = await db.incrObjectField('global', 'nextMid');
|
const mid = await db.incrObjectField('global', 'nextMid');
|
||||||
const timestamp = data.timestamp || new Date().getTime();
|
const timestamp = data.timestamp || new Date().getTime();
|
||||||
let message = {
|
let message = {
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ module.exports = function (Messaging) {
|
|||||||
message.system = !!message.system;
|
message.system = !!message.system;
|
||||||
});
|
});
|
||||||
|
|
||||||
messages = await Promise.all(messages.map(async (message) => {
|
messages = await Promise.all(messages.map(async message => {
|
||||||
if (message.system) {
|
if (message.system) {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ require('./unread')(Messaging);
|
|||||||
require('./notifications')(Messaging);
|
require('./notifications')(Messaging);
|
||||||
|
|
||||||
|
|
||||||
Messaging.getMessages = async (params) => {
|
Messaging.getMessages = async params => {
|
||||||
const isNew = params.isNew || false;
|
const isNew = params.isNew || false;
|
||||||
const start = params.hasOwnProperty('start') ? params.start : 0;
|
const start = params.hasOwnProperty('start') ? params.start : 0;
|
||||||
const stop = parseInt(start, 10) + ((params.count || 50) - 1);
|
const stop = parseInt(start, 10) + ((params.count || 50) - 1);
|
||||||
@@ -98,7 +98,7 @@ Messaging.getRecentChats = async (callerUid, uid, start, stop) => {
|
|||||||
const results = await utils.promiseParallel({
|
const results = await utils.promiseParallel({
|
||||||
roomData: Messaging.getRoomsData(roomIds),
|
roomData: Messaging.getRoomsData(roomIds),
|
||||||
unread: db.isSortedSetMembers('uid:' + uid + ':chat:rooms:unread', roomIds),
|
unread: db.isSortedSetMembers('uid:' + uid + ':chat:rooms:unread', roomIds),
|
||||||
users: Promise.all(roomIds.map(async (roomId) => {
|
users: Promise.all(roomIds.map(async roomId => {
|
||||||
let uids = await db.getSortedSetRevRange('chat:room:' + roomId + ':uids', 0, 9);
|
let uids = await db.getSortedSetRevRange('chat:room:' + roomId + ':uids', 0, 9);
|
||||||
uids = uids.filter(function (value) {
|
uids = uids.filter(function (value) {
|
||||||
return value && parseInt(value, 10) !== parseInt(uid, 10);
|
return value && parseInt(value, 10) !== parseInt(uid, 10);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ var privileges = require('../privileges');
|
|||||||
var meta = require('../meta');
|
var meta = require('../meta');
|
||||||
|
|
||||||
module.exports = function (Messaging) {
|
module.exports = function (Messaging) {
|
||||||
Messaging.getRoomData = async (roomId) => {
|
Messaging.getRoomData = async roomId => {
|
||||||
const data = await db.getObject('chat:room:' + roomId);
|
const data = await db.getObject('chat:room:' + roomId);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
throw new Error('[[error:no-chat-room]]');
|
throw new Error('[[error:no-chat-room]]');
|
||||||
@@ -19,7 +19,7 @@ module.exports = function (Messaging) {
|
|||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
Messaging.getRoomsData = async (roomIds) => {
|
Messaging.getRoomsData = async roomIds => {
|
||||||
const roomData = await db.getObjects(roomIds.map(function (roomId) {
|
const roomData = await db.getObjects(roomIds.map(function (roomId) {
|
||||||
return 'chat:room:' + roomId;
|
return 'chat:room:' + roomId;
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ var db = require('../database');
|
|||||||
var sockets = require('../socket.io');
|
var sockets = require('../socket.io');
|
||||||
|
|
||||||
module.exports = function (Messaging) {
|
module.exports = function (Messaging) {
|
||||||
Messaging.getUnreadCount = async (uid) => {
|
Messaging.getUnreadCount = async uid => {
|
||||||
if (parseInt(uid, 10) <= 0) {
|
if (parseInt(uid, 10) <= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ module.exports = function (Messaging) {
|
|||||||
return await db.sortedSetCard('uid:' + uid + ':chat:rooms:unread');
|
return await db.sortedSetCard('uid:' + uid + ':chat:rooms:unread');
|
||||||
};
|
};
|
||||||
|
|
||||||
Messaging.pushUnreadCount = async (uid) => {
|
Messaging.pushUnreadCount = async uid => {
|
||||||
if (parseInt(uid, 10) <= 0) {
|
if (parseInt(uid, 10) <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ Configs.getFields = async function (fields) {
|
|||||||
values = await db.getObject('config');
|
values = await db.getObject('config');
|
||||||
}
|
}
|
||||||
|
|
||||||
values = Object.assign({}, defaults, values ? deserialize(values) : {});
|
values = { ...defaults, ...(values ? deserialize(values) : {}) };
|
||||||
|
|
||||||
if (!fields.length) {
|
if (!fields.length) {
|
||||||
values.version = nconf.get('version');
|
values.version = nconf.get('version');
|
||||||
@@ -100,7 +100,7 @@ Configs.setMultiple = async function (data) {
|
|||||||
|
|
||||||
Configs.setOnEmpty = async function (values) {
|
Configs.setOnEmpty = async function (values) {
|
||||||
const data = await db.getObject('config');
|
const data = await db.getObject('config');
|
||||||
const config = Object.assign({}, values, data ? deserialize(data) : {});
|
const config = { ...values, ...(data ? deserialize(data) : {}) };
|
||||||
await db.setObject('config', config);
|
await db.setObject('config', config);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -30,9 +30,7 @@ function debugFork(modulePath, args, options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
options = options || {};
|
options = options || {};
|
||||||
options = Object.assign({}, options, {
|
options = { ...options, execArgv: execArgv };
|
||||||
execArgv: execArgv,
|
|
||||||
});
|
|
||||||
|
|
||||||
return fork(modulePath, args, options);
|
return fork(modulePath, args, options);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ async function getTemplateDirs(activePlugins) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getTemplateFiles(dirs) {
|
async function getTemplateFiles(dirs) {
|
||||||
const buckets = await Promise.all(dirs.map(async (dir) => {
|
const buckets = await Promise.all(dirs.map(async dir => {
|
||||||
let files = await file.walk(dir);
|
let files = await file.walk(dir);
|
||||||
files = files.filter(function (path) {
|
files = files.filter(function (path) {
|
||||||
return path.endsWith('.tpl');
|
return path.endsWith('.tpl');
|
||||||
@@ -132,7 +132,7 @@ async function compile() {
|
|||||||
files = await getTemplateDirs(files);
|
files = await getTemplateDirs(files);
|
||||||
files = await getTemplateFiles(files);
|
files = await getTemplateFiles(files);
|
||||||
|
|
||||||
await Promise.all(Object.keys(files).map(async (name) => {
|
await Promise.all(Object.keys(files).map(async name => {
|
||||||
const filePath = files[name];
|
const filePath = files[name];
|
||||||
let imported = await fsReadFile(filePath, 'utf8');
|
let imported = await fsReadFile(filePath, 'utf8');
|
||||||
imported = await processImports(files, name, imported);
|
imported = await processImports(files, name, imported);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ Themes.get = async () => {
|
|||||||
|
|
||||||
let themes = await getThemes(themePath);
|
let themes = await getThemes(themePath);
|
||||||
themes = _.flatten(themes).filter(Boolean);
|
themes = _.flatten(themes).filter(Boolean);
|
||||||
themes = await Promise.all(themes.map(async (theme) => {
|
themes = await Promise.all(themes.map(async theme => {
|
||||||
const config = path.join(themePath, theme, 'theme.json');
|
const config = path.join(themePath, theme, 'theme.json');
|
||||||
try {
|
try {
|
||||||
const file = await fsReadfile(config, 'utf8');
|
const file = await fsReadfile(config, 'utf8');
|
||||||
@@ -61,7 +61,7 @@ Themes.get = async () => {
|
|||||||
async function getThemes(themePath) {
|
async function getThemes(themePath) {
|
||||||
let dirs = await fsReaddir(themePath);
|
let dirs = await fsReaddir(themePath);
|
||||||
dirs = dirs.filter(dir => themeNamePattern.test(dir) || dir.startsWith('@'));
|
dirs = dirs.filter(dir => themeNamePattern.test(dir) || dir.startsWith('@'));
|
||||||
return await Promise.all(dirs.map(async (dir) => {
|
return await Promise.all(dirs.map(async dir => {
|
||||||
try {
|
try {
|
||||||
const dirpath = path.join(themePath, dir);
|
const dirpath = path.join(themePath, dir);
|
||||||
const stat = await fsStat(dirpath);
|
const stat = await fsStat(dirpath);
|
||||||
@@ -85,7 +85,7 @@ async function getThemes(themePath) {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
Themes.set = async (data) => {
|
Themes.set = async data => {
|
||||||
const themeData = {
|
const themeData = {
|
||||||
'theme:type': data.type,
|
'theme:type': data.type,
|
||||||
'theme:id': data.id,
|
'theme:id': data.id,
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ module.exports = function (middleware) {
|
|||||||
function (data, next) {
|
function (data, next) {
|
||||||
async.parallel({
|
async.parallel({
|
||||||
scripts: async.apply(plugins.fireHook, 'filter:scripts.get', []),
|
scripts: async.apply(plugins.fireHook, 'filter:scripts.get', []),
|
||||||
timeagoLocale: (next) => {
|
timeagoLocale: next => {
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
async.apply(languages.listCodes),
|
async.apply(languages.listCodes),
|
||||||
(languageCodes, next) => {
|
(languageCodes, next) => {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ module.exports = function (Plugins) {
|
|||||||
if (Array.isArray(data.method) && data.method.every(method => typeof method === 'function' || typeof method === 'string')) {
|
if (Array.isArray(data.method) && data.method.every(method => typeof method === 'function' || typeof method === 'string')) {
|
||||||
// Go go gadget recursion!
|
// Go go gadget recursion!
|
||||||
data.method.forEach(function (method) {
|
data.method.forEach(function (method) {
|
||||||
const singularData = Object.assign({}, data, { method: method });
|
const singularData = { ...data, method: method };
|
||||||
Plugins.registerHook(id, singularData);
|
Plugins.registerHook(id, singularData);
|
||||||
});
|
});
|
||||||
} else if (typeof data.method === 'string' && data.method.length > 0) {
|
} else if (typeof data.method === 'string' && data.method.length > 0) {
|
||||||
@@ -157,7 +157,7 @@ module.exports = function (Plugins) {
|
|||||||
next();
|
next();
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
const onError = (err) => {
|
const onError = err => {
|
||||||
winston.error('[plugins] Error executing \'' + hook + '\' in plugin \'' + hookObj.id + '\'');
|
winston.error('[plugins] Error executing \'' + hook + '\' in plugin \'' + hookObj.id + '\'');
|
||||||
winston.error(err);
|
winston.error(err);
|
||||||
clearTimeout(timeoutId);
|
clearTimeout(timeoutId);
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ module.exports = function (Plugins) {
|
|||||||
const fields = _.uniq(_.flatMap(targets, target => map[target] || []));
|
const fields = _.uniq(_.flatMap(targets, target => map[target] || []));
|
||||||
|
|
||||||
// clear old data before build
|
// clear old data before build
|
||||||
fields.forEach((field) => {
|
fields.forEach(field => {
|
||||||
switch (field) {
|
switch (field) {
|
||||||
case 'clientScripts':
|
case 'clientScripts':
|
||||||
case 'acpScripts':
|
case 'acpScripts':
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ module.exports = function (Posts) {
|
|||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
Posts.uploads.saveSize = async (filePaths) => {
|
Posts.uploads.saveSize = async filePaths => {
|
||||||
await Promise.all(filePaths.map(async function (fileName) {
|
await Promise.all(filePaths.map(async function (fileName) {
|
||||||
try {
|
try {
|
||||||
const size = await image.size(path.join(pathPrefix, fileName));
|
const size = await image.size(path.join(pathPrefix, fileName));
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ module.exports = function (Posts) {
|
|||||||
const bulkAdd = [];
|
const bulkAdd = [];
|
||||||
const bulkRemove = [];
|
const bulkRemove = [];
|
||||||
const postsByUser = {};
|
const postsByUser = {};
|
||||||
mainPosts.forEach((post) => {
|
mainPosts.forEach(post => {
|
||||||
bulkRemove.push(['cid:' + post.cid + ':uid:' + post.uid + ':tids', post.tid]);
|
bulkRemove.push(['cid:' + post.cid + ':uid:' + post.uid + ':tids', post.tid]);
|
||||||
bulkRemove.push(['uid:' + post.uid + ':topics', post.tid]);
|
bulkRemove.push(['uid:' + post.uid + ':topics', post.tid]);
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ function setupWinston() {
|
|||||||
formats.push(winston.format.timestamp());
|
formats.push(winston.format.timestamp());
|
||||||
formats.push(winston.format.json());
|
formats.push(winston.format.json());
|
||||||
} else {
|
} else {
|
||||||
const timestampFormat = winston.format((info) => {
|
const timestampFormat = winston.format(info => {
|
||||||
var dateString = new Date().toISOString() + ' [' + nconf.get('port') + '/' + global.process.pid + ']';
|
var dateString = new Date().toISOString() + ' [' + nconf.get('port') + '/' + global.process.pid + ']';
|
||||||
info.level = dateString + ' - ' + info.level;
|
info.level = dateString + ' - ' + info.level;
|
||||||
return info;
|
return info;
|
||||||
|
|||||||
@@ -148,8 +148,8 @@ helpers.giveOrRescind = async function (method, privileges, cids, groupNames) {
|
|||||||
cids = Array.isArray(cids) ? cids : [cids];
|
cids = Array.isArray(cids) ? cids : [cids];
|
||||||
for (const groupName of groupNames) {
|
for (const groupName of groupNames) {
|
||||||
const groupKeys = [];
|
const groupKeys = [];
|
||||||
cids.forEach((cid) => {
|
cids.forEach(cid => {
|
||||||
privileges.forEach((privilege) => {
|
privileges.forEach(privilege => {
|
||||||
groupKeys.push('cid:' + cid + ':privileges:groups:' + privilege);
|
groupKeys.push('cid:' + cid + ':privileges:groups:' + privilege);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ SocketModules.chats.getUsersInRoom = function (socket, data, callback) {
|
|||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
payload.users = payload.users.map((user) => {
|
payload.users = payload.users.map(user => {
|
||||||
user.canKick = (parseInt(user.uid, 10) !== parseInt(socket.uid, 10)) && payload.isOwner;
|
user.canKick = (parseInt(user.uid, 10) !== parseInt(socket.uid, 10)) && payload.isOwner;
|
||||||
return user;
|
return user;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ module.exports = function (Topics) {
|
|||||||
return tids.map(() => ({ following: false, ignoring: false }));
|
return tids.map(() => ({ following: false, ignoring: false }));
|
||||||
}
|
}
|
||||||
const keys = [];
|
const keys = [];
|
||||||
tids.forEach((tid) => {
|
tids.forEach(tid => {
|
||||||
keys.push('tid:' + tid + ':followers', 'tid:' + tid + ':ignorers');
|
keys.push('tid:' + tid + ':followers', 'tid:' + tid + ':ignorers');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ module.exports = function (User) {
|
|||||||
property = 'uid';
|
property = 'uid';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Array.isArray(set) || !set.length || !set.every((item) => {
|
if (!Array.isArray(set) || !set.length || !set.every(item => {
|
||||||
if (!item) {
|
if (!item) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ module.exports = function (User) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Append default data to this email payload
|
// Append default data to this email payload
|
||||||
data = Object.assign({}, emailer._defaultPayload, data);
|
data = { ...emailer._defaultPayload, ...data };
|
||||||
|
|
||||||
await emailer.sendToEmail('invitation', email, meta.config.defaultLang, data);
|
await emailer.sendToEmail('invitation', email, meta.config.defaultLang, data);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user