From 896c8c734321c606c8548e9b11ecba58ce1ccd28 Mon Sep 17 00:00:00 2001 From: Peter Jaszkowiak Date: Sat, 18 Feb 2017 12:30:49 -0700 Subject: [PATCH] ESlint object-curly-spacing --- .eslintrc | 4 +- bcrypt.js | 4 +- loader.js | 2 +- public/src/admin/extend/plugins.js | 2 +- public/src/admin/extend/rewards.js | 4 +- public/src/admin/general/dashboard.js | 4 +- public/src/admin/general/navigation.js | 6 +- public/src/admin/manage/category.js | 6 +- public/src/admin/manage/flags.js | 2 +- public/src/admin/manage/group.js | 6 +- public/src/admin/manage/registration.js | 4 +- public/src/admin/manage/tags.js | 6 +- public/src/admin/manage/users.js | 2 +- public/src/admin/settings/email.js | 2 +- public/src/ajaxify.js | 12 +- public/src/app.js | 4 +- public/src/client/account/edit.js | 4 +- public/src/client/account/info.js | 2 +- public/src/client/account/posts.js | 2 +- public/src/client/account/profile.js | 2 +- public/src/client/account/settings.js | 2 +- public/src/client/account/topics.js | 4 +- public/src/client/categories.js | 4 +- public/src/client/category.js | 10 +- public/src/client/category/tools.js | 12 +- public/src/client/chats.js | 10 +- public/src/client/groups/memberlist.js | 2 +- public/src/client/infinitescroll.js | 2 +- public/src/client/notifications.js | 2 +- public/src/client/recent.js | 6 +- public/src/client/tags.js | 4 +- public/src/client/topic/events.js | 4 +- public/src/client/topic/flag.js | 2 +- public/src/client/topic/move-post.js | 2 +- public/src/client/topic/move.js | 2 +- public/src/client/topic/postTools.js | 4 +- public/src/client/topic/posts.js | 8 +- public/src/client/topic/replies.js | 4 +- public/src/client/topic/threadTools.js | 16 +- public/src/client/topic/votes.js | 2 +- public/src/client/unread.js | 2 +- public/src/client/users.js | 2 +- public/src/installer/install.js | 2 +- public/src/modules/autocomplete.js | 2 +- public/src/modules/chat.js | 4 +- public/src/modules/notifications.js | 2 +- public/src/modules/pictureCropper.js | 2 +- public/src/modules/share.js | 2 +- public/src/modules/uploader.js | 2 +- public/src/overrides.js | 2 +- src/analytics.js | 2 +- src/categories.js | 4 +- src/categories/create.js | 2 +- src/categories/delete.js | 2 +- src/categories/recentreplies.js | 2 +- src/categories/topics.js | 8 +- src/categories/update.js | 4 +- src/controllers/accounts/chats.js | 8 +- src/controllers/accounts/edit.js | 10 +- src/controllers/accounts/follow.js | 2 +- src/controllers/accounts/groups.js | 2 +- src/controllers/accounts/helpers.js | 4 +- src/controllers/accounts/info.js | 2 +- src/controllers/accounts/notifications.js | 2 +- src/controllers/accounts/posts.js | 2 +- src/controllers/accounts/profile.js | 4 +- src/controllers/accounts/settings.js | 18 +- src/controllers/admin/groups.js | 6 +- src/controllers/admin/homepage.js | 4 +- src/controllers/admin/info.js | 4 +- src/controllers/admin/tags.js | 2 +- src/controllers/admin/uploads.js | 10 +- src/controllers/admin/users.js | 2 +- src/controllers/api.js | 2 +- src/controllers/authentication.js | 10 +- src/controllers/categories.js | 2 +- src/controllers/groups.js | 12 +- src/controllers/helpers.js | 2 +- src/controllers/index.js | 22 +-- src/controllers/popular.js | 4 +- src/controllers/recent.js | 4 +- src/controllers/search.js | 6 +- src/controllers/tags.js | 4 +- src/controllers/topics.js | 4 +- src/controllers/unread.js | 4 +- src/controllers/uploads.js | 10 +- src/controllers/users.js | 18 +- src/database/mongo/hash.js | 20 +-- src/database/mongo/list.js | 12 +- src/database/mongo/main.js | 12 +- src/database/mongo/sets.js | 24 +-- src/database/mongo/sorted.js | 64 +++---- src/database/mongo/sorted/add.js | 6 +- src/database/mongo/sorted/intersect.js | 16 +- src/database/mongo/sorted/remove.js | 10 +- src/database/mongo/sorted/union.js | 10 +- src/database/redis/sorted.js | 6 +- src/database/redis/sorted/intersect.js | 2 +- src/database/redis/sorted/union.js | 2 +- src/events.js | 2 +- src/groups.js | 8 +- src/groups/cover.js | 2 +- src/groups/create.js | 2 +- src/groups/membership.js | 2 +- src/groups/ownership.js | 4 +- src/groups/search.js | 2 +- src/install.js | 2 +- src/logger.js | 8 +- src/messaging.js | 2 +- src/messaging/rooms.js | 4 +- src/meta.js | 2 +- src/meta/js.js | 2 +- src/middleware/admin.js | 4 +- src/middleware/header.js | 10 +- src/middleware/index.js | 2 +- src/middleware/render.js | 6 +- src/middleware/user.js | 2 +- src/notifications.js | 6 +- src/pagination.js | 16 +- src/password.js | 6 +- src/plugins.js | 2 +- src/plugins/install.js | 6 +- src/posts.js | 12 +- src/posts/create.js | 2 +- src/posts/delete.js | 10 +- src/posts/edit.js | 4 +- src/posts/flags.js | 8 +- src/posts/parse.js | 4 +- src/posts/recent.js | 2 +- src/posts/summary.js | 4 +- src/posts/user.js | 2 +- src/posts/votes.js | 6 +- src/privileges/categories.js | 24 +-- src/privileges/posts.js | 18 +- src/privileges/users.js | 2 +- src/pubsub.js | 2 +- src/rewards/index.js | 4 +- src/routes/authentication.js | 2 +- src/search.js | 4 +- src/sitemap.js | 2 +- src/socket.io/admin.js | 2 +- src/socket.io/admin/categories.js | 2 +- src/socket.io/admin/rooms.js | 8 +- src/socket.io/admin/user.js | 2 +- src/socket.io/groups.js | 2 +- src/socket.io/helpers.js | 2 +- src/socket.io/index.js | 6 +- src/socket.io/modules.js | 4 +- src/socket.io/notifications.js | 2 +- src/socket.io/posts/flag.js | 2 +- src/socket.io/posts/helpers.js | 2 +- src/socket.io/posts/tools.js | 10 +- src/socket.io/topics.js | 4 +- src/socket.io/topics/tags.js | 2 +- src/socket.io/topics/tools.js | 2 +- src/socket.io/user.js | 2 +- src/socket.io/user/profile.js | 4 +- src/socket.io/user/status.js | 2 +- src/topics.js | 8 +- src/topics/bookmarks.js | 2 +- src/topics/create.js | 2 +- src/topics/delete.js | 2 +- src/topics/follow.js | 2 +- src/topics/fork.js | 4 +- src/topics/posts.js | 2 +- src/topics/recent.js | 4 +- src/topics/tags.js | 16 +- src/topics/teaser.js | 2 +- src/topics/thumb.js | 2 +- src/topics/tools.js | 2 +- src/user.js | 6 +- src/user/admin.js | 2 +- src/user/approval.js | 4 +- src/user/auth.js | 2 +- src/user/bans.js | 4 +- src/user/create.js | 2 +- src/user/data.js | 8 +- src/user/delete.js | 6 +- src/user/email.js | 4 +- src/user/notifications.js | 2 +- src/user/picture.js | 22 +-- src/user/profile.js | 4 +- src/user/search.js | 4 +- src/user/settings.js | 4 +- src/widgets/admin.js | 4 +- src/widgets/index.js | 8 +- test/authentication.js | 4 +- test/categories.js | 82 ++++----- test/controllers-admin.js | 96 +++++------ test/controllers.js | 46 ++--- test/database/hash.js | 18 +- test/database/sorted.js | 20 +-- test/groups.js | 96 +++++------ test/helpers/index.js | 4 +- test/messaging.js | 36 ++-- test/meta.js | 20 +-- test/notifications.js | 28 ++-- test/pagination.js | 2 +- test/plugins.js | 14 +- test/posts.js | 86 +++++----- test/rewards.js | 2 +- test/search.js | 4 +- test/socket.io.js | 66 ++++---- test/topics.js | 194 +++++++++++----------- test/uploads.js | 12 +- test/user.js | 102 ++++++------ test/utils.js | 4 +- 207 files changed, 971 insertions(+), 971 deletions(-) diff --git a/.eslintrc b/.eslintrc index cef86e196d..0b1eb32844 100644 --- a/.eslintrc +++ b/.eslintrc @@ -46,6 +46,7 @@ "no-prototype-builtins": "off", "vars-on-top": "off", "no-restricted-syntax": "off", + "no-shadow": "off", // "linebreak-style": "off", // "one-var": "off", @@ -95,8 +96,7 @@ "no-restricted-module": "off", "no-return-assign": "off", "no-restricted-modules": "off", - "object-curly-spacing": "off", - "no-shadow": "off", + // "object-curly-spacing": "off", // "indent": "off", // "padded-blocks": "off", // "eol-last": "off", diff --git a/bcrypt.js b/bcrypt.js index c948b8faa5..40a493e75d 100644 --- a/bcrypt.js +++ b/bcrypt.js @@ -26,9 +26,9 @@ function hashPassword(password, rounds) { function done(err, result) { if (err) { - process.send({err: err.message}); + process.send({ err: err.message }); return process.disconnect(); } - process.send({result: result}); + process.send({ result: result }); process.disconnect(); } diff --git a/loader.js b/loader.js index 0eaf9a12df..7cfefbf259 100644 --- a/loader.js +++ b/loader.js @@ -153,7 +153,7 @@ Loader.restart = function () { nconf.remove('file'); nconf.use('file', { file: pathToConfig }); - fs.readFile(pathToConfig, {encoding: 'utf-8'}, function (err, configFile) { + fs.readFile(pathToConfig, { encoding: 'utf-8' }, function (err, configFile) { if (err) { console.log('Error reading config : ' + err.message); process.exit(); diff --git a/public/src/admin/extend/plugins.js b/public/src/admin/extend/plugins.js index 135a9f05e0..1419a76555 100644 --- a/public/src/admin/extend/plugins.js +++ b/public/src/admin/extend/plugins.js @@ -145,7 +145,7 @@ define('admin/extend/plugins', ['jqueryui', 'translator'], function (jqueryui, t var plugins = $('#order-active-plugins-modal .plugin-list').children(); var data = []; plugins.each(function (index, el) { - data.push({name: $(el).text(), order: index}); + data.push({ name: $(el).text(), order: index }); }); socket.emit('admin.plugins.orderActivePlugins', data, function (err) { diff --git a/public/src/admin/extend/rewards.js b/public/src/admin/extend/rewards.js index 7a40a7ef59..e2858af2e8 100644 --- a/public/src/admin/extend/rewards.js +++ b/public/src/admin/extend/rewards.js @@ -28,7 +28,7 @@ define('admin/extend/rewards', ['translator'], function (translator) { var parent = $(this).parents('[data-id]'); var id = parent.attr('data-id'); - socket.emit('admin.rewards.delete', {id: id}, function (err) { + socket.emit('admin.rewards.delete', { id: id }, function (err) { if (err) { app.alertError(err.message); } else { @@ -153,7 +153,7 @@ define('admin/extend/rewards', ['translator'], function (translator) { var activeRewards = []; $('#active li').each(function () { - var data = {rewards: {}}; + var data = { rewards: {} }; var main = $(this).find('form.main').serializeArray(); var rewards = $(this).find('form.rewards').serializeArray(); diff --git a/public/src/admin/general/dashboard.js b/public/src/admin/general/dashboard.js index cdd12aa5c6..d332b35a0f 100644 --- a/public/src/admin/general/dashboard.js +++ b/public/src/admin/general/dashboard.js @@ -374,10 +374,10 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator'], function (s function updateTopicsGraph(topics) { if (!Object.keys(topics).length) { - topics = {0: { + topics = { 0: { title: 'No users browsing', value: 1, - }}; + } }; } var tids = Object.keys(topics); diff --git a/public/src/admin/general/navigation.js b/public/src/admin/general/navigation.js index ad9f5bc676..50da0f952b 100644 --- a/public/src/admin/general/navigation.js +++ b/public/src/admin/general/navigation.js @@ -63,12 +63,12 @@ define('admin/general/navigation', ['translator', 'iconSelect', 'jqueryui'], fun function drop(ev, ui) { var id = ui.helper.attr('data-id'); var el = $('#active-navigation [data-id="' + id + '"]'); - var data = id === 'custom' ? {iconClass: 'fa-navicon'} : available[id]; + var data = id === 'custom' ? { iconClass: 'fa-navicon' } : available[id]; data.enabled = false; data.index = (parseInt($('#enabled').children().last().attr('data-index'), 10) || 0) + 1; - templates.parse('admin/general/navigation', 'navigation', {navigation: [data]}, function (li) { + templates.parse('admin/general/navigation', 'navigation', { navigation: [data] }, function (li) { translator.translate(li, function (li) { li = $(translator.unescape(li)); el.after(li); @@ -76,7 +76,7 @@ define('admin/general/navigation', ['translator', 'iconSelect', 'jqueryui'], fun }); }); - templates.parse('admin/general/navigation', 'enabled', {enabled: [data]}, function (li) { + templates.parse('admin/general/navigation', 'enabled', { enabled: [data] }, function (li) { translator.translate(li, function (li) { li = $(translator.unescape(li)); $('#enabled').append(li); diff --git a/public/src/admin/manage/category.js b/public/src/admin/manage/category.js index 41c9eceff0..e70b858afa 100644 --- a/public/src/admin/manage/category.js +++ b/public/src/admin/manage/category.js @@ -134,7 +134,7 @@ define('admin/manage/category', [ $('.copy-settings').on('click', function () { selectCategoryModal(function (cid) { - socket.emit('admin.categories.copySettingsFrom', {fromCid: cid, toCid: ajaxify.data.category.cid}, function (err) { + socket.emit('admin.categories.copySettingsFrom', { fromCid: cid, toCid: ajaxify.data.category.cid }, function (err) { if (err) { return app.alertError(err.message); } @@ -152,7 +152,7 @@ define('admin/manage/category', [ uploader.show({ title: '[[admin/manage/categories:alert.upload-image]]', route: config.relative_path + '/api/admin/category/uploadpicture', - params: {cid: cid}, + params: { cid: cid }, }, function (imageUrlOnServer) { $('#category-image').val(imageUrlOnServer); var previewBox = inputEl.parent().parent().siblings('.category-preview'); @@ -434,7 +434,7 @@ define('admin/manage/category', [ Category.copyPrivilegesFromCategory = function () { selectCategoryModal(function (cid) { - socket.emit('admin.categories.copyPrivilegesFrom', {toCid: ajaxify.data.category.cid, fromCid: cid}, function (err) { + socket.emit('admin.categories.copyPrivilegesFrom', { toCid: ajaxify.data.category.cid, fromCid: cid }, function (err) { if (err) { return app.alertError(err.message); } diff --git a/public/src/admin/manage/flags.js b/public/src/admin/manage/flags.js index af44392a7d..a420540f99 100644 --- a/public/src/admin/manage/flags.js +++ b/public/src/admin/manage/flags.js @@ -62,7 +62,7 @@ define('admin/manage/flags', [ } var pid = btn.parents('[data-pid]').attr('data-pid'); var tid = btn.parents('[data-pid]').attr('data-tid'); - socket.emit('posts.delete', {pid: pid, tid: tid}, function (err) { + socket.emit('posts.delete', { pid: pid, tid: tid }, function (err) { done(err, btn); }); }); diff --git a/public/src/admin/manage/group.js b/public/src/admin/manage/group.js index 0a7b6e0247..f2e5c8c92e 100644 --- a/public/src/admin/manage/group.js +++ b/public/src/admin/manage/group.js @@ -40,7 +40,7 @@ define('admin/manage/group', [ var searchText = groupDetailsSearch.val(); var foundUser; - socket.emit('admin.user.search', {query: searchText}, function (err, results) { + socket.emit('admin.user.search', { query: searchText }, function (err, results) { if (!err && results && results.users.length > 0) { var numResults = results.users.length; var x; @@ -53,7 +53,7 @@ define('admin/manage/group', [ for (x = 0; x < numResults; x += 1) { foundUser = $('
  • '); foundUser - .attr({title: results.users[x].username, + .attr({ title: results.users[x].username, 'data-uid': results.users[x].uid, 'data-username': results.users[x].username, 'data-userslug': results.users[x].userslug, @@ -96,7 +96,7 @@ define('admin/manage/group', [ 'icon:text': userLabel.attr('data-usericon-text'), }; - templates.parse('partials/groups/memberlist', 'members', {group: {isOwner: ajaxify.data.group.isOwner, members: [member]}}, function (html) { + templates.parse('partials/groups/memberlist', 'members', { group: { isOwner: ajaxify.data.group.isOwner, members: [member] } }, function (html) { translator.translate(html, function (html) { $('[component="groups/members"] tbody').prepend(html); }); diff --git a/public/src/admin/manage/registration.js b/public/src/admin/manage/registration.js index 3107e6c19f..2db0e5c6bf 100644 --- a/public/src/admin/manage/registration.js +++ b/public/src/admin/manage/registration.js @@ -11,7 +11,7 @@ define('admin/manage/registration', function () { var username = parent.attr('data-username'); var method = action === 'accept' ? 'admin.user.acceptRegistration' : 'admin.user.rejectRegistration'; - socket.emit(method, {username: username}, function (err) { + socket.emit(method, { username: username }, function (err) { if (err) { return app.alertError(err.message); } @@ -39,7 +39,7 @@ define('admin/manage/registration', function () { if (action === 'delete') { bootbox.confirm('[[admin/manage/registration:invitations.confirm-delete]]', function (confirm) { if (confirm) { - socket.emit(method, {email: email, invitedBy: invitedBy}, function (err) { + socket.emit(method, { email: email, invitedBy: invitedBy }, function (err) { if (err) { return app.alertError(err.message); } diff --git a/public/src/admin/manage/tags.js b/public/src/admin/manage/tags.js index 4b73f20609..e20bd72276 100644 --- a/public/src/admin/manage/tags.js +++ b/public/src/admin/manage/tags.js @@ -61,12 +61,12 @@ define('admin/manage/tags', [ } timeoutId = setTimeout(function () { - socket.emit('topics.searchAndLoadTags', {query: $('#tag-search').val()}, function (err, result) { + socket.emit('topics.searchAndLoadTags', { query: $('#tag-search').val() }, function (err, result) { if (err) { return app.alertError(err.message); } - app.parseAndTranslate('admin/manage/tags', 'tags', {tags: result.tags}, function (html) { + app.parseAndTranslate('admin/manage/tags', 'tags', { tags: result.tags }, function (html) { $('.tag-list').html(html); utils.makeNumbersHumanReadable(html.find('.human-readable-number')); timeoutId = 0; @@ -133,7 +133,7 @@ define('admin/manage/tags', [ tagsToDelete.each(function (index, el) { tags.push($(el).attr('data-tag')); }); - socket.emit('admin.tags.deleteTags', {tags: tags}, function (err) { + socket.emit('admin.tags.deleteTags', { tags: tags }, function (err) { if (err) { return app.alertError(err.message); } diff --git a/public/src/admin/manage/users.js b/public/src/admin/manage/users.js index 75f2ce700a..604af20bbc 100644 --- a/public/src/admin/manage/users.js +++ b/public/src/admin/manage/users.js @@ -327,7 +327,7 @@ define('admin/manage/users', ['translator'], function (translator) { timeoutId = setTimeout(function () { $('.fa-spinner').removeClass('hidden'); - socket.emit('admin.user.search', {searchBy: type, query: $this.val()}, function (err, data) { + socket.emit('admin.user.search', { searchBy: type, query: $this.val() }, function (err, data) { if (err) { return app.alertError(err.message); } diff --git a/public/src/admin/settings/email.js b/public/src/admin/settings/email.js index ab989903d0..4e75c10fb7 100644 --- a/public/src/admin/settings/email.js +++ b/public/src/admin/settings/email.js @@ -17,7 +17,7 @@ define('admin/settings/email', ['admin/settings'], function (settings) { function configureEmailTester() { $('button[data-action="email.test"]').off('click').on('click', function () { - socket.emit('admin.email.test', {template: $('#test-email').val()}, function (err) { + socket.emit('admin.email.test', { template: $('#test-email').val() }, function (err) { if (err) { return app.alertError(err.message); } diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 7ab91acdbc..3125373d02 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -29,7 +29,7 @@ $(document).ready(function () { }, ev.state.returnPath, config.relative_path + '/' + ev.state.returnPath); } else if (ev.state.url !== undefined) { ajaxify.go(ev.state.url, function () { - $(window).trigger('action:popstate', {url: ev.state.url}); + $(window).trigger('action:popstate', { url: ev.state.url }); }, true); } } @@ -73,7 +73,7 @@ $(document).ready(function () { // If any listeners alter url and set it to an empty string, abort the ajaxification if (url === null) { - $(window).trigger('action:ajaxify.end', {url: url, tpl_url: ajaxify.data.template.name, title: ajaxify.data.title}); + $(window).trigger('action:ajaxify.end', { url: url, tpl_url: ajaxify.data.template.name, title: ajaxify.data.title }); return false; } @@ -196,7 +196,7 @@ $(document).ready(function () { function done() { count -= 1; if (count === 0) { - $(window).trigger('action:ajaxify.end', {url: url, tpl_url: tpl_url, title: ajaxify.data.title}); + $(window).trigger('action:ajaxify.end', { url: url, tpl_url: tpl_url, title: ajaxify.data.title }); } } var count = 2; @@ -205,7 +205,7 @@ $(document).ready(function () { ajaxify.widgets.render(tpl_url, url, done); - $(window).trigger('action:ajaxify.contentLoaded', {url: url, tpl: tpl_url}); + $(window).trigger('action:ajaxify.contentLoaded', { url: url, tpl: tpl_url }); app.processPage(); @@ -284,7 +284,7 @@ $(document).ready(function () { ajaxify.loadData = function (url, callback) { url = ajaxify.removeRelativePath(url); - $(window).trigger('action:ajaxify.loadingData', {url: url}); + $(window).trigger('action:ajaxify.loadingData', { url: url }); apiXHR = $.ajax({ url: RELATIVE_PATH + '/api/' + url, @@ -300,7 +300,7 @@ $(document).ready(function () { ajaxify.data = data; data.config = config; - $(window).trigger('action:ajaxify.dataLoaded', {url: url, data: data}); + $(window).trigger('action:ajaxify.dataLoaded', { url: url, data: data }); callback(null, data); }, diff --git a/public/src/app.js b/public/src/app.js index 48f65ac752..4da97aee00 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -326,7 +326,7 @@ app.cacheBuster = null; if (chat.modalExists(roomId)) { loadAndCenter(chat.getModal(roomId)); } else { - socket.emit('modules.chats.loadRoom', {roomId: roomId, uid: uid || app.user.uid}, function (err, roomData) { + socket.emit('modules.chats.loadRoom', { roomId: roomId, uid: uid || app.user.uid }, function (err, roomData) { if (err) { return app.alertError(err.message); } @@ -350,7 +350,7 @@ app.cacheBuster = null; return app.alertError('[[error:cant-chat-with-yourself]]'); } - socket.emit('modules.chats.newRoom', {touid: touid}, function (err, roomId) { + socket.emit('modules.chats.newRoom', { touid: touid }, function (err, roomId) { if (err) { return app.alertError(err.message); } diff --git a/public/src/client/account/edit.js b/public/src/client/account/edit.js index f70e692f45..ddee32f3f4 100644 --- a/public/src/client/account/edit.js +++ b/public/src/client/account/edit.js @@ -70,7 +70,7 @@ define('forum/account/edit', ['forum/account/header', 'translator', 'components' function handleImageChange() { $('#changePictureBtn').on('click', function () { - socket.emit('user.getProfilePictures', {uid: ajaxify.data.uid}, function (err, pictures) { + socket.emit('user.getProfilePictures', { uid: ajaxify.data.uid }, function (err, pictures) { if (err) { return app.alertError(err.message); } @@ -259,7 +259,7 @@ define('forum/account/edit', ['forum/account/header', 'translator', 'components' }); modal.find('[data-action="remove-uploaded"]').on('click', function () { - socket.emit('user.removeUploadedPicture', {uid: ajaxify.data.theirid}, function (err) { + socket.emit('user.removeUploadedPicture', { uid: ajaxify.data.theirid }, function (err) { modal.modal('hide'); if (err) { return app.alertError(err.message); diff --git a/public/src/client/account/info.js b/public/src/client/account/info.js index 38f3111b83..f366c0a3e7 100644 --- a/public/src/client/account/info.js +++ b/public/src/client/account/info.js @@ -13,7 +13,7 @@ define('forum/account/info', ['forum/account/header', 'components'], function (h function handleModerationNote() { $('[component="account/save-moderation-note"]').on('click', function () { var note = $('[component="account/moderation-note"]').val(); - socket.emit('user.setModerationNote', {uid: ajaxify.data.uid, note: note}, function (err) { + socket.emit('user.setModerationNote', { uid: ajaxify.data.uid, note: note }, function (err) { if (err) { return app.alertError(err.message); } diff --git a/public/src/client/account/posts.js b/public/src/client/account/posts.js index 3430fa3c98..e247905852 100644 --- a/public/src/client/account/posts.js +++ b/public/src/client/account/posts.js @@ -41,7 +41,7 @@ define('forum/account/posts', ['forum/account/header', 'forum/infinitescroll'], } function onPostsLoaded(posts, callback) { - app.parseAndTranslate(template, 'posts', {posts: posts}, function (html) { + app.parseAndTranslate(template, 'posts', { posts: posts }, function (html) { $('[component="posts"]').append(html); html.find('img:not(.not-responsive)').addClass('img-responsive'); html.find('.timeago').timeago(); diff --git a/public/src/client/account/profile.js b/public/src/client/account/profile.js index 9713b57122..9f57454e00 100644 --- a/public/src/client/account/profile.js +++ b/public/src/client/account/profile.js @@ -69,7 +69,7 @@ define('forum/account/profile', [ return callback(); } - app.parseAndTranslate('account/profile', 'posts', {posts: posts}, function (html) { + app.parseAndTranslate('account/profile', 'posts', { posts: posts }, function (html) { $('[component="posts"]').append(html); html.find('.timeago').timeago(); diff --git a/public/src/client/account/settings.js b/public/src/client/account/settings.js index fe3808ccd8..5a853e0da0 100644 --- a/public/src/client/account/settings.js +++ b/public/src/client/account/settings.js @@ -70,7 +70,7 @@ define('forum/account/settings', ['forum/account/header', 'components', 'sounds' } function saveSettings(settings) { - socket.emit('user.saveSettings', {uid: ajaxify.data.theirid, settings: settings}, function (err, newSettings) { + socket.emit('user.saveSettings', { uid: ajaxify.data.theirid, settings: settings }, function (err, newSettings) { if (err) { return app.alertError(err.message); } diff --git a/public/src/client/account/topics.js b/public/src/client/account/topics.js index 83bd4ef557..bdd7626902 100644 --- a/public/src/client/account/topics.js +++ b/public/src/client/account/topics.js @@ -41,12 +41,12 @@ define('forum/account/topics', ['forum/account/header', 'forum/infinitescroll'], } function onTopicsLoaded(topics, callback) { - app.parseAndTranslate('account/topics', 'topics', {topics: topics}, function (html) { + app.parseAndTranslate('account/topics', 'topics', { topics: topics }, function (html) { $('[component="category"]').append(html); html.find('.timeago').timeago(); app.createUserTooltips(); utils.makeNumbersHumanReadable(html.find('.human-readable-number')); - $(window).trigger('action:topics.loaded', {topics: topics}); + $(window).trigger('action:topics.loaded', { topics: topics }); callback(); }); } diff --git a/public/src/client/categories.js b/public/src/client/categories.js index 40f93b0dc6..30b22d5260 100644 --- a/public/src/client/categories.js +++ b/public/src/client/categories.js @@ -54,12 +54,12 @@ define('forum/categories', ['components', 'translator'], function (components, t recentPosts.last().remove(); } - $(window).trigger('action:posts.loaded', {posts: [post]}); + $(window).trigger('action:posts.loaded', { posts: [post] }); }); } function parseAndTranslate(posts, callback) { - templates.parse('categories', '(categories.)?posts', {categories: {posts: posts}}, function (html) { + templates.parse('categories', '(categories.)?posts', { categories: { posts: posts } }, function (html) { translator.translate(html, function (translatedHTML) { translatedHTML = $(translatedHTML); translatedHTML.find('.post-content img:not(.not-responsive)').addClass('img-responsive'); diff --git a/public/src/client/category.js b/public/src/client/category.js index af4f6dba8c..5b51c2249a 100644 --- a/public/src/client/category.js +++ b/public/src/client/category.js @@ -62,8 +62,8 @@ define('forum/category', [ handleIgnoreWatch(cid); - $(window).trigger('action:topics.loaded', {topics: ajaxify.data.topics}); - $(window).trigger('action:category.loaded', {cid: ajaxify.data.cid}); + $(window).trigger('action:topics.loaded', { topics: ajaxify.data.topics }); + $(window).trigger('action:category.loaded', { cid: ajaxify.data.cid }); }; function handleScrollToTopicIndex() { @@ -204,10 +204,10 @@ define('forum/category', [ var editable = !!$('.thread-tools').length; templates.parse('category', 'topics', { - privileges: {editable: editable}, + privileges: { editable: editable }, showSelect: editable, topics: [topic], - template: {category: true}, + template: { category: true }, }, function (html) { translator.translate(html, function (translatedHTML) { var topic = $(translatedHTML); @@ -354,7 +354,7 @@ define('forum/category', [ app.createUserTooltips(); utils.makeNumbersHumanReadable(html.find('.human-readable-number')); - $(window).trigger('action:topics.loaded', {topics: data.topics}); + $(window).trigger('action:topics.loaded', { topics: data.topics }); callback(); }); diff --git a/public/src/client/category/tools.js b/public/src/client/category/tools.js index 0f8c009e06..0f0dc7b77d 100644 --- a/public/src/client/category/tools.js +++ b/public/src/client/category/tools.js @@ -35,7 +35,7 @@ define('forum/category/tools', [ components.get('topic/lock').on('click', function () { var tids = topicSelect.getSelectedTids(); if (tids.length) { - socket.emit('topics.lock', {tids: tids, cid: CategoryTools.cid}, onCommandComplete); + socket.emit('topics.lock', { tids: tids, cid: CategoryTools.cid }, onCommandComplete); } return false; }); @@ -43,7 +43,7 @@ define('forum/category/tools', [ components.get('topic/unlock').on('click', function () { var tids = topicSelect.getSelectedTids(); if (tids.length) { - socket.emit('topics.unlock', {tids: tids, cid: CategoryTools.cid}, onCommandComplete); + socket.emit('topics.unlock', { tids: tids, cid: CategoryTools.cid }, onCommandComplete); } return false; }); @@ -51,7 +51,7 @@ define('forum/category/tools', [ components.get('topic/pin').on('click', function () { var tids = topicSelect.getSelectedTids(); if (tids.length) { - socket.emit('topics.pin', {tids: tids, cid: CategoryTools.cid}, onCommandComplete); + socket.emit('topics.pin', { tids: tids, cid: CategoryTools.cid }, onCommandComplete); } return false; }); @@ -59,7 +59,7 @@ define('forum/category/tools', [ components.get('topic/unpin').on('click', function () { var tids = topicSelect.getSelectedTids(); if (tids.length) { - socket.emit('topics.unpin', {tids: tids, cid: CategoryTools.cid}, onCommandComplete); + socket.emit('topics.unpin', { tids: tids, cid: CategoryTools.cid }, onCommandComplete); } return false; }); @@ -123,7 +123,7 @@ define('forum/category/tools', [ return; } - socket.emit('topics.' + command, {tids: tids, cid: CategoryTools.cid}, onDeletePurgeComplete); + socket.emit('topics.' + command, { tids: tids, cid: CategoryTools.cid }, onDeletePurgeComplete); }); }); } @@ -250,7 +250,7 @@ define('forum/category/tools', [ var pinnedTopics = $('[component="category/topic"].pinned'); pinnedTopics.each(function (index, element) { - data.push({tid: $(element).attr('data-tid'), order: pinnedTopics.length - index - 1}); + data.push({ tid: $(element).attr('data-tid'), order: pinnedTopics.length - index - 1 }); }); socket.emit('topics.orderPinnedTopics', data, function (err) { diff --git a/public/src/client/chats.js b/public/src/client/chats.js index 4879485993..4f212b3f77 100644 --- a/public/src/client/chats.js +++ b/public/src/client/chats.js @@ -98,7 +98,7 @@ define('forum/chats', [ } loading = true; var start = parseInt($('.chat-content').children('[data-index]').first().attr('data-index'), 10) + 1; - socket.emit('modules.chats.getMessages', {roomId: roomId, uid: uid, start: start}, function (err, data) { + socket.emit('modules.chats.getMessages', { roomId: roomId, uid: uid, start: start }, function (err, data) { if (err) { return app.alertError(err.message); } @@ -170,7 +170,7 @@ define('forum/chats', [ if (oldName === newName) { return; } - socket.emit('modules.chats.renameRoom', {roomId: roomId, newName: newName}, function (err) { + socket.emit('modules.chats.renameRoom', { roomId: roomId, newName: newName }, function (err) { if (err) { return app.alertError(err.message); } @@ -235,10 +235,10 @@ define('forum/chats', [ if (event.item === app.user.username) { return; } - socket.emit('modules.chats.addUserToRoom', {roomId: data.roomId, username: event.item}, function (err) { + socket.emit('modules.chats.addUserToRoom', { roomId: data.roomId, username: event.item }, function (err) { if (err) { app.alertError(err.message); - tagEl.tagsinput('remove', event.item, {nouser: true}); + tagEl.tagsinput('remove', event.item, { nouser: true }); } }); }); @@ -262,7 +262,7 @@ define('forum/chats', [ if (event.options && event.options.nouser) { return; } - socket.emit('modules.chats.removeUserFromRoom', {roomId: data.roomId, username: event.item}, function (err) { + socket.emit('modules.chats.removeUserFromRoom', { roomId: data.roomId, username: event.item }, function (err) { if (err) { return app.alertError(err.message); } diff --git a/public/src/client/groups/memberlist.js b/public/src/client/groups/memberlist.js index 6ab83ccbbc..a5231817b3 100644 --- a/public/src/client/groups/memberlist.js +++ b/public/src/client/groups/memberlist.js @@ -22,7 +22,7 @@ define('forum/groups/memberlist', ['components', 'forum/infinitescroll'], functi } searchInterval = setTimeout(function () { - socket.emit('groups.searchMembers', {groupName: groupName, query: query}, function (err, results) { + socket.emit('groups.searchMembers', { groupName: groupName, query: query }, function (err, results) { if (err) { return app.alertError(err.message); } diff --git a/public/src/client/infinitescroll.js b/public/src/client/infinitescroll.js index 208448d8a5..e2b52548aa 100644 --- a/public/src/client/infinitescroll.js +++ b/public/src/client/infinitescroll.js @@ -54,7 +54,7 @@ define('forum/infinitescroll', function () { } loadingMore = true; - var hookData = {method: method, data: data}; + var hookData = { method: method, data: data }; $(window).trigger('action:infinitescroll.loadmore', hookData); socket.emit(hookData.method, hookData.data, function (err, data) { diff --git a/public/src/client/notifications.js b/public/src/client/notifications.js index 97760b0e0f..fb61a53063 100644 --- a/public/src/client/notifications.js +++ b/public/src/client/notifications.js @@ -54,7 +54,7 @@ define('forum/notifications', ['components', 'notifications', 'forum/infinitescr if (!data.notifications || !data.notifications.length) { return done(); } - app.parseAndTranslate('notifications', 'notifications', {notifications: data.notifications}, function (html) { + app.parseAndTranslate('notifications', 'notifications', { notifications: data.notifications }, function (html) { notifList.append(html); html.find('.timeago').timeago(); done(); diff --git a/public/src/client/recent.js b/public/src/client/recent.js index 4acb4905ba..981baabd12 100644 --- a/public/src/client/recent.js +++ b/public/src/client/recent.js @@ -26,7 +26,7 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function (infinit infinitescroll.init(Recent.loadMoreTopics); } - $(window).trigger('action:topics.loaded', {topics: ajaxify.data.topics}); + $(window).trigger('action:topics.loaded', { topics: ajaxify.data.topics }); }; Recent.watchForNewPosts = function () { @@ -154,14 +154,14 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function (infinit return callback(); } - app.parseAndTranslate(templateName, 'topics', {topics: topics, showSelect: showSelect}, function (html) { + app.parseAndTranslate(templateName, 'topics', { topics: topics, showSelect: showSelect }, function (html) { $('#category-no-topics').remove(); $('[component="category"]').append(html); html.find('.timeago').timeago(); app.createUserTooltips(); utils.makeNumbersHumanReadable(html.find('.human-readable-number')); - $(window).trigger('action:topics.loaded', {topics: topics}); + $(window).trigger('action:topics.loaded', { topics: topics }); callback(); }); }; diff --git a/public/src/client/tags.js b/public/src/client/tags.js index fb57d4d553..9e1fec98b2 100644 --- a/public/src/client/tags.js +++ b/public/src/client/tags.js @@ -19,7 +19,7 @@ define('forum/tags', ['forum/infinitescroll'], function (infinitescroll) { } timeoutId = setTimeout(function () { - socket.emit('topics.searchAndLoadTags', {query: $('#tag-search').val()}, function (err, results) { + socket.emit('topics.searchAndLoadTags', { query: $('#tag-search').val() }, function (err, results) { if (err) { return app.alertError(err.message); } @@ -63,7 +63,7 @@ define('forum/tags', ['forum/infinitescroll'], function (infinitescroll) { function onTagsLoaded(tags, replace, callback) { callback = callback || function () {}; - app.parseAndTranslate('tags', 'tags', {tags: tags}, function (html) { + app.parseAndTranslate('tags', 'tags', { tags: tags }, function (html) { $('.tag-list')[replace ? 'html' : 'append'](html); utils.makeNumbersHumanReadable(html.find('.human-readable-number')); callback(); diff --git a/public/src/client/topic/events.js b/public/src/client/topic/events.js index d87aac6f75..f3e2d925c6 100644 --- a/public/src/client/topic/events.js +++ b/public/src/client/topic/events.js @@ -111,7 +111,7 @@ define('forum/topic/events', [ if (topicTitle.length && data.topic.title && topicTitle.html() !== data.topic.title) { ajaxify.data.title = data.topic.title; var newUrl = 'topic/' + data.topic.slug + (window.location.search ? window.location.search : ''); - history.replaceState({url: newUrl}, null, window.location.protocol + '//' + window.location.host + config.relative_path + '/' + newUrl); + history.replaceState({ url: newUrl }, null, window.location.protocol + '//' + window.location.host + config.relative_path + '/' + newUrl); topicTitle.fadeOut(250, function () { topicTitle.html(data.topic.title).fadeIn(250); @@ -149,7 +149,7 @@ define('forum/topic/events', [ }); if (data.topic.tags && tagsUpdated(data.topic.tags)) { - templates.parse('partials/post_bar', 'tags', {tags: data.topic.tags}, function (html) { + templates.parse('partials/post_bar', 'tags', { tags: data.topic.tags }, function (html) { var tags = $('.tags'); tags.fadeOut(250, function () { diff --git a/public/src/client/topic/flag.js b/public/src/client/topic/flag.js index c9904d3011..1d1c68a8c3 100644 --- a/public/src/client/topic/flag.js +++ b/public/src/client/topic/flag.js @@ -46,7 +46,7 @@ define('forum/topic/flag', [], function () { if (!pid || !reason) { return; } - socket.emit('posts.flag', {pid: pid, reason: reason}, function (err) { + socket.emit('posts.flag', { pid: pid, reason: reason }, function (err) { if (err) { return app.alertError(err.message); } diff --git a/public/src/client/topic/move-post.js b/public/src/client/topic/move-post.js index 3c848be9ff..bd9d542ead 100644 --- a/public/src/client/topic/move-post.js +++ b/public/src/client/topic/move-post.js @@ -44,7 +44,7 @@ define('forum/topic/move-post', [], function () { } function movePost(post, pid, tid, callback) { - socket.emit('posts.movePost', {pid: pid, tid: tid}, function (err) { + socket.emit('posts.movePost', { pid: pid, tid: tid }, function (err) { if (err) { app.alertError(err.message); return callback(); diff --git a/public/src/client/topic/move.js b/public/src/client/topic/move.js index 4d038637ca..1b5b3b6c8a 100644 --- a/public/src/client/topic/move.js +++ b/public/src/client/topic/move.js @@ -42,7 +42,7 @@ define('forum/topic/move', function () { } function parseModal(categories, callback) { - templates.parse('partials/move_thread_modal', {categories: []}, function (html) { + templates.parse('partials/move_thread_modal', { categories: [] }, function (html) { require(['translator'], function (translator) { translator.translate(html, function (html) { modal = $(html); diff --git a/public/src/client/topic/postTools.js b/public/src/client/topic/postTools.js index 206ebe0e6a..5753380171 100644 --- a/public/src/client/topic/postTools.js +++ b/public/src/client/topic/postTools.js @@ -38,7 +38,7 @@ define('forum/topic/postTools', [ var pid = postEl.attr('data-pid'); var index = parseInt(postEl.attr('data-index'), 10); - socket.emit('posts.loadPostTools', {pid: pid, cid: ajaxify.data.cid}, function (err, data) { + socket.emit('posts.loadPostTools', { pid: pid, cid: ajaxify.data.cid }, function (err, data) { if (err) { return app.alertError(err.message); } @@ -286,7 +286,7 @@ define('forum/topic/postTools', [ username = getUserName($(content)); range.detach(); } - return {text: selectedText, pid: selectedPid, username: username}; + return { text: selectedText, pid: selectedPid, username: username }; } function bookmarkPost(button, pid) { diff --git a/public/src/client/topic/posts.js b/public/src/client/topic/posts.js index 88fe8af9b9..eaaf4894ce 100644 --- a/public/src/client/topic/posts.js +++ b/public/src/client/topic/posts.js @@ -87,8 +87,8 @@ define('forum/topic/posts', [ } function updatePagination() { - $.get(config.relative_path + '/api/topic/pagination/' + ajaxify.data.tid, {page: ajaxify.data.pagination.currentPage}, function (paginationData) { - app.parseAndTranslate('partials/paginator', {pagination: paginationData}, function (html) { + $.get(config.relative_path + '/api/topic/pagination/' + ajaxify.data.tid, { page: ajaxify.data.pagination.currentPage }, function (paginationData) { + app.parseAndTranslate('partials/paginator', { pagination: paginationData }, function (html) { $('[component="pagination"]').after(html).remove(); }); }); @@ -174,7 +174,7 @@ define('forum/topic/posts', [ data.slug = ajaxify.data.slug; - $(window).trigger('action:posts.loading', {posts: data.posts, after: after, before: before}); + $(window).trigger('action:posts.loading', { posts: data.posts, after: after, before: before }); app.parseAndTranslate('topic', 'posts', data, function (html) { html = html.filter(function () { @@ -199,7 +199,7 @@ define('forum/topic/posts', [ infinitescroll.removeExtra($('[component="post"]'), direction, 40); - $(window).trigger('action:posts.loaded', {posts: data.posts}); + $(window).trigger('action:posts.loaded', { posts: data.posts }); Posts.processPage(html); diff --git a/public/src/client/topic/replies.js b/public/src/client/topic/replies.js index 3d2f0f72af..3156d44b63 100644 --- a/public/src/client/topic/replies.js +++ b/public/src/client/topic/replies.js @@ -46,9 +46,9 @@ define('forum/topic/replies', ['navigator', 'components', 'forum/topic/posts'], hideReplies: true, }; app.parseAndTranslate('topic', 'posts', tplData, function (html) { - $('
    ', {component: 'post/replies'}).html(html).hide().insertAfter(button).slideDown('fast'); + $('
    ', { component: 'post/replies' }).html(html).hide().insertAfter(button).slideDown('fast'); posts.processPage(html); - $(window).trigger('action:posts.loaded', {posts: data}); + $(window).trigger('action:posts.loaded', { posts: data }); }); }); } else if (close.is(':not(.hidden)')) { diff --git a/public/src/client/topic/threadTools.js b/public/src/client/topic/threadTools.js index ad5a262222..70065678f0 100644 --- a/public/src/client/topic/threadTools.js +++ b/public/src/client/topic/threadTools.js @@ -31,22 +31,22 @@ define('forum/topic/threadTools', [ }); topicContainer.on('click', '[component="topic/lock"]', function () { - socket.emit('topics.lock', {tids: [tid], cid: ajaxify.data.cid}); + socket.emit('topics.lock', { tids: [tid], cid: ajaxify.data.cid }); return false; }); topicContainer.on('click', '[component="topic/unlock"]', function () { - socket.emit('topics.unlock', {tids: [tid], cid: ajaxify.data.cid}); + socket.emit('topics.unlock', { tids: [tid], cid: ajaxify.data.cid }); return false; }); topicContainer.on('click', '[component="topic/pin"]', function () { - socket.emit('topics.pin', {tids: [tid], cid: ajaxify.data.cid}); + socket.emit('topics.pin', { tids: [tid], cid: ajaxify.data.cid }); return false; }); topicContainer.on('click', '[component="topic/unpin"]', function () { - socket.emit('topics.unpin', {tids: [tid], cid: ajaxify.data.cid}); + socket.emit('topics.unpin', { tids: [tid], cid: ajaxify.data.cid }); return false; }); @@ -91,7 +91,7 @@ define('forum/topic/threadTools', [ }); function changeWatching(type) { - socket.emit('topics.changeWatching', {tid: tid, type: type}, function (err) { + socket.emit('topics.changeWatching', { tid: tid, type: type }, function (err) { if (err) { return app.alert({ type: 'danger', @@ -118,7 +118,7 @@ define('forum/topic/threadTools', [ timeout: 5000, }); - $(window).trigger('action:topics.changeWatching', {tid: tid, type: type}); + $(window).trigger('action:topics.changeWatching', { tid: tid, type: type }); }); return false; @@ -133,7 +133,7 @@ define('forum/topic/threadTools', [ return; } - socket.emit('topics.loadTopicTools', {tid: ajaxify.data.tid, cid: ajaxify.data.cid}, function (err, data) { + socket.emit('topics.loadTopicTools', { tid: ajaxify.data.tid, cid: ajaxify.data.cid }, function (err, data) { if (err) { return app.alertError(err); } @@ -155,7 +155,7 @@ define('forum/topic/threadTools', [ return; } - socket.emit('topics.' + command, {tids: [tid], cid: ajaxify.data.cid}, function (err) { + socket.emit('topics.' + command, { tids: [tid], cid: ajaxify.data.cid }, function (err) { if (err) { app.alertError(err.message); } diff --git a/public/src/client/topic/votes.js b/public/src/client/topic/votes.js index 824cfeb2a1..d152d9f4a0 100644 --- a/public/src/client/topic/votes.js +++ b/public/src/client/topic/votes.js @@ -82,7 +82,7 @@ define('forum/topic/votes', ['components', 'translator'], function (components, }; Votes.showVotes = function (pid) { - socket.emit('posts.getVoters', {pid: pid, cid: ajaxify.data.cid}, function (err, data) { + socket.emit('posts.getVoters', { pid: pid, cid: ajaxify.data.cid }, function (err, data) { if (err) { if (err.message === '[[error:no-privileges]]') { return; diff --git a/public/src/client/unread.js b/public/src/client/unread.js index 4c1c65b7f1..f5b1dd73ed 100644 --- a/public/src/client/unread.js +++ b/public/src/client/unread.js @@ -19,7 +19,7 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', ' recent.watchForNewPosts(); - $(window).trigger('action:topics.loaded', {topics: ajaxify.data.topics}); + $(window).trigger('action:topics.loaded', { topics: ajaxify.data.topics }); $('#markSelectedRead').on('click', function () { var tids = topicSelect.getSelectedTids(); diff --git a/public/src/client/users.js b/public/src/client/users.js index 0074af2e8f..ab9ed7f5c5 100644 --- a/public/src/client/users.js +++ b/public/src/client/users.js @@ -98,7 +98,7 @@ define('forum/users', ['translator'], function (translator) { } function renderSearchResults(data) { - templates.parse('partials/paginator', {pagination: data.pagination}, function (html) { + templates.parse('partials/paginator', { pagination: data.pagination }, function (html) { $('.pagination-container').replaceWith(html); }); diff --git a/public/src/installer/install.js b/public/src/installer/install.js index 55661cd1b6..4dddbf9360 100644 --- a/public/src/installer/install.js +++ b/public/src/installer/install.js @@ -42,7 +42,7 @@ $('document').ready(function () { if ($('form .admin .error').length) { ev.preventDefault(); - $('html, body').animate({scrollTop: '0px'}, 400); + $('html, body').animate({ scrollTop: '0px' }, 400); return false; } else { diff --git a/public/src/modules/autocomplete.js b/public/src/modules/autocomplete.js index 3635932630..68cabdb45b 100644 --- a/public/src/modules/autocomplete.js +++ b/public/src/modules/autocomplete.js @@ -14,7 +14,7 @@ define('autocomplete', function () { }, select: onselect, source: function (request, response) { - socket.emit('user.search', {query: request.term}, function (err, result) { + socket.emit('user.search', { query: request.term }, function (err, result) { if (err) { return app.alertError(err.message); } diff --git a/public/src/modules/chat.js b/public/src/modules/chat.js index 8b493ff111..38591ac996 100644 --- a/public/src/modules/chat.js +++ b/public/src/modules/chat.js @@ -75,7 +75,7 @@ define('chat', [ }); } } else { - socket.emit('modules.chats.loadRoom', {roomId: data.roomId}, function (err, roomData) { + socket.emit('modules.chats.loadRoom', { roomId: data.roomId }, function (err, roomData) { if (err) { return app.alertError(err.message); } @@ -108,7 +108,7 @@ define('chat', [ }; module.loadChatsDropdown = function (chatsListEl) { - socket.emit('modules.chats.getRecentChats', {uid: app.user.uid, after: 0}, function (err, data) { + socket.emit('modules.chats.getRecentChats', { uid: app.user.uid, after: 0 }, function (err, data) { if (err) { return app.alertError(err.message); } diff --git a/public/src/modules/notifications.js b/public/src/modules/notifications.js index 4bd786bb19..22198c0db7 100644 --- a/public/src/modules/notifications.js +++ b/public/src/modules/notifications.js @@ -130,7 +130,7 @@ define('notifications', ['sounds', 'translator', 'components'], function (sound, } translator.toggleTimeagoShorthand(); - templates.parse('partials/notifications_list', {notifications: notifs}, function (html) { + templates.parse('partials/notifications_list', { notifications: notifs }, function (html) { notifList.translateHtml(html); }); }); diff --git a/public/src/modules/pictureCropper.js b/public/src/modules/pictureCropper.js index c5b8e155df..6f23edbef1 100644 --- a/public/src/modules/pictureCropper.js +++ b/public/src/modules/pictureCropper.js @@ -32,7 +32,7 @@ define('pictureCropper', ['translator', 'cropper'], function (translator, croppe module.handleImageCrop = function (data, callback) { $('#crop-picture-modal').remove(); - templates.parse('modals/crop_picture', {url: data.url}, function (cropperHtml) { + templates.parse('modals/crop_picture', { url: data.url }, function (cropperHtml) { translator.translate(cropperHtml, function (translated) { var cropperModal = $(translated); cropperModal.modal('show'); diff --git a/public/src/modules/share.js b/public/src/modules/share.js index f9d81a9690..fe45f26d0f 100644 --- a/public/src/modules/share.js +++ b/public/src/modules/share.js @@ -39,7 +39,7 @@ define('share', function () { return openShare('https://plus.google.com/share?url=', getPostUrl($(this)), 500, 570); }); - $(window).trigger('action:share.addHandlers', {openShare: openShare}); + $(window).trigger('action:share.addHandlers', { openShare: openShare }); }; function addHandler(selector, callback) { diff --git a/public/src/modules/uploader.js b/public/src/modules/uploader.js index e986065ed5..1b56dbb4b8 100644 --- a/public/src/modules/uploader.js +++ b/public/src/modules/uploader.js @@ -112,7 +112,7 @@ define('uploader', ['translator'], function (translator) { try { return $.parseJSON(response); } catch (e) { - return {error: '[[error:parse-error]]'}; + return { error: '[[error:parse-error]]' }; } } return response; diff --git a/public/src/overrides.js b/public/src/overrides.js index 27ba05c74b..262b6bcb02 100644 --- a/public/src/overrides.js +++ b/public/src/overrides.js @@ -84,7 +84,7 @@ if ('undefined' !== typeof window) { }); } }); - }(jQuery || {fn: {}})); + }(jQuery || { fn: {} })); (function () { // FIX FOR #1245 - https://github.com/NodeBB/NodeBB/issues/1245 diff --git a/src/analytics.js b/src/analytics.js index d0c4dd5b25..6a733b1a5f 100644 --- a/src/analytics.js +++ b/src/analytics.js @@ -178,7 +178,7 @@ Analytics.getMonthlyPageViews = function (callback) { if (err) { return callback(err); } - callback(null, {thisMonth: scores[0] || 0, lastMonth: scores[1] || 0}); + callback(null, { thisMonth: scores[0] || 0, lastMonth: scores[1] || 0 }); }); }; diff --git a/src/categories.js b/src/categories.js index 1297c0fc65..815049ad4c 100644 --- a/src/categories.js +++ b/src/categories.js @@ -57,7 +57,7 @@ var privileges = require('./privileges'); category.isIgnored = results.isIgnored[0]; category.topic_count = results.topicCount; - plugins.fireHook('filter:category.get', {category: category, uid: data.uid}, next); + plugins.fireHook('filter:category.get', { category: category, uid: data.uid }, next); }, function (data, next) { next(null, data.category); @@ -229,7 +229,7 @@ var privileges = require('./privileges'); Categories.getChildren = function (cids, uid, callback) { var categories = cids.map(function (cid) { - return {cid: cid}; + return { cid: cid }; }); async.each(categories, function (category, next) { diff --git a/src/categories/create.js b/src/categories/create.js index 5be36db37b..7be163bd5b 100644 --- a/src/categories/create.js +++ b/src/categories/create.js @@ -43,7 +43,7 @@ module.exports = function (Categories) { imageClass: 'cover', }; - plugins.fireHook('filter:category.create', {category: category, data: data}, next); + plugins.fireHook('filter:category.create', { category: category, data: data }, next); }, function (data, next) { category = data.category; diff --git a/src/categories/delete.js b/src/categories/delete.js index 58dcbcee41..4aad25846f 100644 --- a/src/categories/delete.js +++ b/src/categories/delete.js @@ -16,7 +16,7 @@ module.exports = function (Categories) { async.eachLimit(tids, 10, function (tid, next) { topics.purgePostsAndTopic(tid, uid, next); }, next); - }, {alwaysStartAt: 0}, next); + }, { alwaysStartAt: 0 }, next); }, function (next) { Categories.getPinnedTids('cid:' + cid + ':tids:pinned', 0, -1, next); diff --git a/src/categories/recentreplies.js b/src/categories/recentreplies.js index 4570a177fe..fa5a6cab7f 100644 --- a/src/categories/recentreplies.js +++ b/src/categories/recentreplies.js @@ -27,7 +27,7 @@ module.exports = function (Categories) { privileges.posts.filter('read', pids, uid, next); }, function (pids, next) { - posts.getPostSummaryByPids(pids, uid, {stripTags: true}, next); + posts.getPostSummaryByPids(pids, uid, { stripTags: true }, next); }, ], callback); }; diff --git a/src/categories/topics.js b/src/categories/topics.js index 4be2298b08..ea719651fb 100644 --- a/src/categories/topics.js +++ b/src/categories/topics.js @@ -20,17 +20,17 @@ module.exports = function (Categories) { }, function (topics, next) { if (!Array.isArray(topics) || !topics.length) { - return next(null, {topics: [], uid: data.uid}); + return next(null, { topics: [], uid: data.uid }); } for (var i = 0; i < topics.length; i += 1) { topics[i].index = data.start + i; } - plugins.fireHook('filter:category.topics.get', {cid: data.cid, topics: topics, uid: data.uid}, next); + plugins.fireHook('filter:category.topics.get', { cid: data.cid, topics: topics, uid: data.uid }, next); }, function (results, next) { - next(null, {topics: results.topics, nextStart: data.stop + 1}); + next(null, { topics: results.topics, nextStart: data.stop + 1 }); }, ], callback); }; @@ -64,7 +64,7 @@ module.exports = function (Categories) { stop = stop === -1 ? stop : start + normalTidsToGet - 1; if (Array.isArray(set)) { - db[reverse ? 'getSortedSetRevIntersect' : 'getSortedSetIntersect']({sets: set, start: start, stop: stop}, next); + db[reverse ? 'getSortedSetRevIntersect' : 'getSortedSetIntersect']({ sets: set, start: start, stop: stop }, next); } else { db[reverse ? 'getSortedSetRevRange' : 'getSortedSetRange'](set, start, stop, next); } diff --git a/src/categories/update.js b/src/categories/update.js index 1dc588405b..04bf0e2235 100644 --- a/src/categories/update.js +++ b/src/categories/update.js @@ -41,7 +41,7 @@ module.exports = function (Categories) { } }, function (next) { - plugins.fireHook('filter:category.update', {category: modifiedFields}, next); + plugins.fireHook('filter:category.update', { category: modifiedFields }, next); }, function (categoryData, next) { category = categoryData.category; @@ -57,7 +57,7 @@ module.exports = function (Categories) { }, next); }, function (next) { - plugins.fireHook('action:category.update', {cid: cid, modified: category}); + plugins.fireHook('action:category.update', { cid: cid, modified: category }); next(); }, ], callback); diff --git a/src/controllers/accounts/chats.js b/src/controllers/accounts/chats.js index d085ea1d4a..8ffac0a4dc 100644 --- a/src/controllers/accounts/chats.js +++ b/src/controllers/accounts/chats.js @@ -45,7 +45,7 @@ chatsController.get = function (req, res, callback) { nextStart: recentChats.nextStart, allowed: true, title: '[[pages:chats]]', - breadcrumbs: helpers.buildBreadcrumbs([{text: username, url: '/user/' + req.params.userslug}, {text: '[[pages:chats]]'}]), + breadcrumbs: helpers.buildBreadcrumbs([{ text: username, url: '/user/' + req.params.userslug }, { text: '[[pages:chats]]' }]), }); } messaging.isUserInRoom(req.uid, req.params.roomid, next); @@ -87,9 +87,9 @@ chatsController.get = function (req, res, callback) { room.usernames = messaging.generateUsernames(room.users, req.uid); room.title = room.roomName || room.usernames || '[[pages:chats]]'; room.breadcrumbs = helpers.buildBreadcrumbs([ - {text: username, url: '/user/' + req.params.userslug}, - {text: '[[pages:chats]]', url: '/user/' + req.params.userslug + '/chats'}, - {text: room.roomName || room.usernames || '[[pages:chats]]'}, + { text: username, url: '/user/' + req.params.userslug }, + { text: '[[pages:chats]]', url: '/user/' + req.params.userslug + '/chats' }, + { text: room.roomName || room.usernames || '[[pages:chats]]' }, ]); room.maximumUsersInChatRoom = parseInt(meta.config.maximumUsersInChatRoom, 10) || 0; room.maximumChatMessageLength = parseInt(meta.config.maximumChatMessageLength, 10) || 1000; diff --git a/src/controllers/accounts/edit.js b/src/controllers/accounts/edit.js index 3a5fabf5d3..740980ae8e 100644 --- a/src/controllers/accounts/edit.js +++ b/src/controllers/accounts/edit.js @@ -36,7 +36,7 @@ editController.get = function (req, res, callback) { }); userData.title = '[[pages:account/edit, ' + userData.username + ']]'; - userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: '[[user:edit]]'}]); + userData.breadcrumbs = helpers.buildBreadcrumbs([{ text: userData.username, url: '/user/' + userData.userslug }, { text: '[[user:edit]]' }]); userData.editButtons = []; plugins.fireHook('filter:user.account.edit', userData, function (err, userData) { @@ -76,9 +76,9 @@ function renderRoute(name, req, res, next) { userData.title = '[[pages:account/edit/' + name + ', ' + userData.username + ']]'; userData.breadcrumbs = helpers.buildBreadcrumbs([ - {text: userData.username, url: '/user/' + userData.userslug}, - {text: '[[user:edit]]', url: '/user/' + userData.userslug + '/edit'}, - {text: '[[user:' + name + ']]'}, + { text: userData.username, url: '/user/' + userData.userslug }, + { text: '[[user:edit]]', url: '/user/' + userData.userslug + '/edit' }, + { text: '[[user:' + name + ']]' }, ]); res.render('account/edit/' + name, userData); @@ -139,7 +139,7 @@ editController.uploadPicture = function (req, res, next) { return next(err); } - res.json([{name: userPhoto.name, url: image.url.startsWith('http') ? image.url : nconf.get('relative_path') + image.url}]); + res.json([{ name: userPhoto.name, url: image.url.startsWith('http') ? image.url : nconf.get('relative_path') + image.url }]); }); }; diff --git a/src/controllers/accounts/follow.js b/src/controllers/accounts/follow.js index 7cc3e1895b..eac274136d 100644 --- a/src/controllers/accounts/follow.js +++ b/src/controllers/accounts/follow.js @@ -47,7 +47,7 @@ function getFollow(tpl, name, req, res, callback) { var count = name === 'following' ? userData.followingCount : userData.followerCount; var pageCount = Math.ceil(count / resultsPerPage); userData.pagination = pagination.create(page, pageCount); - userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: '[[user:' + name + ']]'}]); + userData.breadcrumbs = helpers.buildBreadcrumbs([{ text: userData.username, url: '/user/' + userData.userslug }, { text: '[[user:' + name + ']]' }]); res.render(tpl, userData); }); diff --git a/src/controllers/accounts/groups.js b/src/controllers/accounts/groups.js index fc81b1173a..650c510fc9 100644 --- a/src/controllers/accounts/groups.js +++ b/src/controllers/accounts/groups.js @@ -46,7 +46,7 @@ groupsController.get = function (req, res, callback) { userData.groups = groupsData; userData.title = '[[pages:account/groups, ' + userData.username + ']]'; - userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: '[[global:header.groups]]'}]); + userData.breadcrumbs = helpers.buildBreadcrumbs([{ text: userData.username, url: '/user/' + userData.userslug }, { text: '[[global:header.groups]]' }]); res.render('account/groups', userData); }); }; diff --git a/src/controllers/accounts/helpers.js b/src/controllers/accounts/helpers.js index b4a2af17af..1ee9a08678 100644 --- a/src/controllers/accounts/helpers.js +++ b/src/controllers/accounts/helpers.js @@ -52,13 +52,13 @@ helpers.getUserDataByUserSlug = function (userslug, callerUID, callback) { plugins.fireHook('filter:user.profileLinks', [], next); }, profile_menu: function (next) { - plugins.fireHook('filter:user.profileMenu', {uid: uid, callerUID: callerUID, links: []}, next); + plugins.fireHook('filter:user.profileMenu', { uid: uid, callerUID: callerUID, links: [] }, next); }, groups: function (next) { groups.getUserGroups([uid], next); }, sso: function (next) { - plugins.fireHook('filter:auth.list', {uid: uid, associations: []}, next); + plugins.fireHook('filter:auth.list', { uid: uid, associations: [] }, next); }, }, next); }, diff --git a/src/controllers/accounts/info.js b/src/controllers/accounts/info.js index 9df74b1380..e852ebc3df 100644 --- a/src/controllers/accounts/info.js +++ b/src/controllers/accounts/info.js @@ -36,7 +36,7 @@ infoController.get = function (req, res, callback) { userData.usernames = data.usernames; userData.emails = data.emails; userData.title = '[[pages:account/info]]'; - userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: '[[user:account_info]]'}]); + userData.breadcrumbs = helpers.buildBreadcrumbs([{ text: userData.username, url: '/user/' + userData.userslug }, { text: '[[user:account_info]]' }]); res.render('account/info', userData); }); diff --git a/src/controllers/accounts/notifications.js b/src/controllers/accounts/notifications.js index 8b2479052c..6184ec056d 100644 --- a/src/controllers/accounts/notifications.js +++ b/src/controllers/accounts/notifications.js @@ -14,7 +14,7 @@ notificationsController.get = function (req, res, next) { notifications: notifications, nextStart: 40, title: '[[pages:notifications]]', - breadcrumbs: helpers.buildBreadcrumbs([{text: '[[pages:notifications]]'}]), + breadcrumbs: helpers.buildBreadcrumbs([{ text: '[[pages:notifications]]' }]), }); }); }; diff --git a/src/controllers/accounts/posts.js b/src/controllers/accounts/posts.js index 48d7c23a80..2f603b8015 100644 --- a/src/controllers/accounts/posts.js +++ b/src/controllers/accounts/posts.js @@ -143,7 +143,7 @@ function getFromUserSet(template, req, res, callback) { userData.noItemsFoundKey = data.noItemsFoundKey; userData.title = '[[pages:' + data.template + ', ' + userData.username + ']]'; - userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: data.crumb}]); + userData.breadcrumbs = helpers.buildBreadcrumbs([{ text: userData.username, url: '/user/' + userData.userslug }, { text: data.crumb }]); res.render(data.template, userData); }); diff --git a/src/controllers/accounts/profile.js b/src/controllers/accounts/profile.js index c3fa0e9092..1fc092a5f4 100644 --- a/src/controllers/accounts/profile.js +++ b/src/controllers/accounts/profile.js @@ -76,7 +76,7 @@ profileController.get = function (req, res, callback) { userData.hasPrivateChat = results.hasPrivateChat; userData.aboutme = results.aboutme; userData.nextStart = results.posts.nextStart; - userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username}]); + userData.breadcrumbs = helpers.buildBreadcrumbs([{ text: userData.username }]); userData.title = userData.username; var pageCount = Math.ceil(userData.postcount / itemsPerPage); userData.pagination = pagination.create(page, pageCount, req.query); @@ -127,7 +127,7 @@ profileController.get = function (req, res, callback) { return group && group.name === userData.groupTitle; }); - plugins.fireHook('filter:user.account', {userData: userData, uid: req.uid}, next); + plugins.fireHook('filter:user.account', { userData: userData, uid: req.uid }, next); }, ], function (err, results) { if (err) { diff --git a/src/controllers/accounts/settings.js b/src/controllers/accounts/settings.js index f18a7b0fad..c35658b08f 100644 --- a/src/controllers/accounts/settings.js +++ b/src/controllers/accounts/settings.js @@ -58,11 +58,11 @@ settingsController.get = function (req, res, callback) { Object.keys(soundSettings).forEach(function (setting) { userData[setting] = Object.keys(results.sounds).map(function (name) { - return {name: name, selected: name === results.soundsMapping[soundSettings[setting]]}; + return { name: name, selected: name === results.soundsMapping[soundSettings[setting]] }; }); }); - plugins.fireHook('filter:user.customSettings', {settings: results.settings, customSettings: [], uid: req.uid}, next); + plugins.fireHook('filter:user.customSettings', { settings: results.settings, customSettings: [], uid: req.uid }, next); }, function (data, next) { userData.customSettings = data.customSettings; @@ -75,10 +75,10 @@ settingsController.get = function (req, res, callback) { } userData.dailyDigestFreqOptions = [ - {value: 'off', name: '[[user:digest_off]]', selected: 'off' === userData.settings.dailyDigestFreq}, - {value: 'day', name: '[[user:digest_daily]]', selected: 'day' === userData.settings.dailyDigestFreq}, - {value: 'week', name: '[[user:digest_weekly]]', selected: 'week' === userData.settings.dailyDigestFreq}, - {value: 'month', name: '[[user:digest_monthly]]', selected: 'month' === userData.settings.dailyDigestFreq}, + { value: 'off', name: '[[user:digest_off]]', selected: 'off' === userData.settings.dailyDigestFreq }, + { value: 'day', name: '[[user:digest_daily]]', selected: 'day' === userData.settings.dailyDigestFreq }, + { value: 'week', name: '[[user:digest_weekly]]', selected: 'week' === userData.settings.dailyDigestFreq }, + { value: 'month', name: '[[user:digest_monthly]]', selected: 'month' === userData.settings.dailyDigestFreq }, ]; @@ -135,7 +135,7 @@ settingsController.get = function (req, res, callback) { userData.inTopicSearchAvailable = plugins.hasListeners('filter:topic.search'); userData.title = '[[pages:account/settings]]'; - userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: '[[user:settings]]'}]); + userData.breadcrumbs = helpers.buildBreadcrumbs([{ text: userData.username, url: '/user/' + userData.userslug }, { text: '[[user:settings]]' }]); res.render('account/settings', userData); }); @@ -163,7 +163,7 @@ function getHomePageRoutes(callback) { categoryData = categoryData || []; - plugins.fireHook('filter:homepage.get', {routes: [ + plugins.fireHook('filter:homepage.get', { routes: [ { route: 'categories', name: 'Categories', @@ -180,7 +180,7 @@ function getHomePageRoutes(callback) { route: 'popular', name: 'Popular', }, - ].concat(categoryData)}, next); + ].concat(categoryData) }, next); }, function (data, next) { next(null, data.routes); diff --git a/src/controllers/admin/groups.js b/src/controllers/admin/groups.js index 2f4fa31664..4e4aa64531 100644 --- a/src/controllers/admin/groups.js +++ b/src/controllers/admin/groups.js @@ -34,7 +34,7 @@ groupsController.list = function (req, res, next) { groups.getGroupsData(groupNames, next); }, function (groupData, next) { - next(null, {groups: groupData, pagination: pagination.create(page, pageCount)}); + next(null, { groups: groupData, pagination: pagination.create(page, pageCount) }); }, ], function (err, data) { if (err) { @@ -59,14 +59,14 @@ groupsController.get = function (req, res, callback) { if (!exists) { return callback(); } - groups.get(groupName, {uid: req.uid, truncateUserList: true, userListCount: 20}, next); + groups.get(groupName, { uid: req.uid, truncateUserList: true, userListCount: 20 }, next); }, ], function (err, group) { if (err) { return callback(err); } group.isOwner = true; - res.render('admin/manage/group', {group: group, allowPrivateGroups: parseInt(meta.config.allowPrivateGroups, 10) === 1}); + res.render('admin/manage/group', { group: group, allowPrivateGroups: parseInt(meta.config.allowPrivateGroups, 10) === 1 }); }); }; diff --git a/src/controllers/admin/homepage.js b/src/controllers/admin/homepage.js index d40a578e66..1450283847 100644 --- a/src/controllers/admin/homepage.js +++ b/src/controllers/admin/homepage.js @@ -35,7 +35,7 @@ homePageController.get = function (req, res, next) { categoryData = []; } - plugins.fireHook('filter:homepage.get', {routes: [ + plugins.fireHook('filter:homepage.get', { routes: [ { route: 'categories', name: 'Categories', @@ -48,7 +48,7 @@ homePageController.get = function (req, res, next) { route: 'popular', name: 'Popular', }, - ].concat(categoryData)}, function (err, data) { + ].concat(categoryData) }, function (err, data) { if (err) { return next(err); } diff --git a/src/controllers/admin/info.js b/src/controllers/admin/info.js index ac32a2c63a..96783a9c87 100644 --- a/src/controllers/admin/info.js +++ b/src/controllers/admin/info.js @@ -24,7 +24,7 @@ infoController.get = function (req, res, next) { data.sort(function (a, b) { return (a.os.hostname < b.os.hostname) ? -1 : (a.os.hostname > b.os.hostname) ? 1 : 0; }); - res.render('admin/development/info', {info: data, infoJSON: JSON.stringify(data, null, 4), host: os.hostname(), port: nconf.get('port')}); + res.render('admin/development/info', { info: data, infoJSON: JSON.stringify(data, null, 4), host: os.hostname(), port: nconf.get('port') }); }, 500); }; @@ -33,7 +33,7 @@ pubsub.on('sync:node:info:start', function () { if (err) { return winston.error(err); } - pubsub.publish('sync:node:info:end', {data: data, id: os.hostname() + ':' + nconf.get('port')}); + pubsub.publish('sync:node:info:end', { data: data, id: os.hostname() + ':' + nconf.get('port') }); }); }); diff --git a/src/controllers/admin/tags.js b/src/controllers/admin/tags.js index 5e6c0d71a4..f586e5f70c 100644 --- a/src/controllers/admin/tags.js +++ b/src/controllers/admin/tags.js @@ -10,7 +10,7 @@ tagsController.get = function (req, res, next) { return next(err); } - res.render('admin/manage/tags', {tags: tags}); + res.render('admin/manage/tags', { tags: tags }); }); }; diff --git a/src/controllers/admin/uploads.js b/src/controllers/admin/uploads.js index c939da345f..0f53dcb8f3 100644 --- a/src/controllers/admin/uploads.js +++ b/src/controllers/admin/uploads.js @@ -49,7 +49,7 @@ uploadsController.uploadFavicon = function (req, res, next) { return next(err); } - res.json([{name: uploadedFile.name, url: image.url}]); + res.json([{ name: uploadedFile.name, url: image.url }]); }); } }; @@ -87,7 +87,7 @@ uploadsController.uploadTouchIcon = function (req, res, next) { return next(err); } - res.json([{name: uploadedFile.name, url: imageObj.url}]); + res.json([{ name: uploadedFile.name, url: imageObj.url }]); }); }); } @@ -145,7 +145,7 @@ function validateUpload(req, res, next, uploadedFile, allowedTypes) { } }); - res.json({error: '[[error:invalid-image-type, ' + allowedTypes.join(', ') + ']]'}); + res.json({ error: '[[error:invalid-image-type, ' + allowedTypes.join(', ') + ']]' }); return false; } @@ -163,11 +163,11 @@ function uploadImage(filename, folder, uploadedFile, req, res, next) { return next(err); } - res.json([{name: uploadedFile.name, url: image.url.startsWith('http') ? image.url : nconf.get('relative_path') + image.url}]); + res.json([{ name: uploadedFile.name, url: image.url.startsWith('http') ? image.url : nconf.get('relative_path') + image.url }]); } if (plugins.hasListeners('filter:uploadImage')) { - plugins.fireHook('filter:uploadImage', {image: uploadedFile, uid: req.user.uid}, done); + plugins.fireHook('filter:uploadImage', { image: uploadedFile, uid: req.user.uid }, done); } else { file.saveFileToLocal(filename, folder, uploadedFile.path, done); } diff --git a/src/controllers/admin/users.js b/src/controllers/admin/users.js index cb84792b85..ad10b7365e 100644 --- a/src/controllers/admin/users.js +++ b/src/controllers/admin/users.js @@ -71,7 +71,7 @@ usersController.registrationQueue = function (req, res, next) { user.getRegistrationQueue(start, stop, next); }, customHeaders: function (next) { - plugins.fireHook('filter:admin.registrationQueue.customHeaders', {headers: []}, next); + plugins.fireHook('filter:admin.registrationQueue.customHeaders', { headers: [] }, next); }, invites: function (next) { async.waterfall([ diff --git a/src/controllers/api.js b/src/controllers/api.js index 858db57d66..66392e6160 100644 --- a/src/controllers/api.js +++ b/src/controllers/api.js @@ -311,7 +311,7 @@ apiController.getModerators = function (req, res, next) { if (err) { return next(err); } - res.json({moderators: moderators}); + res.json({ moderators: moderators }); }); }; diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js index ffbe36dfc9..47a15c1161 100644 --- a/src/controllers/authentication.js +++ b/src/controllers/authentication.js @@ -74,7 +74,7 @@ authenticationController.register = function (req, res, next) { }, function (queue, next) { res.locals.processLogin = true; // set it to false in plugin if you wish to just register only - plugins.fireHook('filter:register.check', {req: req, res: res, userData: userData, queue: queue}, next); + plugins.fireHook('filter:register.check', { req: req, res: res, userData: userData, queue: queue }, next); }, function (data, next) { if (data.queue) { @@ -133,7 +133,7 @@ function registerAndLoginUser(req, res, userData, callback) { }, function (next) { user.deleteInvitationKey(userData.email); - plugins.fireHook('filter:register.complete', {uid: uid, referrer: req.body.referrer || nconf.get('relative_path') + '/'}, next); + plugins.fireHook('filter:register.complete', { uid: uid, referrer: req.body.referrer || nconf.get('relative_path') + '/' }, next); }, ], callback); } @@ -145,7 +145,7 @@ function addToApprovalQueue(req, userData, callback) { user.addToApprovalQueue(userData, next); }, function (next) { - next(null, {message: '[[register:registration-added-to-queue]]'}); + next(null, { message: '[[register:registration-added-to-queue]]' }); }, ], callback); } @@ -284,7 +284,7 @@ authenticationController.doLogin = function (req, uid, callback) { return callback(); } - req.login({uid: uid}, function (err) { + req.login({ uid: uid }, function (err) { if (err) { return callback(err); } @@ -427,7 +427,7 @@ authenticationController.logout = function (req, res, next) { user.setUserField(uid, 'lastonline', Date.now() - 300000); - plugins.fireHook('static:user.loggedOut', {req: req, res: res, uid: uid}, function () { + plugins.fireHook('static:user.loggedOut', { req: req, res: res, uid: uid }, function () { res.status(200).send(''); // Force session check for all connected socket.io clients with the same session id diff --git a/src/controllers/categories.js b/src/controllers/categories.js index 5133444f7a..8112dead67 100644 --- a/src/controllers/categories.js +++ b/src/controllers/categories.js @@ -60,7 +60,7 @@ categoriesController.list = function (req, res, next) { }; if (req.path.startsWith('/api/categories') || req.path.startsWith('/categories')) { - data.breadcrumbs = helpers.buildBreadcrumbs([{text: data.title}]); + data.breadcrumbs = helpers.buildBreadcrumbs([{ text: data.title }]); } data.categories.forEach(function (category) { diff --git a/src/controllers/groups.js b/src/controllers/groups.js index 75df1112eb..5fdc140826 100644 --- a/src/controllers/groups.js +++ b/src/controllers/groups.js @@ -19,7 +19,7 @@ groupsController.list = function (req, res, next) { return next(err); } data.title = '[[pages:groups]]'; - data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[pages:groups]]'}]); + data.breadcrumbs = helpers.buildBreadcrumbs([{ text: '[[pages:groups]]' }]); res.render('groups/list', data); }); }; @@ -108,7 +108,7 @@ groupsController.details = function (req, res, callback) { } results.group.isOwner = results.group.isOwner || results.isAdmin || (results.isGlobalMod && !results.group.system); results.title = '[[pages:group, ' + results.group.displayName + ']]'; - results.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[pages:groups]]', url: '/groups' }, {text: results.group.displayName}]); + results.breadcrumbs = helpers.buildBreadcrumbs([{ text: '[[pages:groups]]', url: '/groups' }, { text: results.group.displayName }]); results.allowPrivateGroups = parseInt(meta.config.allowPrivateGroups, 10) === 1; res.render('groups/details', results); @@ -145,9 +145,9 @@ groupsController.members = function (req, res, callback) { } var breadcrumbs = helpers.buildBreadcrumbs([ - {text: '[[pages:groups]]', url: '/groups' }, - {text: validator.escape(String(groupName)), url: '/groups/' + req.params.slug}, - {text: '[[groups:details.members]]'}, + { text: '[[pages:groups]]', url: '/groups' }, + { text: validator.escape(String(groupName)), url: '/groups/' + req.params.slug }, + { text: '[[groups:details.members]]' }, ]); res.render('groups/members', { @@ -180,7 +180,7 @@ groupsController.uploadCover = function (req, res, next) { if (err) { return next(err); } - res.json([{url: image.url.startsWith('http') ? image.url : nconf.get('relative_path') + image.url}]); + res.json([{ url: image.url.startsWith('http') ? image.url : nconf.get('relative_path') + image.url }]); }); }; diff --git a/src/controllers/helpers.js b/src/controllers/helpers.js index 3500ac9158..0942cc7b82 100644 --- a/src/controllers/helpers.js +++ b/src/controllers/helpers.js @@ -164,7 +164,7 @@ helpers.getWatchedCategories = function (uid, selectedCid, callback) { recursive(category, categoriesData, ''); }); - next(null, {categories: categoriesData, selectedCategory: selectedCategory}); + next(null, { categories: categoriesData, selectedCategory: selectedCategory }); }, ], callback); }; diff --git a/src/controllers/index.js b/src/controllers/index.js index 3124355a98..14600263de 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -46,7 +46,7 @@ Controllers.home = function (req, res, next) { var hook = 'action:homepage.get:' + route; if (plugins.hasListeners(hook)) { - return plugins.fireHook(hook, {req: req, res: res, next: next}); + return plugins.fireHook(hook, { req: req, res: res, next: next }); } if (route === 'categories' || route === '/') { @@ -83,7 +83,7 @@ Controllers.reset = function (req, res, next) { displayExpiryNotice: req.session.passwordExpired, code: req.params.code, minimumPasswordLength: parseInt(meta.config.minimumPasswordLength, 10), - breadcrumbs: helpers.buildBreadcrumbs([{text: '[[reset_password:reset_password]]', url: '/reset'}, {text: '[[reset_password:update_password]]'}]), + breadcrumbs: helpers.buildBreadcrumbs([{ text: '[[reset_password:reset_password]]', url: '/reset' }, { text: '[[reset_password:update_password]]' }]), title: '[[pages:reset]]', }); @@ -92,7 +92,7 @@ Controllers.reset = function (req, res, next) { } else { res.render('reset', { code: null, - breadcrumbs: helpers.buildBreadcrumbs([{text: '[[reset_password:reset_password]]'}]), + breadcrumbs: helpers.buildBreadcrumbs([{ text: '[[reset_password:reset_password]]' }]), title: '[[pages:reset]]', }); } @@ -122,7 +122,7 @@ Controllers.login = function (req, res, next) { data.allowLocalLogin = parseInt(meta.config.allowLocalLogin, 10) === 1 || parseInt(req.query.local, 10) === 1; data.allowRegistration = registrationType === 'normal' || registrationType === 'admin-approval' || registrationType === 'admin-approval-ip'; data.allowLoginWith = '[[login:' + allowLoginWith + ']]'; - data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[global:login]]'}]); + data.breadcrumbs = helpers.buildBreadcrumbs([{ text: '[[global:login]]' }]); data.error = req.flash('error')[0] || errorText; data.title = '[[pages:login]]'; @@ -170,7 +170,7 @@ Controllers.register = function (req, res, next) { } }, function (next) { - plugins.fireHook('filter:parse.post', {postData: {content: meta.config.termsOfUse || ''}}, next); + plugins.fireHook('filter:parse.post', { postData: { content: meta.config.termsOfUse || '' } }, next); }, ], function (err, termsOfUse) { if (err) { @@ -188,7 +188,7 @@ Controllers.register = function (req, res, next) { data.maximumUsernameLength = parseInt(meta.config.maximumUsernameLength, 10); data.minimumPasswordLength = parseInt(meta.config.minimumPasswordLength, 10); data.termsOfUse = termsOfUse.postData.content; - data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[register:register]]'}]); + data.breadcrumbs = helpers.buildBreadcrumbs([{ text: '[[register:register]]' }]); data.regFormEntry = []; data.error = req.flash('error')[0] || errorText; data.title = '[[pages:register]]'; @@ -329,7 +329,7 @@ Controllers.outgoing = function (req, res) { var data = { outgoing: validator.escape(String(url)), title: meta.config.title, - breadcrumbs: helpers.buildBreadcrumbs([{text: '[[notifications:outgoing_link]]'}]), + breadcrumbs: helpers.buildBreadcrumbs([{ text: '[[notifications:outgoing_link]]' }]), }; if (url) { @@ -343,7 +343,7 @@ Controllers.termsOfUse = function (req, res, next) { if (!meta.config.termsOfUse) { return next(); } - res.render('tos', {termsOfUse: meta.config.termsOfUse}); + res.render('tos', { termsOfUse: meta.config.termsOfUse }); }; Controllers.ping = function (req, res) { @@ -378,11 +378,11 @@ Controllers.handle404 = function (req, res) { var path = String(req.path || ''); if (res.locals.isAPI) { - return res.json({path: validator.escape(path.replace(/^\/api/, '')), title: '[[global:404.title]]'}); + return res.json({ path: validator.escape(path.replace(/^\/api/, '')), title: '[[global:404.title]]' }); } var middleware = require('../middleware'); middleware.buildHeader(req, res, function () { - res.render('404', {path: validator.escape(path), title: '[[global:404.title]]'}); + res.render('404', { path: validator.escape(path), title: '[[global:404.title]]' }); }); } else { res.status(404).type('txt').send('Not found'); @@ -436,7 +436,7 @@ Controllers.handleErrors = function (err, req, res, next) { var path = String(req.path || ''); if (res.locals.isAPI) { - res.json({path: validator.escape(path), error: err.message}); + res.json({ path: validator.escape(path), error: err.message }); } else { var middleware = require('../middleware'); middleware.buildHeader(req, res, function () { diff --git a/src/controllers/popular.js b/src/controllers/popular.js index 1daf7f5ed5..21c07224c1 100644 --- a/src/controllers/popular.js +++ b/src/controllers/popular.js @@ -52,10 +52,10 @@ popularController.get = function (req, res, next) { }; if (req.path.startsWith('/api/popular') || req.path.startsWith('/popular')) { - var breadcrumbs = [{text: termToBreadcrumb[term]}]; + var breadcrumbs = [{ text: termToBreadcrumb[term] }]; if (req.params.term) { - breadcrumbs.unshift({text: '[[global:header.popular]]', url: '/popular'}); + breadcrumbs.unshift({ text: '[[global:header.popular]]', url: '/popular' }); } data.breadcrumbs = helpers.buildBreadcrumbs(breadcrumbs); diff --git a/src/controllers/recent.js b/src/controllers/recent.js index 0901ea624d..c5d1d2128a 100644 --- a/src/controllers/recent.js +++ b/src/controllers/recent.js @@ -13,7 +13,7 @@ var pagination = require('../pagination'); var recentController = {}; -var validFilter = {'': true, new: true, watched: true}; +var validFilter = { '': true, new: true, watched: true }; recentController.get = function (req, res, next) { var page = parseInt(req.query.page, 10) || 1; @@ -84,7 +84,7 @@ recentController.get = function (req, res, next) { data.pagination = pagination.create(page, pageCount, req.query); if (req.path.startsWith('/api/recent') || req.path.startsWith('/recent')) { - data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[recent:title]]'}]); + data.breadcrumbs = helpers.buildBreadcrumbs([{ text: '[[recent:title]]' }]); } data.querystring = cid ? ('?cid=' + validator.escape(String(cid))) : ''; diff --git a/src/controllers/search.js b/src/controllers/search.js index f91577190b..29a883489f 100644 --- a/src/controllers/search.js +++ b/src/controllers/search.js @@ -54,8 +54,8 @@ searchController.search = function (req, res, next) { } var categoriesData = [ - {value: 'all', text: '[[unread:all_categories]]'}, - {value: 'watched', text: '[[category:watched-categories]]'}, + { value: 'all', text: '[[unread:all_categories]]' }, + { value: 'watched', text: '[[category:watched-categories]]' }, ].concat(results.categories); var searchData = results.search; @@ -65,7 +65,7 @@ searchController.search = function (req, res, next) { searchData.showAsPosts = !req.query.showAs || req.query.showAs === 'posts'; searchData.showAsTopics = req.query.showAs === 'topics'; searchData.title = '[[global:header.search]]'; - searchData.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[global:search]]'}]); + searchData.breadcrumbs = helpers.buildBreadcrumbs([{ text: '[[global:search]]' }]); searchData.expandSearch = !req.query.term; res.render('search', searchData); diff --git a/src/controllers/tags.js b/src/controllers/tags.js index 36d1969a1d..cffff0e44c 100644 --- a/src/controllers/tags.js +++ b/src/controllers/tags.js @@ -19,7 +19,7 @@ tagsController.getTag = function (req, res, next) { var templateData = { topics: [], tag: tag, - breadcrumbs: helpers.buildBreadcrumbs([{text: '[[tags:tags]]', url: '/tags'}, {text: tag}]), + breadcrumbs: helpers.buildBreadcrumbs([{ text: '[[tags:tags]]', url: '/tags' }, { text: tag }]), title: '[[pages:tag, ' + tag + ']]', }; var settings; @@ -86,7 +86,7 @@ tagsController.getTags = function (req, res, next) { var data = { tags: tags, nextStart: 100, - breadcrumbs: helpers.buildBreadcrumbs([{text: '[[tags:tags]]'}]), + breadcrumbs: helpers.buildBreadcrumbs([{ text: '[[tags:tags]]' }]), title: '[[pages:tags]]', }; res.render('tags', data); diff --git a/src/controllers/topics.js b/src/controllers/topics.js index 4d6f87b68f..2d8d9bff1e 100644 --- a/src/controllers/topics.js +++ b/src/controllers/topics.js @@ -125,7 +125,7 @@ topicsController.get = function (req, res, callback) { topics.modifyPostsByPrivilege(topicData, userPrivileges); - plugins.fireHook('filter:controllers.topic.get', {topicData: topicData, uid: req.uid}, next); + plugins.fireHook('filter:controllers.topic.get', { topicData: topicData, uid: req.uid }, next); }, function (data, next) { var breadcrumbs = [ @@ -315,7 +315,7 @@ topicsController.teaser = function (req, res, next) { if (!pid) { return res.status(404).json('not-found'); } - posts.getPostSummaryByPids([pid], req.uid, {stripTags: false}, next); + posts.getPostSummaryByPids([pid], req.uid, { stripTags: false }, next); }, ], function (err, posts) { if (err) { diff --git a/src/controllers/unread.js b/src/controllers/unread.js index a0da19c6c4..c5d0d4d950 100644 --- a/src/controllers/unread.js +++ b/src/controllers/unread.js @@ -12,7 +12,7 @@ var helpers = require('./helpers'); var unreadController = {}; -var validFilter = {'': true, new: true, watched: true}; +var validFilter = { '': true, new: true, watched: true }; unreadController.get = function (req, res, next) { var page = parseInt(req.query.page, 10) || 1; @@ -59,7 +59,7 @@ unreadController.get = function (req, res, next) { data.selectedCategory = results.watchedCategories.selectedCategory; if (req.path.startsWith('/api/unread') || req.path.startsWith('/unread')) { - data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[unread:title]]'}]); + data.breadcrumbs = helpers.buildBreadcrumbs([{ text: '[[unread:title]]' }]); } data.title = '[[pages:unread]]'; diff --git a/src/controllers/uploads.js b/src/controllers/uploads.js index 0a556f722a..ca57f8f18e 100644 --- a/src/controllers/uploads.js +++ b/src/controllers/uploads.js @@ -59,7 +59,7 @@ function uploadAsImage(req, uploadedFile, callback) { return next(new Error('[[error:no-privileges]]')); } if (plugins.hasListeners('filter:uploadImage')) { - return plugins.fireHook('filter:uploadImage', {image: uploadedFile, uid: req.uid}, callback); + return plugins.fireHook('filter:uploadImage', { image: uploadedFile, uid: req.uid }, callback); } file.isFileTypeAllowed(uploadedFile.path, next); }, @@ -155,7 +155,7 @@ uploadsController.uploadThumb = function (req, res, next) { } if (plugins.hasListeners('filter:uploadImage')) { - return plugins.fireHook('filter:uploadImage', {image: uploadedFile, uid: req.uid}, next); + return plugins.fireHook('filter:uploadImage', { image: uploadedFile, uid: req.uid }, next); } uploadFile(req.uid, uploadedFile, next); @@ -166,11 +166,11 @@ uploadsController.uploadThumb = function (req, res, next) { uploadsController.uploadGroupCover = function (uid, uploadedFile, callback) { if (plugins.hasListeners('filter:uploadImage')) { - return plugins.fireHook('filter:uploadImage', {image: uploadedFile, uid: uid}, callback); + return plugins.fireHook('filter:uploadImage', { image: uploadedFile, uid: uid }, callback); } if (plugins.hasListeners('filter:uploadFile')) { - return plugins.fireHook('filter:uploadFile', {file: uploadedFile, uid: uid}, callback); + return plugins.fireHook('filter:uploadFile', { file: uploadedFile, uid: uid }, callback); } file.isFileTypeAllowed(uploadedFile.path, function (err) { @@ -183,7 +183,7 @@ uploadsController.uploadGroupCover = function (uid, uploadedFile, callback) { function uploadFile(uid, uploadedFile, callback) { if (plugins.hasListeners('filter:uploadFile')) { - return plugins.fireHook('filter:uploadFile', {file: uploadedFile, uid: uid}, callback); + return plugins.fireHook('filter:uploadFile', { file: uploadedFile, uid: uid }, callback); } if (!uploadedFile) { diff --git a/src/controllers/users.js b/src/controllers/users.js index fdf6fa36cc..ae3643bb8d 100644 --- a/src/controllers/users.js +++ b/src/controllers/users.js @@ -146,22 +146,22 @@ usersController.renderUsersPage = function (set, req, res, next) { usersController.getUsers = function (set, uid, query, callback) { var setToData = { - 'users:postcount': {title: '[[pages:users/sort-posts]]', crumb: '[[users:top_posters]]'}, - 'users:reputation': {title: '[[pages:users/sort-reputation]]', crumb: '[[users:most_reputation]]'}, - 'users:joindate': {title: '[[pages:users/latest]]', crumb: '[[global:users]]'}, - 'users:online': {title: '[[pages:users/online]]', crumb: '[[global:online]]'}, - 'users:banned': {title: '[[pages:users/banned]]', crumb: '[[user:banned]]'}, - 'users:flags': {title: '[[pages:users/most-flags]]', crumb: '[[users:most_flags]]'}, + 'users:postcount': { title: '[[pages:users/sort-posts]]', crumb: '[[users:top_posters]]' }, + 'users:reputation': { title: '[[pages:users/sort-reputation]]', crumb: '[[users:most_reputation]]' }, + 'users:joindate': { title: '[[pages:users/latest]]', crumb: '[[global:users]]' }, + 'users:online': { title: '[[pages:users/online]]', crumb: '[[global:online]]' }, + 'users:banned': { title: '[[pages:users/banned]]', crumb: '[[user:banned]]' }, + 'users:flags': { title: '[[pages:users/most-flags]]', crumb: '[[users:most_flags]]' }, }; if (!setToData[set]) { - setToData[set] = {title: '', crumb: ''}; + setToData[set] = { title: '', crumb: '' }; } - var breadcrumbs = [{text: setToData[set].crumb}]; + var breadcrumbs = [{ text: setToData[set].crumb }]; if (set !== 'users:joindate') { - breadcrumbs.unshift({text: '[[global:users]]', url: '/users'}); + breadcrumbs.unshift({ text: '[[global:users]]', url: '/users' }); } var page = parseInt(query.page, 10) || 1; diff --git a/src/database/mongo/hash.js b/src/database/mongo/hash.js index cd9af198d2..e253135c47 100644 --- a/src/database/mongo/hash.js +++ b/src/database/mongo/hash.js @@ -9,7 +9,7 @@ module.exports = function (db, module) { return callback(); } - db.collection('objects').update({_key: key}, {$set: data}, {upsert: true, w: 1}, function (err) { + db.collection('objects').update({ _key: key }, { $set: data }, { upsert: true, w: 1 }, function (err) { callback(err); }); }; @@ -29,14 +29,14 @@ module.exports = function (db, module) { if (!key) { return callback(); } - db.collection('objects').findOne({_key: key}, {_id: 0, _key: 0}, callback); + db.collection('objects').findOne({ _key: key }, { _id: 0, _key: 0 }, callback); }; module.getObjects = function (keys, callback) { if (!Array.isArray(keys) || !keys.length) { return callback(null, []); } - db.collection('objects').find({_key: {$in: keys}}, {_id: 0}).toArray(function (err, data) { + db.collection('objects').find({ _key: { $in: keys } }, { _id: 0 }).toArray(function (err, data) { if (err) { return callback(err); } @@ -61,7 +61,7 @@ module.exports = function (db, module) { _id: 0, }; _fields[field] = 1; - db.collection('objects').findOne({_key: key}, {fields: _fields}, function (err, item) { + db.collection('objects').findOne({ _key: key }, { fields: _fields }, function (err, item) { if (err || !item) { return callback(err, null); } @@ -82,7 +82,7 @@ module.exports = function (db, module) { fields[i] = helpers.fieldToString(fields[i]); _fields[fields[i]] = 1; } - db.collection('objects').findOne({_key: key}, {fields: _fields}, function (err, item) { + db.collection('objects').findOne({ _key: key }, { fields: _fields }, function (err, item) { if (err) { return callback(err); } @@ -109,7 +109,7 @@ module.exports = function (db, module) { _fields[fields[i]] = 1; } - db.collection('objects').find({_key: {$in: keys}}, {fields: _fields}).toArray(function (err, items) { + db.collection('objects').find({ _key: { $in: keys } }, { fields: _fields }).toArray(function (err, items) { if (err) { return callback(err); } @@ -166,7 +166,7 @@ module.exports = function (db, module) { var data = {}; field = helpers.fieldToString(field); data[field] = ''; - db.collection('objects').findOne({_key: key}, {fields: data}, function (err, item) { + db.collection('objects').findOne({ _key: key }, { fields: data }, function (err, item) { callback(err, !!item && item[field] !== undefined && item[field] !== null); }); }; @@ -182,7 +182,7 @@ module.exports = function (db, module) { data[field] = ''; }); - db.collection('objects').findOne({_key: key}, {fields: data}, function (err, item) { + db.collection('objects').findOne({ _key: key }, { fields: data }, function (err, item) { if (err) { return callback(err); } @@ -216,7 +216,7 @@ module.exports = function (db, module) { data[field] = ''; }); - db.collection('objects').update({_key: key}, {$unset: data}, function (err) { + db.collection('objects').update({ _key: key }, { $unset: data }, function (err) { callback(err); }); }; @@ -240,7 +240,7 @@ module.exports = function (db, module) { field = helpers.fieldToString(field); data[field] = value; - db.collection('objects').findAndModify({_key: key}, {}, {$inc: data}, {new: true, upsert: true}, function (err, result) { + db.collection('objects').findAndModify({ _key: key }, {}, { $inc: data }, { new: true, upsert: true }, function (err, result) { callback(err, result && result.value ? result.value[field] : null); }); }; diff --git a/src/database/mongo/list.js b/src/database/mongo/list.js index 2314c7cbc3..a639ec0d73 100644 --- a/src/database/mongo/list.js +++ b/src/database/mongo/list.js @@ -18,7 +18,7 @@ module.exports = function (db, module) { } if (exists) { - db.collection('objects').update({_key: key}, {$push: {array: {$each: [value], $position: 0}}}, {upsert: true, w: 1 }, function (err, res) { + db.collection('objects').update({ _key: key }, { $push: { array: { $each: [value], $position: 0 } } }, { upsert: true, w: 1 }, function (err, res) { callback(err); }); } else { @@ -33,7 +33,7 @@ module.exports = function (db, module) { return callback(); } value = helpers.valueToString(value); - db.collection('objects').update({ _key: key }, { $push: { array: value } }, {upsert: true, w: 1}, function (err, res) { + db.collection('objects').update({ _key: key }, { $push: { array: value } }, { upsert: true, w: 1 }, function (err, res) { callback(err); }); }; @@ -48,7 +48,7 @@ module.exports = function (db, module) { return callback(err); } - db.collection('objects').update({_key: key }, { $pop: { array: 1 } }, function (err, result) { + db.collection('objects').update({ _key: key }, { $pop: { array: 1 } }, function (err, result) { callback(err, (value && value.length) ? value[0] : null); }); }); @@ -61,7 +61,7 @@ module.exports = function (db, module) { } value = helpers.valueToString(value); - db.collection('objects').update({_key: key }, { $pull: { array: value } }, function (err, res) { + db.collection('objects').update({ _key: key }, { $pull: { array: value } }, function (err, res) { callback(err); }); }; @@ -76,7 +76,7 @@ module.exports = function (db, module) { return callback(err); } - db.collection('objects').update({_key: key}, {$set: {array: value}}, function (err, res) { + db.collection('objects').update({ _key: key }, { $set: { array: value } }, function (err, res) { callback(err); }); }); @@ -87,7 +87,7 @@ module.exports = function (db, module) { return callback(); } - db.collection('objects').findOne({_key: key}, { array: 1}, function (err, data) { + db.collection('objects').findOne({ _key: key }, { array: 1 }, function (err, data) { if (err || !(data && data.array)) { return callback(err, []); } diff --git a/src/database/mongo/main.js b/src/database/mongo/main.js index 0aa832e02d..c4cd9fe752 100644 --- a/src/database/mongo/main.js +++ b/src/database/mongo/main.js @@ -23,7 +23,7 @@ module.exports = function (db, module) { if (!key) { return callback(); } - db.collection('objects').findOne({_key: key}, function (err, item) { + db.collection('objects').findOne({ _key: key }, function (err, item) { callback(err, item !== undefined && item !== null); }); }; @@ -33,7 +33,7 @@ module.exports = function (db, module) { if (!key) { return callback(); } - db.collection('objects').remove({_key: key}, function (err, res) { + db.collection('objects').remove({ _key: key }, function (err, res) { callback(err); }); }; @@ -43,7 +43,7 @@ module.exports = function (db, module) { if (!Array.isArray(keys) || !keys.length) { return callback(); } - db.collection('objects').remove({_key: {$in: keys}}, function (err, res) { + db.collection('objects').remove({ _key: { $in: keys } }, function (err, res) { callback(err); }); }; @@ -60,7 +60,7 @@ module.exports = function (db, module) { if (!key) { return callback(); } - var data = {value: value}; + var data = { value: value }; module.setObject(key, data, callback); }; @@ -69,14 +69,14 @@ module.exports = function (db, module) { if (!key) { return callback(); } - db.collection('objects').findAndModify({_key: key}, {}, {$inc: {value: 1}}, {new: true, upsert: true}, function (err, result) { + db.collection('objects').findAndModify({ _key: key }, {}, { $inc: { value: 1 } }, { new: true, upsert: true }, function (err, result) { callback(err, result && result.value ? result.value.value : null); }); }; module.rename = function (oldKey, newKey, callback) { callback = callback || helpers.noop; - db.collection('objects').update({_key: oldKey}, {$set: {_key: newKey}}, {multi: true}, function (err, res) { + db.collection('objects').update({ _key: oldKey }, { $set: { _key: newKey } }, { multi: true }, function (err, res) { callback(err); }); }; diff --git a/src/database/mongo/sets.js b/src/database/mongo/sets.js index c4834e3fd8..54f6458249 100644 --- a/src/database/mongo/sets.js +++ b/src/database/mongo/sets.js @@ -47,11 +47,11 @@ module.exports = function (db, module) { var bulk = db.collection('objects').initializeUnorderedBulkOp(); for (var i = 0; i < keys.length; i += 1) { - bulk.find({_key: keys[i]}).upsert().updateOne({ $addToSet: { + bulk.find({ _key: keys[i] }).upsert().updateOne({ $addToSet: { members: { $each: value, }, - }}); + } }); } bulk.execute(function (err, res) { @@ -69,7 +69,7 @@ module.exports = function (db, module) { array[index] = helpers.valueToString(element); }); - db.collection('objects').update({_key: key}, {$pullAll: {members: value}}, function (err, res) { + db.collection('objects').update({ _key: key }, { $pullAll: { members: value } }, function (err, res) { callback(err); }); }; @@ -84,9 +84,9 @@ module.exports = function (db, module) { var bulk = db.collection('objects').initializeUnorderedBulkOp(); for (var i = 0; i < keys.length; i += 1) { - bulk.find({_key: keys[i]}).updateOne({$pull: { + bulk.find({ _key: keys[i] }).updateOne({ $pull: { members: value, - }}); + } }); } bulk.execute(function (err, res) { @@ -100,7 +100,7 @@ module.exports = function (db, module) { } value = helpers.valueToString(value); - db.collection('objects').findOne({_key: key, members: value}, {_id: 0, members: 0}, function (err, item) { + db.collection('objects').findOne({ _key: key, members: value }, { _id: 0, members: 0 }, function (err, item) { callback(err, item !== null && item !== undefined); }); }; @@ -114,7 +114,7 @@ module.exports = function (db, module) { values[i] = helpers.valueToString(values[i]); } - db.collection('objects').findOne({_key: key}, {_id: 0, _key: 0}, function (err, items) { + db.collection('objects').findOne({ _key: key }, { _id: 0, _key: 0 }, function (err, items) { if (err) { return callback(err); } @@ -133,7 +133,7 @@ module.exports = function (db, module) { } value = helpers.valueToString(value); - db.collection('objects').find({_key: {$in: sets}, members: value}, {_id: 0, members: 0}).toArray(function (err, result) { + db.collection('objects').find({ _key: { $in: sets }, members: value }, { _id: 0, members: 0 }).toArray(function (err, result) { if (err) { return callback(err); } @@ -154,7 +154,7 @@ module.exports = function (db, module) { if (!key) { return callback(null, []); } - db.collection('objects').findOne({_key: key}, {members: 1}, {_id: 0, _key: 0}, function (err, data) { + db.collection('objects').findOne({ _key: key }, { members: 1 }, { _id: 0, _key: 0 }, function (err, data) { callback(err, data ? data.members : []); }); }; @@ -163,7 +163,7 @@ module.exports = function (db, module) { if (!Array.isArray(keys) || !keys.length) { return callback(null, []); } - db.collection('objects').find({_key: {$in: keys}}, {_id: 0, _key: 1, members: 1}).toArray(function (err, data) { + db.collection('objects').find({ _key: { $in: keys } }, { _id: 0, _key: 1, members: 1 }).toArray(function (err, data) { if (err) { return callback(err); } @@ -185,7 +185,7 @@ module.exports = function (db, module) { if (!key) { return callback(null, 0); } - db.collection('objects').findOne({_key: key}, {_id: 0}, function (err, data) { + db.collection('objects').findOne({ _key: key }, { _id: 0 }, function (err, data) { callback(err, data ? data.members.length : 0); }); }; @@ -205,7 +205,7 @@ module.exports = function (db, module) { module.setRemoveRandom = function (key, callback) { callback = callback || function () {}; - db.collection('objects').findOne({_key: key}, function (err, data) { + db.collection('objects').findOne({ _key: key }, function (err, data) { if (err || !data) { return callback(err); } diff --git a/src/database/mongo/sorted.js b/src/database/mongo/sorted.js index f20e3330a5..d274146f67 100644 --- a/src/database/mongo/sorted.js +++ b/src/database/mongo/sorted.js @@ -32,13 +32,13 @@ module.exports = function (db, module) { return callback(); } - var fields = {_id: 0, value: 1}; + var fields = { _id: 0, value: 1 }; if (withScores) { fields.score = 1; } if (Array.isArray(key)) { - key = {$in: key}; + key = { $in: key }; } var limit = stop - start + 1; @@ -46,10 +46,10 @@ module.exports = function (db, module) { limit = 0; } - db.collection('objects').find({_key: key}, {fields: fields}) + db.collection('objects').find({ _key: key }, { fields: fields }) .limit(limit) .skip(start) - .sort({score: sort}) + .sort({ score: sort }) .toArray(function (err, data) { if (err || !data) { return callback(err); @@ -89,25 +89,25 @@ module.exports = function (db, module) { count = 0; } - var query = {_key: key}; + var query = { _key: key }; if (min !== '-inf') { - query.score = {$gte: min}; + query.score = { $gte: min }; } if (max !== '+inf') { query.score = query.score || {}; query.score.$lte = max; } - var fields = {_id: 0, value: 1}; + var fields = { _id: 0, value: 1 }; if (withScores) { fields.score = 1; } - db.collection('objects').find(query, {fields: fields}) + db.collection('objects').find(query, { fields: fields }) .limit(count) .skip(start) - .sort({score: sort}) + .sort({ score: sort }) .toArray(function (err, data) { if (err) { return callback(err); @@ -128,9 +128,9 @@ module.exports = function (db, module) { return callback(); } - var query = {_key: key}; + var query = { _key: key }; if (min !== '-inf') { - query.score = {$gte: min}; + query.score = { $gte: min }; } if (max !== '+inf') { query.score = query.score || {}; @@ -146,7 +146,7 @@ module.exports = function (db, module) { if (!key) { return callback(null, 0); } - db.collection('objects').count({_key: key}, function (err, count) { + db.collection('objects').count({ _key: key }, function (err, count) { count = parseInt(count, 10); callback(err, count ? count : 0); }); @@ -158,7 +158,7 @@ module.exports = function (db, module) { } var pipeline = [ { $match: { _key: { $in: keys } } }, - { $group: { _id: {_key: '$_key'}, count: { $sum: 1 } } }, + { $group: { _id: { _key: '$_key' }, count: { $sum: 1 } } }, { $project: { _id: 1, count: '$count' } }, ]; db.collection('objects').aggregate(pipeline, function (err, results) { @@ -213,7 +213,7 @@ module.exports = function (db, module) { } var data = new Array(values.length); for (var i = 0; i < values.length; i += 1) { - data[i] = {key: keys[i], value: values[i]}; + data[i] = { key: keys[i], value: values[i] }; } async.map(data, function (item, next) { @@ -244,7 +244,7 @@ module.exports = function (db, module) { return callback(); } value = helpers.valueToString(value); - db.collection('objects').findOne({_key: key, value: value}, {fields: {_id: 0, score: 1}}, function (err, result) { + db.collection('objects').findOne({ _key: key, value: value }, { fields: { _id: 0, score: 1 } }, function (err, result) { callback(err, result ? result.score : null); }); }; @@ -254,7 +254,7 @@ module.exports = function (db, module) { return callback(); } value = helpers.valueToString(value); - db.collection('objects').find({_key: {$in: keys}, value: value}, {_id: 0, _key: 1, score: 1}).toArray(function (err, result) { + db.collection('objects').find({ _key: { $in: keys }, value: value }, { _id: 0, _key: 1, score: 1 }).toArray(function (err, result) { if (err) { return callback(err); } @@ -277,7 +277,7 @@ module.exports = function (db, module) { return callback(); } values = values.map(helpers.valueToString); - db.collection('objects').find({_key: key, value: {$in: values}}, {_id: 0, value: 1, score: 1}).toArray(function (err, result) { + db.collection('objects').find({ _key: key, value: { $in: values } }, { _id: 0, value: 1, score: 1 }).toArray(function (err, result) { if (err) { return callback(err); } @@ -304,7 +304,7 @@ module.exports = function (db, module) { return callback(); } value = helpers.valueToString(value); - db.collection('objects').findOne({_key: key, value: value}, {_id: 0, value: 1}, function (err, result) { + db.collection('objects').findOne({ _key: key, value: value }, { _id: 0, value: 1 }, function (err, result) { callback(err, !!result); }); }; @@ -314,7 +314,7 @@ module.exports = function (db, module) { return callback(); } values = values.map(helpers.valueToString); - db.collection('objects').find({_key: key, value: {$in: values}}, {fields: {_id: 0, value: 1}}).toArray(function (err, results) { + db.collection('objects').find({ _key: key, value: { $in: values } }, { fields: { _id: 0, value: 1 } }).toArray(function (err, results) { if (err) { return callback(err); } @@ -335,7 +335,7 @@ module.exports = function (db, module) { return callback(); } value = helpers.valueToString(value); - db.collection('objects').find({_key: {$in: keys}, value: value}, {fields: {_id: 0, _key: 1, value: 1}}).toArray(function (err, results) { + db.collection('objects').find({ _key: { $in: keys }, value: value }, { fields: { _id: 0, _key: 1, value: 1 } }).toArray(function (err, results) { if (err) { return callback(err); } @@ -355,7 +355,7 @@ module.exports = function (db, module) { if (!Array.isArray(keys) || !keys.length) { return callback(null, []); } - db.collection('objects').find({_key: {$in: keys}}, {_id: 0, _key: 1, value: 1}).toArray(function (err, data) { + db.collection('objects').find({ _key: { $in: keys } }, { _id: 0, _key: 1, value: 1 }).toArray(function (err, data) { if (err) { return callback(err); } @@ -383,7 +383,7 @@ module.exports = function (db, module) { value = helpers.valueToString(value); data.score = parseFloat(increment); - db.collection('objects').findAndModify({_key: key, value: value}, {}, {$inc: data}, {new: true, upsert: true}, function (err, result) { + db.collection('objects').findAndModify({ _key: key, value: value }, {}, { $inc: data }, { new: true, upsert: true }, function (err, result) { // if there is duplicate key error retry the upsert // https://github.com/NodeBB/NodeBB/issues/4467 // https://jira.mongodb.org/browse/SERVER-14322 @@ -416,11 +416,11 @@ module.exports = function (db, module) { count = 0; } - var query = {_key: key}; + var query = { _key: key }; buildLexQuery(query, min, max); - db.collection('objects').find(query, {_id: 0, value: 1}) - .sort({value: sort}) + db.collection('objects').find(query, { _id: 0, value: 1 }) + .sort({ value: sort }) .skip(start) .limit(count === -1 ? 0 : count) .toArray(function (err, data) { @@ -437,7 +437,7 @@ module.exports = function (db, module) { module.sortedSetRemoveRangeByLex = function (key, min, max, callback) { callback = callback || helpers.noop; - var query = {_key: key}; + var query = { _key: key }; buildLexQuery(query, min, max); db.collection('objects').remove(query, function (err) { @@ -448,11 +448,11 @@ module.exports = function (db, module) { function buildLexQuery(query, min, max) { if (min !== '-') { if (min.match(/^\(/)) { - query.value = {$gt: min.slice(1)}; + query.value = { $gt: min.slice(1) }; } else if (min.match(/^\[/)) { - query.value = {$gte: min.slice(1)}; + query.value = { $gte: min.slice(1) }; } else { - query.value = {$gte: min}; + query.value = { $gte: min }; } } if (max !== '+') { @@ -470,9 +470,9 @@ module.exports = function (db, module) { module.processSortedSet = function (setKey, process, batch, callback) { var done = false; var ids = []; - var cursor = db.collection('objects').find({_key: setKey}) - .sort({score: 1}) - .project({_id: 0, value: 1}) + var cursor = db.collection('objects').find({ _key: setKey }) + .sort({ score: 1 }) + .project({ _id: 0, value: 1 }) .batchSize(batch); async.whilst( diff --git a/src/database/mongo/sorted/add.js b/src/database/mongo/sorted/add.js index acbb279985..b90501feee 100644 --- a/src/database/mongo/sorted/add.js +++ b/src/database/mongo/sorted/add.js @@ -14,7 +14,7 @@ module.exports = function (db, module) { value = helpers.valueToString(value); - db.collection('objects').update({_key: key, value: value}, {$set: {score: parseFloat(score)}}, {upsert: true, w: 1}, function (err) { + db.collection('objects').update({ _key: key, value: value }, { $set: { score: parseFloat(score) } }, { upsert: true, w: 1 }, function (err) { if (err && err.message.startsWith('E11000 duplicate key error')) { return process.nextTick(module.sortedSetAdd, key, score, value, callback); } @@ -35,7 +35,7 @@ module.exports = function (db, module) { var bulk = db.collection('objects').initializeUnorderedBulkOp(); for (var i = 0; i < scores.length; i += 1) { - bulk.find({_key: key, value: values[i]}).upsert().updateOne({$set: {score: parseFloat(scores[i])}}); + bulk.find({ _key: key, value: values[i] }).upsert().updateOne({ $set: { score: parseFloat(scores[i]) } }); } bulk.execute(function (err) { @@ -53,7 +53,7 @@ module.exports = function (db, module) { var bulk = db.collection('objects').initializeUnorderedBulkOp(); for (var i = 0; i < keys.length; i += 1) { - bulk.find({_key: keys[i], value: value}).upsert().updateOne({$set: {score: parseFloat(score)}}); + bulk.find({ _key: keys[i], value: value }).upsert().updateOne({ $set: { score: parseFloat(score) } }); } bulk.execute(function (err) { diff --git a/src/database/mongo/sorted/intersect.js b/src/database/mongo/sorted/intersect.js index dc1d4ef54c..82f24214ea 100644 --- a/src/database/mongo/sorted/intersect.js +++ b/src/database/mongo/sorted/intersect.js @@ -7,9 +7,9 @@ module.exports = function (db, module) { } var pipeline = [ - { $match: { _key: {$in: keys}} }, - { $group: { _id: {value: '$value'}, count: {$sum: 1}} }, - { $match: { count: keys.length} }, + { $match: { _key: { $in: keys } } }, + { $group: { _id: { value: '$value' }, count: { $sum: 1 } } }, + { $match: { count: keys.length } }, { $group: { _id: null, count: { $sum: 1 } } }, ]; @@ -47,7 +47,7 @@ module.exports = function (db, module) { limit = 0; } - var pipeline = [{ $match: { _key: {$in: sets}} }]; + var pipeline = [{ $match: { _key: { $in: sets } } }]; weights.forEach(function (weight, index) { if (weight !== 1) { @@ -70,9 +70,9 @@ module.exports = function (db, module) { } }); - pipeline.push({ $group: { _id: {value: '$value'}, totalScore: aggregate, count: {$sum: 1}} }); - pipeline.push({ $match: { count: sets.length} }); - pipeline.push({ $sort: { totalScore: params.sort} }); + pipeline.push({ $group: { _id: { value: '$value' }, totalScore: aggregate, count: { $sum: 1 } } }); + pipeline.push({ $match: { count: sets.length } }); + pipeline.push({ $sort: { totalScore: params.sort } }); if (start) { pipeline.push({ $skip: start }); @@ -82,7 +82,7 @@ module.exports = function (db, module) { pipeline.push({ $limit: limit }); } - var project = { _id: 0, value: '$_id.value'}; + var project = { _id: 0, value: '$_id.value' }; if (params.withScores) { project.score = '$totalScore'; } diff --git a/src/database/mongo/sorted/remove.js b/src/database/mongo/sorted/remove.js index cceb4e0c6a..e8dea857eb 100644 --- a/src/database/mongo/sorted/remove.js +++ b/src/database/mongo/sorted/remove.js @@ -14,10 +14,10 @@ module.exports = function (db, module) { if (Array.isArray(value)) { value = value.map(helpers.valueToString); - db.collection('objects').remove({_key: key, value: {$in: value}}, done); + db.collection('objects').remove({ _key: key, value: { $in: value } }, done); } else { value = helpers.valueToString(value); - db.collection('objects').remove({_key: key, value: value}, done); + db.collection('objects').remove({ _key: key, value: value }, done); } }; @@ -28,7 +28,7 @@ module.exports = function (db, module) { } value = helpers.valueToString(value); - db.collection('objects').remove({_key: {$in: keys}, value: value}, function (err) { + db.collection('objects').remove({ _key: { $in: keys }, value: value }, function (err) { callback(err); }); }; @@ -38,10 +38,10 @@ module.exports = function (db, module) { if (!Array.isArray(keys) || !keys.length) { return callback(); } - var query = {_key: {$in: keys}}; + var query = { _key: { $in: keys } }; if (min !== '-inf') { - query.score = {$gte: min}; + query.score = { $gte: min }; } if (max !== '+inf') { query.score = query.score || {}; diff --git a/src/database/mongo/sorted/union.js b/src/database/mongo/sorted/union.js index ee8ae3e261..a06df788aa 100644 --- a/src/database/mongo/sorted/union.js +++ b/src/database/mongo/sorted/union.js @@ -7,8 +7,8 @@ module.exports = function (db, module) { } var pipeline = [ - { $match: { _key: {$in: keys} } }, - { $group: { _id: {value: '$value' } } }, + { $match: { _key: { $in: keys } } }, + { $group: { _id: { value: '$value' } } }, { $group: { _id: null, count: { $sum: 1 } } }, ]; @@ -47,9 +47,9 @@ module.exports = function (db, module) { } var pipeline = [ - { $match: { _key: {$in: params.sets}} }, - { $group: { _id: {value: '$value'}, totalScore: aggregate} }, - { $sort: { totalScore: params.sort} }, + { $match: { _key: { $in: params.sets } } }, + { $group: { _id: { value: '$value' }, totalScore: aggregate } }, + { $sort: { totalScore: params.sort } }, ]; if (params.start) { diff --git a/src/database/redis/sorted.js b/src/database/redis/sorted.js index feb8a4cc27..2fd3220eaa 100644 --- a/src/database/redis/sorted.js +++ b/src/database/redis/sorted.js @@ -28,7 +28,7 @@ module.exports = function (redisClient, module) { function sortedSetRange(method, key, start, stop, withScores, callback) { if (Array.isArray(key)) { - return module.sortedSetUnion({method: method, sets: key, start: start, stop: stop, withScores: withScores}, callback); + return module.sortedSetUnion({ method: method, sets: key, start: start, stop: stop, withScores: withScores }, callback); } var params = [key, start, stop]; @@ -45,7 +45,7 @@ module.exports = function (redisClient, module) { } var objects = []; for (var i = 0; i < data.length; i += 2) { - objects.push({value: data[i], score: parseFloat(data[i + 1])}); + objects.push({ value: data[i], score: parseFloat(data[i + 1]) }); } callback(null, objects); }); @@ -74,7 +74,7 @@ module.exports = function (redisClient, module) { } var objects = []; for (var i = 0; i < data.length; i += 2) { - objects.push({value: data[i], score: parseFloat(data[i + 1])}); + objects.push({ value: data[i], score: parseFloat(data[i + 1]) }); } callback(null, objects); }); diff --git a/src/database/redis/sorted/intersect.js b/src/database/redis/sorted/intersect.js index aeb68d02ef..86240a7a34 100644 --- a/src/database/redis/sorted/intersect.js +++ b/src/database/redis/sorted/intersect.js @@ -70,7 +70,7 @@ module.exports = function (redisClient, module) { results = results[1] || []; var objects = []; for (var i = 0; i < results.length; i += 2) { - objects.push({value: results[i], score: parseFloat(results[i + 1])}); + objects.push({ value: results[i], score: parseFloat(results[i + 1]) }); } callback(null, objects); }); diff --git a/src/database/redis/sorted/union.js b/src/database/redis/sorted/union.js index 88bdd3e7bf..ea17ee2d4e 100644 --- a/src/database/redis/sorted/union.js +++ b/src/database/redis/sorted/union.js @@ -50,7 +50,7 @@ module.exports = function (redisClient, module) { results = results[1] || []; var objects = []; for (var i = 0; i < results.length; i += 2) { - objects.push({value: results[i], score: parseFloat(results[i + 1])}); + objects.push({ value: results[i], score: parseFloat(results[i + 1]) }); } callback(null, objects); }); diff --git a/src/events.js b/src/events.js index 9665ec265f..a484aa1fef 100644 --- a/src/events.js +++ b/src/events.js @@ -130,6 +130,6 @@ var utils = require('../public/src/utils'); batch.processSortedSet('events:time', function (eids, next) { events.deleteEvents(eids, next); - }, {alwaysStartAt: 0}, callback); + }, { alwaysStartAt: 0 }, callback); }; }(module.exports)); diff --git a/src/groups.js b/src/groups.js index 0d2a22c131..775d19b378 100644 --- a/src/groups.js +++ b/src/groups.js @@ -184,7 +184,7 @@ var utils = require('../public/src/utils'); results.base.isInvited = results.isInvited; results.base.isOwner = results.isOwner; - plugins.fireHook('filter:group.get', {group: results.base}, function (err, data) { + plugins.fireHook('filter:group.get', { group: results.base }, function (err, data) { callback(err, data ? data.group : null); }); }); @@ -274,7 +274,7 @@ var utils = require('../public/src/utils'); if (err) { return callback(err); } - plugins.fireHook('action:group.set', {field: field, value: value, type: 'set'}); + plugins.fireHook('action:group.set', { field: field, value: value, type: 'set' }); callback(); }); }; @@ -358,7 +358,7 @@ var utils = require('../public/src/utils'); privileges.posts.filter('read', pids, uid, next); }, function (pids, next) { - posts.getPostSummaryByPids(pids, uid, {stripTags: false}, next); + posts.getPostSummaryByPids(pids, uid, { stripTags: false }, next); }, ], callback); }; @@ -414,7 +414,7 @@ var utils = require('../public/src/utils'); } }); - plugins.fireHook('filter:groups.get', {groups: groupData}, function (err, data) { + plugins.fireHook('filter:groups.get', { groups: groupData }, function (err, data) { callback(err, data ? data.groups : null); }); }); diff --git a/src/groups/cover.js b/src/groups/cover.js index 0f56621212..d7dd9a8b79 100644 --- a/src/groups/cover.js +++ b/src/groups/cover.js @@ -74,7 +74,7 @@ module.exports = function (Groups) { if (unlinkErr) { winston.error(unlinkErr); } - callback(err, {url: url}); + callback(err, { url: url }); }); }); }; diff --git a/src/groups/create.js b/src/groups/create.js index eef4eda5f0..4b680b8992 100644 --- a/src/groups/create.js +++ b/src/groups/create.js @@ -43,7 +43,7 @@ module.exports = function (Groups) { private: isPrivate, disableJoinRequests: disableJoinRequests, }; - plugins.fireHook('filter:group.create', {group: groupData, data: data}, next); + plugins.fireHook('filter:group.create', { group: groupData, data: data }, next); }, function (results, next) { var tasks = [ diff --git a/src/groups/membership.js b/src/groups/membership.js index 268edc6eca..b0afbbd9c8 100644 --- a/src/groups/membership.js +++ b/src/groups/membership.js @@ -317,7 +317,7 @@ module.exports = function (Groups) { }); function clearCache(uid, groupName) { - pubsub.publish('group:cache:del', {uid: uid, groupName: groupName}); + pubsub.publish('group:cache:del', { uid: uid, groupName: groupName }); cache.del(uid + ':' + groupName); } diff --git a/src/groups/ownership.js b/src/groups/ownership.js index 779644d2a9..0b386bbe35 100644 --- a/src/groups/ownership.js +++ b/src/groups/ownership.js @@ -29,7 +29,7 @@ module.exports = function (Groups) { db.setAdd('group:' + groupName + ':owners', toUid, next); }, function (next) { - plugins.fireHook('action:group.grantOwnership', {uid: toUid, groupName: groupName}); + plugins.fireHook('action:group.grantOwnership', { uid: toUid, groupName: groupName }); next(); }, ], callback); @@ -50,7 +50,7 @@ module.exports = function (Groups) { db.setRemove('group:' + groupName + ':owners', toUid, next); }, function (next) { - plugins.fireHook('action:group.rescindOwnership', {uid: toUid, groupName: groupName}); + plugins.fireHook('action:group.rescindOwnership', { uid: toUid, groupName: groupName }); next(); }, ], callback); diff --git a/src/groups/search.js b/src/groups/search.js index 680dff11e8..44bc835d5c 100644 --- a/src/groups/search.js +++ b/src/groups/search.js @@ -91,7 +91,7 @@ module.exports = function (Groups) { if (err) { return callback(err); } - callback(null, {users: users}); + callback(null, { users: users }); }); return; } diff --git a/src/install.js b/src/install.js index 126c96ae79..a06a138f26 100644 --- a/src/install.js +++ b/src/install.js @@ -272,7 +272,7 @@ function createAdmin(callback) { var adminUid; async.waterfall([ function (next) { - User.create({username: results.username, password: results.password, email: results.email}, next); + User.create({ username: results.username, password: results.password, email: results.email }, next); }, function (uid, next) { adminUid = uid; diff --git a/src/logger.js b/src/logger.js index 3e0c1996d2..c40ae49ae1 100644 --- a/src/logger.js +++ b/src/logger.js @@ -77,13 +77,13 @@ var opts = { var stats = fs.statSync(value); if (stats) { if (stats.isDirectory()) { - stream = fs.createWriteStream(path.join(value, 'nodebb.log'), {flags: 'a'}); + stream = fs.createWriteStream(path.join(value, 'nodebb.log'), { flags: 'a' }); } else { - stream = fs.createWriteStream(value, {flags: 'a'}); + stream = fs.createWriteStream(value, { flags: 'a' }); } } } else { - stream = fs.createWriteStream(value, {flags: 'a'}); + stream = fs.createWriteStream(value, { flags: 'a' }); } if (stream) { @@ -121,7 +121,7 @@ var opts = { /* * Always initialize "ofn" (original function) with the original logger function */ - opts.express.ofn = morgan('combined', {stream: opts.streams.log.f}); + opts.express.ofn = morgan('combined', { stream: opts.streams.log.f }); }; Logger.expressLogger = function (req, res, next) { diff --git a/src/messaging.js b/src/messaging.js index aa24944c96..9f939564dd 100644 --- a/src/messaging.js +++ b/src/messaging.js @@ -170,7 +170,7 @@ Messaging.getRecentChats = function (callerUid, uid, start, stop, callback) { room.usernames = Messaging.generateUsernames(room.users, uid); }); - next(null, {rooms: results.roomData, nextStart: stop + 1}); + next(null, { rooms: results.roomData, nextStart: stop + 1 }); }, ], callback); }; diff --git a/src/messaging/rooms.js b/src/messaging/rooms.js index 0356daec64..ead62fee4d 100644 --- a/src/messaging/rooms.js +++ b/src/messaging/rooms.js @@ -79,7 +79,7 @@ module.exports = function (Messaging) { db.isSortedSetMember('chat:room:' + roomId + ':uids', uid, next); }, function (inRoom, next) { - plugins.fireHook('filter:messaging.isUserInRoom', {uid: uid, roomId: roomId, inRoom: inRoom}, next); + plugins.fireHook('filter:messaging.isUserInRoom', { uid: uid, roomId: roomId, inRoom: inRoom }, next); }, function (data, next) { next(null, data.inRoom); @@ -214,7 +214,7 @@ module.exports = function (Messaging) { db.isSortedSetMember('chat:room:' + roomId + ':uids', uid, next); }, function (inRoom, next) { - plugins.fireHook('filter:messaging.canReply', {uid: uid, roomId: roomId, inRoom: inRoom, canReply: inRoom}, next); + plugins.fireHook('filter:messaging.canReply', { uid: uid, roomId: roomId, inRoom: inRoom, canReply: inRoom }, next); }, function (data, next) { next(null, data.canReply); diff --git a/src/meta.js b/src/meta.js index d4aa3cae49..6cbccd70a1 100644 --- a/src/meta.js +++ b/src/meta.js @@ -47,7 +47,7 @@ var utils = require('../public/src/utils'); }; Meta.restart = function () { - pubsub.publish('meta:restart', {hostname: os.hostname()}); + pubsub.publish('meta:restart', { hostname: os.hostname() }); restart(); }; diff --git a/src/meta/js.js b/src/meta/js.js index 189c0757de..f028717ba7 100644 --- a/src/meta/js.js +++ b/src/meta/js.js @@ -235,7 +235,7 @@ module.exports = function (Meta) { /** * otherwise, just clean up --debug/--debug-brk options which are set up by default from the parent one */ - forkProcessParams = {execArgv: []}; + forkProcessParams = { execArgv: [] }; } return forkProcessParams; diff --git a/src/middleware/admin.js b/src/middleware/admin.js index 02c15c099d..fb950b7480 100644 --- a/src/middleware/admin.js +++ b/src/middleware/admin.js @@ -64,7 +64,7 @@ module.exports = function (middleware) { } var arr = []; scripts.forEach(function (script) { - arr.push({src: script}); + arr.push({ src: script }); }); next(null, arr); @@ -107,7 +107,7 @@ module.exports = function (middleware) { bodyClass: data.bodyClass, }; - templateValues.template = {name: res.locals.template}; + templateValues.template = { name: res.locals.template }; templateValues.template[res.locals.template] = true; req.app.render('admin/header', templateValues, next); diff --git a/src/middleware/header.js b/src/middleware/header.js index 670bf83303..1928169ae6 100644 --- a/src/middleware/header.js +++ b/src/middleware/header.js @@ -28,7 +28,7 @@ module.exports = function (middleware) { controllers.api.getConfig(req, res, next); }, plugins: function (next) { - plugins.fireHook('filter:middleware.buildHeader', {req: req, locals: res.locals}, next); + plugins.fireHook('filter:middleware.buildHeader', { req: req, locals: res.locals }, next); }, }, next); }, @@ -139,18 +139,18 @@ module.exports = function (middleware) { templateValues.privateUserInfo = parseInt(meta.config.privateUserInfo, 10) === 1; templateValues.privateTagListing = parseInt(meta.config.privateTagListing, 10) === 1; - templateValues.template = {name: res.locals.template}; + templateValues.template = { name: res.locals.template }; templateValues.template[res.locals.template] = true; templateValues.scripts = results.scripts.map(function (script) { - return {src: script}; + return { src: script }; }); if (req.route && req.route.path === '/') { modifyTitle(templateValues); } - plugins.fireHook('filter:middleware.renderHeader', {templateValues: templateValues, req: req, res: res}, function (err, data) { + plugins.fireHook('filter:middleware.renderHeader', { templateValues: templateValues, req: req, res: res }, function (err, data) { if (err) { return callback(err); } @@ -161,7 +161,7 @@ module.exports = function (middleware) { }; middleware.renderFooter = function (req, res, data, callback) { - plugins.fireHook('filter:middleware.renderFooter', {templateValues: data, req: req, res: res}, function (err, data) { + plugins.fireHook('filter:middleware.renderFooter', { templateValues: data, req: req, res: res }, function (err, data) { if (err) { return callback(err); } diff --git a/src/middleware/index.js b/src/middleware/index.js index e9a172c326..798067429a 100644 --- a/src/middleware/index.js +++ b/src/middleware/index.js @@ -80,7 +80,7 @@ middleware.pageView = function (req, res, next) { uid: req.uid, }); - plugins.fireHook('action:middleware.pageView', {req: req}); + plugins.fireHook('action:middleware.pageView', { req: req }); if (req.user) { user.updateLastOnlineTime(req.user.uid); diff --git a/src/middleware/render.js b/src/middleware/render.js index 0716869649..9109e8daaf 100644 --- a/src/middleware/render.js +++ b/src/middleware/render.js @@ -36,15 +36,15 @@ module.exports = function (middleware) { function (next) { options.loggedIn = !!req.uid; options.relative_path = nconf.get('relative_path'); - options.template = {name: template}; + options.template = { name: template }; options.template[template] = true; options.url = (req.baseUrl + req.path).replace(/^\/api/, ''); options.bodyClass = buildBodyClass(req); - plugins.fireHook('filter:' + template + '.build', {req: req, res: res, templateData: options}, next); + plugins.fireHook('filter:' + template + '.build', { req: req, res: res, templateData: options }, next); }, function (data, next) { - plugins.fireHook('filter:middleware.render', {req: res, res: res, templateData: data.templateData}, next); + plugins.fireHook('filter:middleware.render', { req: res, res: res, templateData: data.templateData }, next); }, function (data, next) { options = data.templateData; diff --git a/src/middleware/user.js b/src/middleware/user.js index 881820da0c..ed56ad6d9e 100644 --- a/src/middleware/user.js +++ b/src/middleware/user.js @@ -141,7 +141,7 @@ module.exports = function (middleware) { return next(); } - res.status(403).render('403', {title: '[[global:403.title]]'}); + res.status(403).render('403', { title: '[[global:403.title]]' }); }; middleware.registrationComplete = function (req, res, next) { diff --git a/src/notifications.js b/src/notifications.js index 0fad742e1a..c2c8f01874 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -171,7 +171,7 @@ var utils = require('../public/src/utils'); setTimeout(function () { batch.processArray(uids, function (uids, next) { pushToUids(uids, notification, next); - }, {interval: 1000}, function (err) { + }, { interval: 1000 }, function (err) { if (err) { winston.error(err.stack); } @@ -188,7 +188,7 @@ var utils = require('../public/src/utils'); async.waterfall([ function (next) { - plugins.fireHook('filter:notification.push', {notification: notification, uids: uids}, next); + plugins.fireHook('filter:notification.push', { notification: notification, uids: uids }, next); }, function (data, next) { uids = data.uids; @@ -218,7 +218,7 @@ var utils = require('../public/src/utils'); }); } - plugins.fireHook('action:notification.pushed', {notification: notification, uids: uids}); + plugins.fireHook('action:notification.pushed', { notification: notification, uids: uids }); next(); }, ], callback); diff --git a/src/pagination.js b/src/pagination.js index 6f61c80def..c0332ebd14 100644 --- a/src/pagination.js +++ b/src/pagination.js @@ -7,8 +7,8 @@ var pagination = {}; pagination.create = function (currentPage, pageCount, queryObj) { if (pageCount <= 1) { return { - prev: {page: 1, active: currentPage > 1}, - next: {page: 1, active: currentPage < pageCount}, + prev: { page: 1, active: currentPage > 1 }, + next: { page: 1, active: currentPage < pageCount }, rel: [], pages: [], currentPage: 1, @@ -42,22 +42,22 @@ pagination.create = function (currentPage, pageCount, queryObj) { var pages = pagesToShow.map(function (page) { queryObj.page = page; - return {page: page, active: page === currentPage, qs: qs.stringify(queryObj)}; + return { page: page, active: page === currentPage, qs: qs.stringify(queryObj) }; }); for (i = pages.length - 1; i > 0; i -= 1) { if (pages[i].page - 2 === pages[i - 1].page) { - pages.splice(i, 0, {page: pages[i].page - 1, active: false, qs: qs.stringify(queryObj)}); + pages.splice(i, 0, { page: pages[i].page - 1, active: false, qs: qs.stringify(queryObj) }); } else if (pages[i].page - 1 !== pages[i - 1].page) { - pages.splice(i, 0, {separator: true}); + pages.splice(i, 0, { separator: true }); } } - var data = {rel: [], pages: pages, currentPage: currentPage, pageCount: pageCount}; + var data = { rel: [], pages: pages, currentPage: currentPage, pageCount: pageCount }; queryObj.page = previous; - data.prev = {page: previous, active: currentPage > 1, qs: qs.stringify(queryObj)}; + data.prev = { page: previous, active: currentPage > 1, qs: qs.stringify(queryObj) }; queryObj.page = next; - data.next = {page: next, active: currentPage < pageCount, qs: qs.stringify(queryObj)}; + data.next = { page: next, active: currentPage < pageCount, qs: qs.stringify(queryObj) }; if (currentPage < pageCount) { data.rel.push({ diff --git a/src/password.js b/src/password.js index c98b2f5ba6..d4fd1b0f8d 100644 --- a/src/password.js +++ b/src/password.js @@ -4,17 +4,17 @@ var fork = require('child_process').fork; module.hash = function (rounds, password, callback) { - forkChild({type: 'hash', rounds: rounds, password: password}, callback); + forkChild({ type: 'hash', rounds: rounds, password: password }, callback); }; module.compare = function (password, hash, callback) { - forkChild({type: 'compare', password: password, hash: hash}, callback); + forkChild({ type: 'compare', password: password, hash: hash }, callback); }; function forkChild(message, callback) { var forkProcessParams = {}; if (global.v8debug || parseInt(process.execArgv.indexOf('--debug'), 10) !== -1) { - forkProcessParams = {execArgv: ['--debug=' + (5859), '--nolazy']}; + forkProcessParams = { execArgv: ['--debug=' + (5859), '--nolazy'] }; } var child = fork('./bcrypt', [], forkProcessParams); diff --git a/src/plugins.js b/src/plugins.js index 75b3c49b23..dd2423f70f 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -135,7 +135,7 @@ var middleware; }; var controllers = require('./controllers'); - Plugins.fireHook('static:app.load', {app: app, router: router, middleware: middleware, controllers: controllers}, function (err) { + Plugins.fireHook('static:app.load', { app: app, router: router, middleware: middleware, controllers: controllers }, function (err) { if (err) { return winston.error('[plugins] Encountered error while executing post-router plugins hooks: ' + err.message); } diff --git a/src/plugins/install.js b/src/plugins/install.js index d3d70d9034..be97ad4a68 100644 --- a/src/plugins/install.js +++ b/src/plugins/install.js @@ -57,12 +57,12 @@ module.exports = function (Plugins) { winston.warn('[plugins] Could not toggle active state on plugin \'' + id + '\''); return callback(err); } - callback(null, {id: id, active: !isActive}); + callback(null, { id: id, active: !isActive }); }); }; Plugins.toggleInstall = function (id, version, callback) { - pubsub.publish('plugins:toggleInstall', {hostname: os.hostname(), id: id, version: version}); + pubsub.publish('plugins:toggleInstall', { hostname: os.hostname(), id: id, version: version }); toggleInstall(id, version, callback); }; @@ -112,7 +112,7 @@ module.exports = function (Plugins) { } Plugins.upgrade = function (id, version, callback) { - pubsub.publish('plugins:upgrade', {hostname: os.hostname(), id: id, version: version}); + pubsub.publish('plugins:upgrade', { hostname: os.hostname(), id: id, version: version }); upgrade(id, version, callback); }; diff --git a/src/posts.js b/src/posts.js index 28126c7e0e..c7e7ec3e0a 100644 --- a/src/posts.js +++ b/src/posts.js @@ -65,7 +65,7 @@ var plugins = require('./plugins'); }, next); }, function (posts, next) { - plugins.fireHook('filter:post.getPosts', {posts: posts, uid: uid}, next); + plugins.fireHook('filter:post.getPosts', { posts: posts, uid: uid }, next); }, function (data, next) { if (!data || !Array.isArray(data.posts)) { @@ -86,10 +86,10 @@ var plugins = require('./plugins'); privileges.posts.filter('read', pids, uid, next); }, function (pids, next) { - Posts.getPostSummaryByPids(pids, uid, {stripTags: false}, next); + Posts.getPostSummaryByPids(pids, uid, { stripTags: false }, next); }, function (posts, next) { - next(null, {posts: posts, nextStart: stop + 1}); + next(null, { posts: posts, nextStart: stop + 1 }); }, ], callback); }; @@ -122,7 +122,7 @@ var plugins = require('./plugins'); data.pid = pid; - plugins.fireHook('filter:post.getFields', {posts: [data], fields: fields}, function (err, data) { + plugins.fireHook('filter:post.getFields', { posts: [data], fields: fields }, function (err, data) { callback(err, (data && Array.isArray(data.posts) && data.posts.length) ? data.posts[0] : null); }); }); @@ -141,7 +141,7 @@ var plugins = require('./plugins'); if (err) { return callback(err); } - plugins.fireHook('filter:post.getFields', {posts: posts, fields: fields}, function (err, data) { + plugins.fireHook('filter:post.getFields', { posts: posts, fields: fields }, function (err, data) { callback(err, (data && Array.isArray(data.posts)) ? data.posts : null); }); }); @@ -250,7 +250,7 @@ var plugins = require('./plugins'); ], next); }, function (next) { - Posts.setPostFields(postData.pid, {upvotes: postData.upvotes, downvotes: postData.downvotes}, next); + Posts.setPostFields(postData.pid, { upvotes: postData.upvotes, downvotes: postData.downvotes }, next); }, ], function (err) { callback(err); diff --git a/src/posts/create.js b/src/posts/create.js index 43cd0817a3..e8e24a5585 100644 --- a/src/posts/create.js +++ b/src/posts/create.js @@ -59,7 +59,7 @@ module.exports = function (Posts) { plugins.fireHook('filter:post.save', postData, next); }, function (postData, next) { - plugins.fireHook('filter:post.create', {post: postData, data: data}, next); + plugins.fireHook('filter:post.create', { post: postData, data: data }, next); }, function (data, next) { postData = data.post; diff --git a/src/posts/delete.js b/src/posts/delete.js index 8076beb06b..63f511481b 100644 --- a/src/posts/delete.js +++ b/src/posts/delete.js @@ -14,10 +14,10 @@ module.exports = function (Posts) { var postData; async.waterfall([ function (next) { - plugins.fireHook('filter:post.delete', {pid: pid, uid: uid}, next); + plugins.fireHook('filter:post.delete', { pid: pid, uid: uid }, next); }, function (data, next) { - Posts.setPostFields(pid, {deleted: 1, deleterUid: uid}, next); + Posts.setPostFields(pid, { deleted: 1, deleterUid: uid }, next); }, function (next) { Posts.getPostFields(pid, ['pid', 'tid', 'uid', 'timestamp'], next); @@ -50,10 +50,10 @@ module.exports = function (Posts) { var postData; async.waterfall([ function (next) { - plugins.fireHook('filter:post.restore', {pid: pid, uid: uid}, next); + plugins.fireHook('filter:post.restore', { pid: pid, uid: uid }, next); }, function (data, next) { - Posts.setPostFields(pid, {deleted: 0, deleterUid: 0}, next); + Posts.setPostFields(pid, { deleted: 0, deleterUid: 0 }, next); }, function (next) { Posts.getPostFields(pid, ['pid', 'tid', 'uid', 'content', 'timestamp'], next); @@ -121,7 +121,7 @@ module.exports = function (Posts) { if (!exists) { return callback(); } - plugins.fireHook('filter:post.purge', {pid: pid, uid: uid}, next); + plugins.fireHook('filter:post.purge', { pid: pid, uid: uid }, next); }, function (data, next) { async.parallel([ diff --git a/src/posts/edit.js b/src/posts/edit.js index 6d133f1395..863888a6ce 100644 --- a/src/posts/edit.js +++ b/src/posts/edit.js @@ -44,7 +44,7 @@ module.exports = function (Posts) { if (data.handle) { postData.handle = data.handle; } - plugins.fireHook('filter:post.edit', {req: data.req, post: postData, data: data, uid: data.uid}, next); + plugins.fireHook('filter:post.edit', { req: data.req, post: postData, data: data, uid: data.uid }, next); }, function (result, next) { postData = result.post; @@ -122,7 +122,7 @@ module.exports = function (Posts) { async.waterfall([ function (next) { - plugins.fireHook('filter:topic.edit', {req: data.req, topic: topicData, data: data}, next); + plugins.fireHook('filter:topic.edit', { req: data.req, topic: topicData, data: data }, next); }, function (results, next) { db.setObject('topic:' + tid, results.topic, next); diff --git a/src/posts/flags.js b/src/posts/flags.js index a1ee62ecd4..4bab4cc771 100644 --- a/src/posts/flags.js +++ b/src/posts/flags.js @@ -175,7 +175,7 @@ module.exports = function (Posts) { async.waterfall([ function (next) { if (Array.isArray(set)) { - db.getSortedSetRevIntersect({sets: set, start: start, stop: -1, aggregate: 'MAX'}, next); + db.getSortedSetRevIntersect({ sets: set, start: start, stop: -1, aggregate: 'MAX' }, next); } else { db.getSortedSetRevRange(set, start, -1, next); } @@ -193,7 +193,7 @@ module.exports = function (Posts) { function (posts, next) { var count = posts.length; var end = stop - start + 1; - next(null, {posts: posts.slice(0, stop === -1 ? undefined : end), count: count}); + next(null, { posts: posts.slice(0, stop === -1 ? undefined : end), count: count }); }, ], callback); }; @@ -208,7 +208,7 @@ module.exports = function (Posts) { }, next); }, posts: function (next) { - Posts.getPostSummaryByPids(pids, uid, {stripTags: false, extraFields: ['flags', 'flag:assignee', 'flag:state', 'flag:notes', 'flag:history']}, next); + Posts.getPostSummaryByPids(pids, uid, { stripTags: false, extraFields: ['flags', 'flag:assignee', 'flag:state', 'flag:notes', 'flag:history'] }, next); }, }, next); }, @@ -218,7 +218,7 @@ module.exports = function (Posts) { var uid = uidReason.split(':')[0]; var reason = uidReason.substr(uidReason.indexOf(':') + 1); user.getUserFields(uid, ['username', 'userslug', 'picture'], function (err, userData) { - next(err, {user: userData, reason: reason}); + next(err, { user: userData, reason: reason }); }); }, next); }, function (err, reasons) { diff --git a/src/posts/parse.js b/src/posts/parse.js index 02cd9fa307..ff8eb29ce7 100644 --- a/src/posts/parse.js +++ b/src/posts/parse.js @@ -26,7 +26,7 @@ module.exports = function (Posts) { postData.content = postData.content.toString(); } - plugins.fireHook('filter:parse.post', {postData: postData}, function (err, data) { + plugins.fireHook('filter:parse.post', { postData: postData }, function (err, data) { if (err) { return callback(err); } @@ -43,7 +43,7 @@ module.exports = function (Posts) { Posts.parseSignature = function (userData, uid, callback) { userData.signature = sanitizeSignature(userData.signature || ''); - plugins.fireHook('filter:parse.signature', {userData: userData, uid: uid}, callback); + plugins.fireHook('filter:parse.signature', { userData: userData, uid: uid }, callback); }; Posts.relativeToAbsolute = function (content) { diff --git a/src/posts/recent.js b/src/posts/recent.js index 1c4cfd6b15..8936ee3633 100644 --- a/src/posts/recent.js +++ b/src/posts/recent.js @@ -28,7 +28,7 @@ module.exports = function (Posts) { privileges.posts.filter('read', pids, uid, next); }, function (pids, next) { - Posts.getPostSummaryByPids(pids, uid, {stripTags: true}, next); + Posts.getPostSummaryByPids(pids, uid, { stripTags: true }, next); }, ], callback); }; diff --git a/src/posts/summary.js b/src/posts/summary.js index 9e88303c1d..93e322229d 100644 --- a/src/posts/summary.js +++ b/src/posts/summary.js @@ -80,7 +80,7 @@ module.exports = function (Posts) { parsePosts(posts, options, next); }, function (posts, next) { - plugins.fireHook('filter:post.getPostSummaryByPids', {posts: posts, uid: uid}, next); + plugins.fireHook('filter:post.getPostSummaryByPids', { posts: posts, uid: uid }, next); }, function (data, next) { next(null, data.posts); @@ -128,7 +128,7 @@ module.exports = function (Posts) { }); categories.getCategoriesFields(cids, ['cid', 'name', 'icon', 'slug', 'parentCid', 'bgColor', 'color'], function (err, categories) { - callback(err, {topics: topics, categories: categories}); + callback(err, { topics: topics, categories: categories }); }); }); } diff --git a/src/posts/user.js b/src/posts/user.js index 74bc16b562..59906bf2ca 100644 --- a/src/posts/user.js +++ b/src/posts/user.js @@ -71,7 +71,7 @@ module.exports = function (Posts) { Posts.parseSignature(userData, uid, next); }, customProfileInfo: function (next) { - plugins.fireHook('filter:posts.custom_profile_info', {profile: [], uid: userData.uid}, next); + plugins.fireHook('filter:posts.custom_profile_info', { profile: [], uid: userData.uid }, next); }, }, function (err, results) { if (err) { diff --git a/src/posts/votes.js b/src/posts/votes.js index 449e929fd7..97f88b3820 100644 --- a/src/posts/votes.js +++ b/src/posts/votes.js @@ -63,7 +63,7 @@ module.exports = function (Posts) { Posts.hasVoted = function (pid, uid, callback) { if (!parseInt(uid, 10)) { - return callback(null, {upvoted: false, downvoted: false}); + return callback(null, { upvoted: false, downvoted: false }); } db.isMemberOfSets(['pid:' + pid + ':upvote', 'pid:' + pid + ':downvote'], uid, function (err, hasVoted) { @@ -71,14 +71,14 @@ module.exports = function (Posts) { return callback(err); } - callback(null, {upvoted: hasVoted[0], downvoted: hasVoted[1]}); + callback(null, { upvoted: hasVoted[0], downvoted: hasVoted[1] }); }); }; Posts.getVoteStatusByPostIDs = function (pids, uid, callback) { if (!parseInt(uid, 10)) { var data = pids.map(function () { return false; }); - return callback(null, {upvotes: data, downvotes: data}); + return callback(null, { upvotes: data, downvotes: data }); } var upvoteSets = []; var downvoteSets = []; diff --git a/src/privileges/categories.js b/src/privileges/categories.js index 5e16fd1b17..ff3d16148f 100644 --- a/src/privileges/categories.js +++ b/src/privileges/categories.js @@ -17,18 +17,18 @@ module.exports = function (privileges) { // Method used in admin/category controller to show all users/groups with privs in that given cid var privilegeLabels = [ - {name: 'Find Category'}, - {name: 'Access Category'}, - {name: 'Access Topics'}, - {name: 'Create Topics'}, - {name: 'Reply to Topics'}, - {name: 'Edit Posts'}, - {name: 'Delete Posts'}, - {name: 'Delete Topics'}, - {name: 'Upload Images'}, - {name: 'Upload Files'}, - {name: 'Purge'}, - {name: 'Moderate'}, + { name: 'Find Category' }, + { name: 'Access Category' }, + { name: 'Access Topics' }, + { name: 'Create Topics' }, + { name: 'Reply to Topics' }, + { name: 'Edit Posts' }, + { name: 'Delete Posts' }, + { name: 'Delete Topics' }, + { name: 'Upload Images' }, + { name: 'Upload Files' }, + { name: 'Purge' }, + { name: 'Moderate' }, ]; async.parallel({ diff --git a/src/privileges/posts.js b/src/privileges/posts.js index a27dd51a93..08703ed3f9 100644 --- a/src/privileges/posts.js +++ b/src/privileges/posts.js @@ -144,7 +144,7 @@ module.exports = function (privileges) { return callback(err); } if (results.isAdminOrMod) { - return callback(null, {flag: true}); + return callback(null, { flag: true }); } callback(null, results.isEditable); @@ -172,24 +172,24 @@ module.exports = function (privileges) { } if (results.isAdminOrMod) { - return callback(null, {flag: true}); + return callback(null, { flag: true }); } if (results.isLocked) { - return callback(null, {flag: false, message: '[[error:topic-locked]]'}); + return callback(null, { flag: false, message: '[[error:topic-locked]]' }); } if (!results['posts:delete']) { - return callback(null, {flag: false, message: '[[error:no-privileges]]'}); + return callback(null, { flag: false, message: '[[error:no-privileges]]' }); } var postDeleteDuration = parseInt(meta.config.postDeleteDuration, 10); if (postDeleteDuration && (Date.now() - parseInt(postData.timestamp, 10) > postDeleteDuration * 1000)) { - return callback(null, {flag: false, message: '[[error:post-delete-duration-expired, ' + meta.config.postDeleteDuration + ']]'}); + return callback(null, { flag: false, message: '[[error:post-delete-duration-expired, ' + meta.config.postDeleteDuration + ']]' }); } var deleterUid = parseInt(postData.deleterUid, 10) || 0; var flag = results.isOwner && (deleterUid === 0 || deleterUid === parseInt(postData.uid, 10)); - callback(null, {flag: flag, message: '[[error:no-privileges]]'}); + callback(null, { flag: flag, message: '[[error:no-privileges]]' }); }); }; @@ -230,13 +230,13 @@ module.exports = function (privileges) { tid = postData.tid; var postEditDuration = parseInt(meta.config.postEditDuration, 10); if (postEditDuration && Date.now() - parseInt(postData.timestamp, 10) > postEditDuration * 1000) { - return callback(null, {flag: false, message: '[[error:post-edit-duration-expired, ' + meta.config.postEditDuration + ']]'}); + return callback(null, { flag: false, message: '[[error:post-edit-duration-expired, ' + meta.config.postEditDuration + ']]' }); } topics.isLocked(postData.tid, next); }, function (isLocked, next) { if (isLocked) { - return callback(null, {flag: false, message: '[[error:topic-locked]]'}); + return callback(null, { flag: false, message: '[[error:topic-locked]]' }); } async.parallel({ @@ -245,7 +245,7 @@ module.exports = function (privileges) { }, next); }, function (result, next) { - next(null, {flag: result.owner && result.edit, message: '[[error:no-privileges]]'}); + next(null, { flag: result.owner && result.edit, message: '[[error:no-privileges]]' }); }, ], callback); } diff --git a/src/privileges/users.js b/src/privileges/users.js index 9d8d55b6f5..a73437db75 100644 --- a/src/privileges/users.js +++ b/src/privileges/users.js @@ -123,7 +123,7 @@ module.exports = function (privileges) { } function filterIsModerator(cid, uid, isModerator, callback) { - plugins.fireHook('filter:user.isModerator', {uid: uid, cid: cid, isModerator: isModerator}, function (err, data) { + plugins.fireHook('filter:user.isModerator', { uid: uid, cid: cid, isModerator: isModerator }, function (err, data) { if (err) { return callback(err); } diff --git a/src/pubsub.js b/src/pubsub.js index 9f7d3fe0d5..b33a03b6bf 100644 --- a/src/pubsub.js +++ b/src/pubsub.js @@ -37,7 +37,7 @@ util.inherits(PubSub, EventEmitter); PubSub.prototype.publish = function (event, data) { if (this.pubClient) { - this.pubClient.publish(channelName, JSON.stringify({event: event, data: data})); + this.pubClient.publish(channelName, JSON.stringify({ event: event, data: data })); } else { this.emit(event, data); } diff --git a/src/rewards/index.js b/src/rewards/index.js index c32bc94c0e..38105dd5ff 100644 --- a/src/rewards/index.js +++ b/src/rewards/index.js @@ -100,7 +100,7 @@ function checkCondition(reward, method, callback) { return callback(err); } - plugins.fireHook('filter:rewards.checkConditional:' + reward.conditional, {left: value, right: reward.value}, function (err, bool) { + plugins.fireHook('filter:rewards.checkConditional:' + reward.conditional, { left: value, right: reward.value }, function (err, bool) { callback(err || bool); }); }); @@ -113,7 +113,7 @@ function giveRewards(uid, rewards, callback) { } async.each(rewards, function (reward, next) { - plugins.fireHook('action:rewards.award:' + reward.rid, {uid: uid, reward: rewardData[rewards.indexOf(reward)]}); + plugins.fireHook('action:rewards.award:' + reward.rid, { uid: uid, reward: rewardData[rewards.indexOf(reward)] }); db.sortedSetIncrBy('uid:' + uid + ':rewards', 1, reward.id, next); }, callback); }); diff --git a/src/routes/authentication.js b/src/routes/authentication.js index 6a3e5ef197..0e1d2aa6e2 100644 --- a/src/routes/authentication.js +++ b/src/routes/authentication.js @@ -40,7 +40,7 @@ winston.warn('[authentication] Login override detected, skipping local login strategy.'); plugins.fireHook('action:auth.overrideLogin'); } else { - passport.use(new passportLocal({passReqToCallback: true}, controllers.authentication.localLogin)); + passport.use(new passportLocal({ passReqToCallback: true }, controllers.authentication.localLogin)); } plugins.fireHook('filter:auth.init', loginStrategies, function (err) { diff --git a/src/search.js b/src/search.js index 82886a1d18..15ebb88184 100644 --- a/src/search.js +++ b/src/search.js @@ -76,7 +76,7 @@ function searchInContent(data, callback) { var matchCount = 0; if (!results || (!results.pids.length && !results.tids.length)) { - return callback(null, {posts: [], matchCount: matchCount, pageCount: 1}); + return callback(null, { posts: [], matchCount: matchCount, pageCount: 1 }); } async.waterfall([ @@ -105,7 +105,7 @@ function searchInContent(data, callback) { posts.getPostSummaryByPids(pids, data.uid, {}, next); }, function (posts, next) { - next(null, {posts: posts, matchCount: matchCount, pageCount: Math.max(1, Math.ceil(parseInt(matchCount, 10) / 10))}); + next(null, { posts: posts, matchCount: matchCount, pageCount: Math.max(1, Math.ceil(parseInt(matchCount, 10) / 10)) }); }, ], callback); }); diff --git a/src/sitemap.js b/src/sitemap.js index dbd881a067..d6f6fa39fe 100644 --- a/src/sitemap.js +++ b/src/sitemap.js @@ -72,7 +72,7 @@ sitemap.getPages = function (callback) { priority: 0.4, }]; - plugins.fireHook('filter:sitemap.getPages', {urls: urls}, function (err, data) { + plugins.fireHook('filter:sitemap.getPages', { urls: urls }, function (err, data) { if (err) { return callback(err); } diff --git a/src/socket.io/admin.js b/src/socket.io/admin.js index 0658d48a34..0e7c277dfd 100644 --- a/src/socket.io/admin.js +++ b/src/socket.io/admin.js @@ -169,7 +169,7 @@ SocketAdmin.config.setMultiple = function (socket, data, callback) { value: data[field], }; plugins.fireHook('action:config.set', setting); - logger.monitorConfig({io: index.server}, setting); + logger.monitorConfig({ io: index.server }, setting); } } setImmediate(next); diff --git a/src/socket.io/admin/categories.js b/src/socket.io/admin/categories.js index 3f81d2a5a7..50c2061038 100644 --- a/src/socket.io/admin/categories.js +++ b/src/socket.io/admin/categories.js @@ -23,7 +23,7 @@ Categories.getAll = function (socket, data, callback) { async.apply(categories.getCategoriesData), function (categories, next) { // Hook changes, there is no req, and res - plugins.fireHook('filter:admin.categories.get', {categories: categories}, next); + plugins.fireHook('filter:admin.categories.get', { categories: categories }, next); }, function (result, next) { next(null, categories.getTree(result.categories, 0)); diff --git a/src/socket.io/admin/rooms.js b/src/socket.io/admin/rooms.js index 96144fbeaf..544bdc04da 100644 --- a/src/socket.io/admin/rooms.js +++ b/src/socket.io/admin/rooms.js @@ -22,7 +22,7 @@ pubsub.on('sync:stats:start', function () { if (err) { return winston.error(err); } - pubsub.publish('sync:stats:end', {stats: stats, id: os.hostname() + ':' + nconf.get('port')}); + pubsub.publish('sync:stats:end', { stats: stats, id: os.hostname() + ':' + nconf.get('port') }); }); }); @@ -81,7 +81,7 @@ SocketRooms.getAll = function (socket, data, callback) { totals.users.category += stats[instance].users.category; stats[instance].topics.forEach(function (topic) { - totals.topics[topic.tid] = totals.topics[topic.tid] || {count: 0, tid: topic.tid}; + totals.topics[topic.tid] = totals.topics[topic.tid] || { count: 0, tid: topic.tid }; totals.topics[topic.tid].count += topic.count; }); } @@ -89,7 +89,7 @@ SocketRooms.getAll = function (socket, data, callback) { var topTenTopics = []; Object.keys(totals.topics).forEach(function (tid) { - topTenTopics.push({tid: tid, count: totals.topics[tid].count}); + topTenTopics.push({ tid: tid, count: totals.topics[tid].count }); }); topTenTopics = topTenTopics.sort(function (a, b) { @@ -165,7 +165,7 @@ SocketRooms.getLocalStats = function (callback) { tid = room.match(/^topic_(\d+)/); if (tid) { socketData.users.topics += roomClients[room].length; - topTenTopics.push({tid: tid[1], count: roomClients[room].length}); + topTenTopics.push({ tid: tid[1], count: roomClients[room].length }); } else if (room.match(/^category/)) { socketData.users.category += roomClients[room].length; } diff --git a/src/socket.io/admin/user.js b/src/socket.io/admin/user.js index aca1bff8a8..8770381aae 100644 --- a/src/socket.io/admin/user.js +++ b/src/socket.io/admin/user.js @@ -196,7 +196,7 @@ User.search = function (socket, data, callback) { var searchData; async.waterfall([ function (next) { - user.search({query: data.query, searchBy: data.searchBy, uid: socket.uid}, next); + user.search({ query: data.query, searchBy: data.searchBy, uid: socket.uid }, next); }, function (_searchData, next) { searchData = _searchData; diff --git a/src/socket.io/groups.js b/src/socket.io/groups.js index 3b27b7fdc2..16240a506b 100644 --- a/src/socket.io/groups.js +++ b/src/socket.io/groups.js @@ -265,7 +265,7 @@ SocketGroups.loadMoreMembers = function (socket, data, callback) { return callback(err); } - callback(null, {users: users, nextStart: data.after + 10}); + callback(null, { users: users, nextStart: data.after + 10 }); }); }; diff --git a/src/socket.io/helpers.js b/src/socket.io/helpers.js index 27aeef6392..ce2ee7b30c 100644 --- a/src/socket.io/helpers.js +++ b/src/socket.io/helpers.js @@ -32,7 +32,7 @@ SocketHelpers.notifyNew = function (uid, type, result) { filterTidCidIgnorers(uids, result.posts[0].topic.tid, result.posts[0].topic.cid, next); }, function (uids, next) { - plugins.fireHook('filter:sockets.sendNewPostToUids', {uidsTo: uids, uidFrom: uid, type: type}, next); + plugins.fireHook('filter:sockets.sendNewPostToUids', { uidsTo: uids, uidFrom: uid, type: type }, next); }, ], function (err, data) { if (err) { diff --git a/src/socket.io/index.js b/src/socket.io/index.js index fcce4ecc69..21edc91453 100644 --- a/src/socket.io/index.js +++ b/src/socket.io/index.js @@ -92,7 +92,7 @@ function onMessage(socket, payload) { if (process.env.NODE_ENV === 'development') { winston.warn('[socket.io] Unrecognized message: ' + eventName); } - return callback({message: '[[error:invalid-event]]'}); + return callback({ message: '[[error:invalid-event]]' }); } socket.previousEvents = socket.previousEvents || []; @@ -124,7 +124,7 @@ function onMessage(socket, payload) { methodToCall(socket, params, next); }, ], function (err, result) { - callback(err ? {message: err.message} : null, result); + callback(err ? { message: err.message } : null, result); }); } @@ -198,7 +198,7 @@ function addRedisAdapter(io) { var redis = require('../database/redis'); var pub = redis.connect(); var sub = redis.connect(); - io.adapter(redisAdapter({pubClient: pub, subClient: sub})); + io.adapter(redisAdapter({ pubClient: pub, subClient: sub })); } else if (nconf.get('isCluster') === 'true') { winston.warn('[socket.io] Clustering detected, you are advised to configure Redis as a websocket store.'); } diff --git a/src/socket.io/modules.js b/src/socket.io/modules.js index 64f8fd0a5a..bd4c7febc2 100644 --- a/src/socket.io/modules.js +++ b/src/socket.io/modules.js @@ -254,7 +254,7 @@ SocketModules.chats.markRead = function (socket, roomId, callback) { } Messaging.pushUnreadCount(socket.uid); - server.in('uid_' + socket.uid).emit('event:chats.markedAsRead', {roomId: roomId}); + server.in('uid_' + socket.uid).emit('event:chats.markedAsRead', { roomId: roomId }); if (results.uidsInRoom.indexOf(socket.uid.toString()) === -1) { return callback(); @@ -300,7 +300,7 @@ SocketModules.chats.renameRoom = function (socket, data, callback) { Messaging.getUidsInRoom(data.roomId, 0, -1, next); }, function (uids, next) { - var eventData = {roomId: data.roomId, newName: validator.escape(String(data.newName))}; + var eventData = { roomId: data.roomId, newName: validator.escape(String(data.newName)) }; uids.forEach(function (uid) { server.in('uid_' + uid).emit('event:chats.roomRename', eventData); }); diff --git a/src/socket.io/notifications.js b/src/socket.io/notifications.js index 6ab97c5dc8..66e5135ed6 100644 --- a/src/socket.io/notifications.js +++ b/src/socket.io/notifications.js @@ -29,7 +29,7 @@ SocketNotifs.loadMore = function (socket, data, callback) { user.notifications.getAll(socket.uid, start, stop, next); }, function (notifications, next) { - next(null, {notifications: notifications, nextStart: stop}); + next(null, { notifications: notifications, nextStart: stop }); }, ], callback); }; diff --git a/src/socket.io/posts/flag.js b/src/socket.io/posts/flag.js index e5a89e778f..dccf302c43 100644 --- a/src/socket.io/posts/flag.js +++ b/src/socket.io/posts/flag.js @@ -99,7 +99,7 @@ module.exports = function (SocketPosts) { return next(err); } - plugins.fireHook('action:post.flag', {post: post, reason: data.reason, flaggingUser: flaggingUser}); + plugins.fireHook('action:post.flag', { post: post, reason: data.reason, flaggingUser: flaggingUser }); notifications.push(notification, results.admins.concat(results.moderators).concat(results.globalMods), next); }); }, diff --git a/src/socket.io/posts/helpers.js b/src/socket.io/posts/helpers.js index 7db1a8b5ae..c7b92488d5 100644 --- a/src/socket.io/posts/helpers.js +++ b/src/socket.io/posts/helpers.js @@ -46,7 +46,7 @@ helpers.postCommand = function (socket, command, eventName, notification, data, filter:post.bookmark filter:post.unbookmark */ - plugins.fireHook('filter:post.' + command, {data: data, uid: socket.uid}, next); + plugins.fireHook('filter:post.' + command, { data: data, uid: socket.uid }, next); }, function (filteredData, next) { executeCommand(socket, command, eventName, notification, filteredData.data, next); diff --git a/src/socket.io/posts/tools.js b/src/socket.io/posts/tools.js index d759a5c249..ee393a42b9 100644 --- a/src/socket.io/posts/tools.js +++ b/src/socket.io/posts/tools.js @@ -36,7 +36,7 @@ module.exports = function (SocketPosts) { posts.hasBookmarked(data.pid, socket.uid, next); }, tools: function (next) { - plugins.fireHook('filter:post.tools', {pid: data.pid, uid: socket.uid, tools: []}, next); + plugins.fireHook('filter:post.tools', { pid: data.pid, uid: socket.uid, tools: [] }, next); }, postSharing: function (next) { social.getActivePostSharing(next); @@ -121,7 +121,7 @@ module.exports = function (SocketPosts) { return callback(new Error('[[error:invalid-data]]')); } async.eachSeries(data.pids, function (pid, next) { - SocketPosts.delete(socket, {pid: pid, tid: data.tid}, next); + SocketPosts.delete(socket, { pid: pid, tid: data.tid }, next); }, callback); }; @@ -130,7 +130,7 @@ module.exports = function (SocketPosts) { return callback(new Error('[[error:invalid-data]]')); } async.eachSeries(data.pids, function (pid, next) { - SocketPosts.purge(socket, {pid: pid, tid: data.tid}, next); + SocketPosts.purge(socket, { pid: pid, tid: data.tid }, next); }, callback); }; @@ -156,7 +156,7 @@ module.exports = function (SocketPosts) { posts.getPostField(data.pid, 'toPid', next); }, function (toPid, next) { - postData = {pid: data.pid, toPid: toPid}; + postData = { pid: data.pid, toPid: toPid }; posts.tools.purge(socket.uid, data.pid, next); }, function (next) { @@ -181,7 +181,7 @@ module.exports = function (SocketPosts) { posts.getTopicFields(pid, ['tid', 'cid'], next); }, function (topic, next) { - socketTopics.doTopicAction('delete', 'event:topic_deleted', socket, {tids: [topic.tid], cid: topic.cid}, next); + socketTopics.doTopicAction('delete', 'event:topic_deleted', socket, { tids: [topic.tid], cid: topic.cid }, next); }, ], callback); } diff --git a/src/socket.io/topics.js b/src/socket.io/topics.js index 2fdecf550f..358ff4223f 100644 --- a/src/socket.io/topics.js +++ b/src/socket.io/topics.js @@ -33,10 +33,10 @@ SocketTopics.post = function (socket, data, callback) { callback(null, result.topicData); - socket.emit('event:new_post', {posts: [result.postData]}); + socket.emit('event:new_post', { posts: [result.postData] }); socket.emit('event:new_topic', result.topicData); - socketHelpers.notifyNew(socket.uid, 'newTopic', {posts: [result.postData], topic: result.topicData}); + socketHelpers.notifyNew(socket.uid, 'newTopic', { posts: [result.postData], topic: result.topicData }); }); }; diff --git a/src/socket.io/topics/tags.js b/src/socket.io/topics/tags.js index 4ef579babb..0b7076fa20 100644 --- a/src/socket.io/topics/tags.js +++ b/src/socket.io/topics/tags.js @@ -48,7 +48,7 @@ module.exports = function (SocketTopics) { }, function (tags, next) { tags = tags.filter(Boolean); - next(null, {tags: tags, nextStart: stop + 1}); + next(null, { tags: tags, nextStart: stop + 1 }); }, ], callback); }; diff --git a/src/socket.io/topics/tools.js b/src/socket.io/topics/tools.js index 8df029c926..74cdb68e7e 100644 --- a/src/socket.io/topics/tools.js +++ b/src/socket.io/topics/tools.js @@ -32,7 +32,7 @@ module.exports = function (SocketTopics) { function (results, next) { topic = results.topic; topic.privileges = results.privileges; - plugins.fireHook('filter:topic.thread_tools', {topic: results.topic, uid: socket.uid, tools: []}, next); + plugins.fireHook('filter:topic.thread_tools', { topic: results.topic, uid: socket.uid, tools: [] }, next); }, function (data, next) { topic.deleted = parseInt(topic.deleted, 10) === 1; diff --git a/src/socket.io/user.js b/src/socket.io/user.js index 533d6e64fd..bef5eb9d77 100644 --- a/src/socket.io/user.js +++ b/src/socket.io/user.js @@ -46,7 +46,7 @@ SocketUser.deleteAccount = function (socket, data, callback) { user.deleteAccount(socket.uid, next); }, function (next) { - require('./index').server.sockets.emit('event:user_status_change', {uid: socket.uid, status: 'offline'}); + require('./index').server.sockets.emit('event:user_status_change', { uid: socket.uid, status: 'offline' }); events.log({ type: 'user-delete', diff --git a/src/socket.io/user/profile.js b/src/socket.io/user/profile.js index e2d4de9ce1..8e88edb1e5 100644 --- a/src/socket.io/user/profile.js +++ b/src/socket.io/user/profile.js @@ -174,11 +174,11 @@ module.exports = function (SocketUser) { } if (userData.email !== oldUserData.email) { - log('email-change', {oldEmail: oldUserData.email, newEmail: userData.email}); + log('email-change', { oldEmail: oldUserData.email, newEmail: userData.email }); } if (userData.username !== oldUserData.username) { - log('username-change', {oldUsername: oldUserData.username, newUsername: userData.username}); + log('username-change', { oldUsername: oldUserData.username, newUsername: userData.username }); } next(null, userData); diff --git a/src/socket.io/user/status.js b/src/socket.io/user/status.js index 562a57d82c..8849f0210e 100644 --- a/src/socket.io/user/status.js +++ b/src/socket.io/user/status.js @@ -30,7 +30,7 @@ module.exports = function (SocketUser) { return callback(new Error('[[error:invalid-user-status]]')); } - var data = {status: status}; + var data = { status: status }; if (status !== 'offline') { data.lastonline = Date.now(); } diff --git a/src/topics.js b/src/topics.js index 0972988bfa..0eba6545fd 100644 --- a/src/topics.js +++ b/src/topics.js @@ -67,7 +67,7 @@ var social = require('./social'); Topics.getTopics(tids, uid, next); }, function (topics, next) { - next(null, {topics: topics, nextStart: stop + 1}); + next(null, { topics: topics, nextStart: stop + 1 }); }, ], callback); }; @@ -161,7 +161,7 @@ var social = require('./social'); return topic && topic.category && !topic.category.disabled; }); - plugins.fireHook('filter:topics.get', {topics: topics, uid: uid}, next); + plugins.fireHook('filter:topics.get', { topics: topics, uid: uid }, next); }, function (data, next) { next(null, data.topics); @@ -175,7 +175,7 @@ var social = require('./social'); async.parallel({ posts: async.apply(getMainPostAndReplies, topicData, set, uid, start, stop, reverse), category: async.apply(Topics.getCategoryData, topicData.tid), - threadTools: async.apply(plugins.fireHook, 'filter:topic.thread_tools', {topic: topicData, uid: uid, tools: []}), + threadTools: async.apply(plugins.fireHook, 'filter:topic.thread_tools', { topic: topicData, uid: uid, tools: [] }), isFollowing: async.apply(Topics.isFollowing, [topicData.tid], uid), isIgnoring: async.apply(Topics.isIgnoring, [topicData.tid], uid), bookmark: async.apply(Topics.getUserBookmark, topicData.tid, uid), @@ -211,7 +211,7 @@ var social = require('./social'); topicData.icons = []; - plugins.fireHook('filter:topic.get', {topic: topicData, uid: uid}, next); + plugins.fireHook('filter:topic.get', { topic: topicData, uid: uid }, next); }, function (data, next) { next(null, data.topic); diff --git a/src/topics/bookmarks.js b/src/topics/bookmarks.js index 487d3fd29e..b47d5f2278 100644 --- a/src/topics/bookmarks.js +++ b/src/topics/bookmarks.js @@ -43,7 +43,7 @@ module.exports = function (Topics) { }, function (bookmarks, next) { var forkedPosts = pids.map(function (pid) { - return {pid: pid, tid: tid}; + return { pid: pid, tid: tid }; }); var uidData = bookmarks.map(function (bookmark) { diff --git a/src/topics/create.js b/src/topics/create.js index 2b4f022f57..815d703d01 100644 --- a/src/topics/create.js +++ b/src/topics/create.js @@ -48,7 +48,7 @@ module.exports = function (Topics) { topicData.thumb = data.thumb; } - plugins.fireHook('filter:topic.create', {topic: topicData, data: data}, next); + plugins.fireHook('filter:topic.create', { topic: topicData, data: data }, next); }, function (data, next) { topicData = data.topic; diff --git a/src/topics/delete.js b/src/topics/delete.js index dbf8474ecb..7fdd0bc1a7 100644 --- a/src/topics/delete.js +++ b/src/topics/delete.js @@ -97,7 +97,7 @@ module.exports = function (Topics) { async.eachLimit(pids, 10, function (pid, next) { posts.purge(pid, uid, next); }, next); - }, {alwaysStartAt: 0}, next); + }, { alwaysStartAt: 0 }, next); }, function (next) { posts.purge(mainPid, uid, next); diff --git a/src/topics/follow.js b/src/topics/follow.js index 48742797b8..a3b1041b13 100644 --- a/src/topics/follow.js +++ b/src/topics/follow.js @@ -74,7 +74,7 @@ module.exports = function (Topics) { method2(tid, uid, next); }, function (next) { - plugins.fireHook(hook, {uid: uid, tid: tid}); + plugins.fireHook(hook, { uid: uid, tid: tid }); next(); }, ], callback); diff --git a/src/topics/fork.js b/src/topics/fork.js index 6a9965b51c..4765727d6f 100644 --- a/src/topics/fork.js +++ b/src/topics/fork.js @@ -52,7 +52,7 @@ module.exports = function (Topics) { if (!results.isAdminOrMod) { return next(new Error('[[error:no-privileges]]')); } - Topics.create({uid: results.postData.uid, title: title, cid: cid}, next); + Topics.create({ uid: results.postData.uid, title: title, cid: cid }, next); }, function (results, next) { Topics.updateTopicBookmarks(fromTid, pids, function () { next(null, results); }); @@ -134,7 +134,7 @@ module.exports = function (Topics) { if (err) { return callback(err); } - plugins.fireHook('action:post.move', {post: postData, tid: tid}); + plugins.fireHook('action:post.move', { post: postData, tid: tid }); callback(); }); }; diff --git a/src/topics/posts.js b/src/topics/posts.js index e013eaf7b0..65c180d784 100644 --- a/src/topics/posts.js +++ b/src/topics/posts.js @@ -185,7 +185,7 @@ module.exports = function (Topics) { }); var parents = {}; parentPosts.forEach(function (post, i) { - parents[parentPids[i]] = {username: usersMap[post.uid]}; + parents[parentPids[i]] = { username: usersMap[post.uid] }; }); postData.forEach(function (post) { diff --git a/src/topics/recent.js b/src/topics/recent.js index 3d4f298369..eb2aebec66 100644 --- a/src/topics/recent.js +++ b/src/topics/recent.js @@ -100,7 +100,7 @@ module.exports = function (Topics) { Topics.getTopics(tids, uid, next); }, function (topics, next) { - next(null, {topics: topics, nextStart: stop + 1}); + next(null, { topics: topics, nextStart: stop + 1 }); }, ], callback); }; @@ -142,7 +142,7 @@ module.exports = function (Topics) { Topics.updateRecent = function (tid, timestamp, callback) { callback = callback || function () {}; if (plugins.hasListeners('filter:topics.updateRecent')) { - plugins.fireHook('filter:topics.updateRecent', {tid: tid, timestamp: timestamp}, function (err, data) { + plugins.fireHook('filter:topics.updateRecent', { tid: tid, timestamp: timestamp }, function (err, data) { if (err) { return callback(err); } diff --git a/src/topics/tags.js b/src/topics/tags.js index a82a7e4890..d10c127ac0 100644 --- a/src/topics/tags.js +++ b/src/topics/tags.js @@ -20,7 +20,7 @@ module.exports = function (Topics) { async.waterfall([ function (next) { - plugins.fireHook('filter:tags.filter', {tags: tags, tid: tid}, next); + plugins.fireHook('filter:tags.filter', { tags: tags, tid: tid }, next); }, function (data, next) { tags = data.tags.slice(0, meta.config.maximumTagsPerTopic || 5); @@ -230,7 +230,7 @@ module.exports = function (Topics) { uniqueTopicTags = _.uniq(_.flatten(topicTags)); var tags = uniqueTopicTags.map(function (tag) { - return {value: tag}; + return { value: tag }; }); async.parallel({ @@ -312,13 +312,13 @@ module.exports = function (Topics) { async.waterfall([ function (next) { if (plugins.hasListeners('filter:topics.searchTags')) { - plugins.fireHook('filter:topics.searchTags', {data: data}, next); + plugins.fireHook('filter:topics.searchTags', { data: data }, next); } else { findMatches(data.query, 0, next); } }, function (result, next) { - plugins.fireHook('filter:tags.search', {data: data, matches: result.matches}, next); + plugins.fireHook('filter:tags.search', { data: data, matches: result.matches }, next); }, function (result, next) { next(null, result.matches); @@ -334,7 +334,7 @@ module.exports = function (Topics) { async.waterfall([ function (next) { if (plugins.hasListeners('filter:topics.autocompleteTags')) { - plugins.fireHook('filter:topics.autocompleteTags', {data: data}, next); + plugins.fireHook('filter:topics.autocompleteTags', { data: data }, next); } else { findMatches(data.query, data.cid, next); } @@ -377,7 +377,7 @@ module.exports = function (Topics) { matches = matches.sort(function (a, b) { return a > b; }); - next(null, {matches: matches}); + next(null, { matches: matches }); }, ], callback); } @@ -403,7 +403,7 @@ module.exports = function (Topics) { }, tagData: function (next) { tags = tags.map(function (tag) { - return {value: tag}; + return { value: tag }; }); Topics.getTagData(tags, next); @@ -427,7 +427,7 @@ module.exports = function (Topics) { Topics.getRelatedTopics = function (topicData, uid, callback) { if (plugins.hasListeners('filter:topic.getRelatedTopics')) { - return plugins.fireHook('filter:topic.getRelatedTopics', {topic: topicData, uid: uid}, callback); + return plugins.fireHook('filter:topic.getRelatedTopics', { topic: topicData, uid: uid }, callback); } var maximumTopics = parseInt(meta.config.maximumRelatedTopics, 10) || 0; diff --git a/src/topics/teaser.js b/src/topics/teaser.js index 9264b4b254..aa64d7780f 100644 --- a/src/topics/teaser.js +++ b/src/topics/teaser.js @@ -94,7 +94,7 @@ module.exports = function (Topics) { return tidToPost[topic.tid]; }); - plugins.fireHook('filter:teasers.get', {teasers: teasers}, next); + plugins.fireHook('filter:teasers.get', { teasers: teasers }, next); }, function (data, next) { next(null, data.teasers); diff --git a/src/topics/thumb.js b/src/topics/thumb.js index 8735dcc7c4..574ca302ad 100644 --- a/src/topics/thumb.js +++ b/src/topics/thumb.js @@ -61,7 +61,7 @@ module.exports = function (Topics) { return callback(); } - plugins.fireHook('filter:uploadImage', {image: {path: pathToUpload, name: ''}, uid: data.uid}, next); + plugins.fireHook('filter:uploadImage', { image: { path: pathToUpload, name: '' }, uid: data.uid }, next); }, function (uploadedFile, next) { deleteFile(pathToUpload); diff --git a/src/topics/tools.js b/src/topics/tools.js index 396c4b9b3e..f83a5f91f0 100644 --- a/src/topics/tools.js +++ b/src/topics/tools.js @@ -97,7 +97,7 @@ module.exports = function (Topics) { Topics.purgePostsAndTopic(tid, uid, next); }, function (next) { - next(null, {tid: tid, cid: cid, uid: uid}); + next(null, { tid: tid, cid: cid, uid: uid }); }, ], callback); }; diff --git a/src/user.js b/src/user.js index 17d0a59585..968417f816 100644 --- a/src/user.js +++ b/src/user.js @@ -63,7 +63,7 @@ var meta = require('./meta'); }, function (next) { topics.pushUnreadCount(uid); - plugins.fireHook('action:user.online', {uid: uid, timestamp: now}); + plugins.fireHook('action:user.online', { uid: uid, timestamp: now }); next(); }, ], callback); @@ -93,7 +93,7 @@ var meta = require('./meta'); User.getUsersWithFields = function (uids, fields, uid, callback) { async.waterfall([ function (next) { - plugins.fireHook('filter:users.addFields', {fields: fields}, next); + plugins.fireHook('filter:users.addFields', { fields: fields }, next); }, function (data, next) { data.fields = data.fields.filter(function (field, index, array) { @@ -120,7 +120,7 @@ var meta = require('./meta'); user['email:confirmed'] = parseInt(user['email:confirmed'], 10) === 1; } }); - plugins.fireHook('filter:userlist.get', {users: results.userData, uid: uid}, next); + plugins.fireHook('filter:userlist.get', { users: results.userData, uid: uid }, next); }, function (data, next) { next(null, data.users); diff --git a/src/user/admin.js b/src/user/admin.js index 39a12a9c0a..7ef6c0dda7 100644 --- a/src/user/admin.js +++ b/src/user/admin.js @@ -38,7 +38,7 @@ module.exports = function (User) { uids = users.map(function (user) { return user.score; }); - plugins.fireHook('filter:user.csvFields', {fields: ['uid', 'email', 'username']}, next); + plugins.fireHook('filter:user.csvFields', { fields: ['uid', 'email', 'username'] }, next); }, function (data, next) { User.getUsersFields(uids, data.fields, next); diff --git a/src/user/approval.js b/src/user/approval.js index 33a3d0ab8a..cbb1ba08b4 100644 --- a/src/user/approval.js +++ b/src/user/approval.js @@ -30,7 +30,7 @@ module.exports = function (User) { ip: userData.ip, hashedPassword: hashedPassword, }; - plugins.fireHook('filter:user.addToApprovalQueue', {data: data, userData: userData}, next); + plugins.fireHook('filter:user.addToApprovalQueue', { data: data, userData: userData }, next); }, function (results, next) { db.setObject('registration:queue:name:' + userData.username, results.data, next); @@ -211,7 +211,7 @@ module.exports = function (User) { }, next); }, function (users, next) { - plugins.fireHook('filter:user.getRegistrationQueue', {users: users}, next); + plugins.fireHook('filter:user.getRegistrationQueue', { users: users }, next); }, function (results, next) { next(null, results.users); diff --git a/src/user/auth.js b/src/user/auth.js index a59e68b43f..29a79f39c4 100644 --- a/src/user/auth.js +++ b/src/user/auth.js @@ -172,6 +172,6 @@ module.exports = function (User) { ], next); }, ], next); - }, {batch: 1000}, callback); + }, { batch: 1000 }, callback); }; }; diff --git a/src/user/bans.js b/src/user/bans.js index 964a70669d..e98380a573 100644 --- a/src/user/bans.js +++ b/src/user/bans.js @@ -49,7 +49,7 @@ module.exports = function (User) { User.unban = function (uid, callback) { async.waterfall([ function (next) { - User.setUserFields(uid, {banned: 0, 'banned:expire': 0}, next); + User.setUserFields(uid, { banned: 0, 'banned:expire': 0 }, next); }, function (next) { db.sortedSetsRemove(['users:banned', 'users:banned:expire'], uid, next); @@ -75,7 +75,7 @@ module.exports = function (User) { async.parallel([ async.apply(db.sortedSetRemove.bind(db), 'users:banned:expire', uid), async.apply(db.sortedSetRemove.bind(db), 'users:banned', uid), - async.apply(User.setUserFields, uid, {banned: 0, 'banned:expire': 0}), + async.apply(User.setUserFields, uid, { banned: 0, 'banned:expire': 0 }), ], function (err) { next(err, false); }); diff --git a/src/user/create.js b/src/user/create.js index 20af1dd20a..2620cb67d3 100644 --- a/src/user/create.js +++ b/src/user/create.js @@ -49,7 +49,7 @@ module.exports = function (User) { renameUsername(userData, next); }, userData: function (next) { - plugins.fireHook('filter:user.create', {user: userData, data: data}, next); + plugins.fireHook('filter:user.create', { user: userData, data: data }, next); }, }, function (err, results) { if (err) { diff --git a/src/user/data.js b/src/user/data.js index 5812180df5..3a7ee731aa 100644 --- a/src/user/data.js +++ b/src/user/data.js @@ -155,7 +155,7 @@ module.exports = function (User) { if (err) { return callback(err); } - plugins.fireHook('action:user.set', {uid: uid, field: field, value: value, type: 'set'}); + plugins.fireHook('action:user.set', { uid: uid, field: field, value: value, type: 'set' }); callback(); }); }; @@ -168,7 +168,7 @@ module.exports = function (User) { } for (var field in data) { if (data.hasOwnProperty(field)) { - plugins.fireHook('action:user.set', {uid: uid, field: field, value: data[field], type: 'set'}); + plugins.fireHook('action:user.set', { uid: uid, field: field, value: data[field], type: 'set' }); } } callback(); @@ -181,7 +181,7 @@ module.exports = function (User) { if (err) { return callback(err); } - plugins.fireHook('action:user.set', {uid: uid, field: field, value: value, type: 'increment'}); + plugins.fireHook('action:user.set', { uid: uid, field: field, value: value, type: 'increment' }); callback(null, value); }); @@ -193,7 +193,7 @@ module.exports = function (User) { if (err) { return callback(err); } - plugins.fireHook('action:user.set', {uid: uid, field: field, value: value, type: 'decrement'}); + plugins.fireHook('action:user.set', { uid: uid, field: field, value: value, type: 'decrement' }); callback(null, value); }); diff --git a/src/user/delete.js b/src/user/delete.js index 28b8a4989e..7392192c8b 100644 --- a/src/user/delete.js +++ b/src/user/delete.js @@ -33,7 +33,7 @@ module.exports = function (User) { async.eachSeries(ids, function (pid, next) { posts.purge(pid, callerUid, next); }, next); - }, {alwaysStartAt: 0}, callback); + }, { alwaysStartAt: 0 }, callback); } function deleteTopics(callerUid, uid, callback) { @@ -41,7 +41,7 @@ module.exports = function (User) { async.eachSeries(ids, function (tid, next) { topics.purge(tid, callerUid, next); }, next); - }, {alwaysStartAt: 0}, callback); + }, { alwaysStartAt: 0 }, callback); } User.deleteAccount = function (uid, callback) { @@ -58,7 +58,7 @@ module.exports = function (User) { }, function (_userData, next) { userData = _userData; - plugins.fireHook('static:user.delete', {uid: uid}, next); + plugins.fireHook('static:user.delete', { uid: uid }, next); }, function (next) { deleteVotes(uid, next); diff --git a/src/user/email.js b/src/user/email.js index 5e124551bd..f75ff9cf9b 100644 --- a/src/user/email.js +++ b/src/user/email.js @@ -76,7 +76,7 @@ var emailer = require('../emailer'); }; if (plugins.hasListeners('action:user.verify')) { - plugins.fireHook('action:user.verify', {uid: uid, data: data}); + plugins.fireHook('action:user.verify', { uid: uid, data: data }); next(); } else { emailer.send('welcome', uid, data, next); @@ -101,7 +101,7 @@ var emailer = require('../emailer'); db.sortedSetRemove('users:notvalidated', confirmObj.uid, next); }, function (next) { - plugins.fireHook('action:user.email.confirmed', {uid: confirmObj.uid, email: confirmObj.email}, next); + plugins.fireHook('action:user.email.confirmed', { uid: confirmObj.uid, email: confirmObj.email }, next); }, ], function (err) { callback(err ? new Error('[[error:email-confirm-failed]]') : null); diff --git a/src/user/notifications.js b/src/user/notifications.js index 93f9d2e124..f830092b07 100644 --- a/src/user/notifications.js +++ b/src/user/notifications.js @@ -13,7 +13,7 @@ var privileges = require('../privileges'); (function (UserNotifications) { UserNotifications.get = function (uid, callback) { if (!parseInt(uid, 10)) { - return callback(null, {read: [], unread: []}); + return callback(null, { read: [], unread: [] }); } getNotifications(uid, 0, 9, function (err, notifications) { if (err) { diff --git a/src/user/picture.js b/src/user/picture.js index 08b548e444..32d91d6877 100644 --- a/src/user/picture.js +++ b/src/user/picture.js @@ -41,7 +41,7 @@ module.exports = function (User) { async.waterfall([ function (next) { if (plugins.hasListeners('filter:uploadImage')) { - return plugins.fireHook('filter:uploadImage', {image: picture, uid: updateUid}, next); + return plugins.fireHook('filter:uploadImage', { image: picture, uid: updateUid }, next); } var filename = updateUid + '-profileimg' + (keepAllVersions ? '-' + Date.now() : '') + (convertToPNG ? '.png' : extension); @@ -77,7 +77,7 @@ module.exports = function (User) { }, function (_image, next) { uploadedImage = _image; - User.setUserFields(updateUid, {uploadedpicture: uploadedImage.url, picture: uploadedImage.url}, next); + User.setUserFields(updateUid, { uploadedpicture: uploadedImage.url, picture: uploadedImage.url }, next); }, function (next) { next(null, uploadedImage); @@ -107,12 +107,12 @@ module.exports = function (User) { return callback(new Error('[[error:file-too-big, ' + uploadSize + ']]')); } - var picture = {url: url, name: ''}; - plugins.fireHook('filter:uploadImage', {image: picture, uid: uid}, function (err, image) { + var picture = { url: url, name: '' }; + plugins.fireHook('filter:uploadImage', { image: picture, uid: uid }, function (err, image) { if (err) { return callback(err); } - User.setUserFields(uid, {uploadedpicture: image.url, picture: image.url}); + User.setUserFields(uid, { uploadedpicture: image.url, picture: image.url }); callback(null, image); }); }); @@ -169,7 +169,7 @@ module.exports = function (User) { }; if (plugins.hasListeners('filter:uploadImage')) { - return plugins.fireHook('filter:uploadImage', {image: image, uid: data.uid}, next); + return plugins.fireHook('filter:uploadImage', { image: image, uid: data.uid }, next); } var filename = data.uid + '-profilecover' + (keepAllVersions ? '-' + Date.now() : ''); @@ -213,10 +213,10 @@ module.exports = function (User) { if (data.position) { User.updateCoverPosition(data.uid, data.position, function (err) { - callback(err, {url: url}); + callback(err, { url: url }); }); } else { - callback(err, {url: url}); + callback(err, { url: url }); } }); }; @@ -260,7 +260,7 @@ module.exports = function (User) { }; if (plugins.hasListeners('filter:uploadImage')) { - return plugins.fireHook('filter:uploadImage', {image: image, uid: data.uid}, next); + return plugins.fireHook('filter:uploadImage', { image: image, uid: data.uid }, next); } var filename = data.uid + '-profileavatar' + (keepAllVersions ? '-' + Date.now() : ''); @@ -281,7 +281,7 @@ module.exports = function (User) { }, function (uploadData, next) { url = uploadData.url; - User.setUserFields(data.uid, {uploadedpicture: url, picture: url}, next); + User.setUserFields(data.uid, { uploadedpicture: url, picture: url }, next); }, function (next) { fs.unlink(data.file.path, function (err) { @@ -296,7 +296,7 @@ module.exports = function (User) { callback(err); // send back the original error } - callback(err, {url: url}); + callback(err, { url: url }); }); }; diff --git a/src/user/profile.js b/src/user/profile.js index ea813db035..b0d40cf02d 100644 --- a/src/user/profile.js +++ b/src/user/profile.js @@ -17,7 +17,7 @@ module.exports = function (User) { async.waterfall([ function (next) { - plugins.fireHook('filter:user.updateProfile', {uid: uid, data: data, fields: fields}, next); + plugins.fireHook('filter:user.updateProfile', { uid: uid, data: data, fields: fields }, next); }, function (data, next) { fields = data.fields; @@ -55,7 +55,7 @@ module.exports = function (User) { }, next); }, function (next) { - plugins.fireHook('action:user.updateProfile', {data: data, uid: uid}); + plugins.fireHook('action:user.updateProfile', { data: data, uid: uid }); User.getUserFields(uid, ['email', 'username', 'userslug', 'picture', 'icon:text', 'icon:bgColor'], next); }, ], callback); diff --git a/src/user/search.js b/src/user/search.js index 751bb04cf2..4583e0e28f 100644 --- a/src/user/search.js +++ b/src/user/search.js @@ -33,7 +33,7 @@ module.exports = function (User) { filterAndSortUids(uids, data, next); }, function (uids, next) { - plugins.fireHook('filter:users.search', {uids: uids, uid: uid}, next); + plugins.fireHook('filter:users.search', { uids: uids, uid: uid }, next); }, function (data, next) { var uids = data.uids; @@ -156,7 +156,7 @@ module.exports = function (User) { function (users, next) { var diff = process.hrtime(start); var timing = ((diff[0] * 1e3) + (diff[1] / 1e6)).toFixed(1); - next(null, {timing: timing, users: users}); + next(null, { timing: timing, users: users }); }, ], callback); } diff --git a/src/user/settings.js b/src/user/settings.js index 46eb7ada3f..115d0d92ad 100644 --- a/src/user/settings.js +++ b/src/user/settings.js @@ -47,7 +47,7 @@ module.exports = function (User) { }; function onSettingsLoaded(uid, settings, callback) { - plugins.fireHook('filter:user.getSettings', {uid: uid, settings: settings}, function (err, data) { + plugins.fireHook('filter:user.getSettings', { uid: uid, settings: settings }, function (err, data) { if (err) { return callback(err); } @@ -101,7 +101,7 @@ module.exports = function (User) { data.userLang = data.userLang || meta.config.defaultLang; - plugins.fireHook('action:user.saveSettings', {uid: uid, settings: data}); + plugins.fireHook('action:user.saveSettings', { uid: uid, settings: data }); var settings = { showemail: data.showemail, diff --git a/src/widgets/admin.js b/src/widgets/admin.js index 68ccd3d7ec..dde3aca43d 100644 --- a/src/widgets/admin.js +++ b/src/widgets/admin.js @@ -16,8 +16,8 @@ admin.get = function (callback) { { name: 'Global Header', template: 'global', location: 'header' }, { name: 'Global Footer', template: 'global', location: 'footer' }, - { name: 'Group Page (Left)', template: 'groups/details.tpl', location: 'left'}, - { name: 'Group Page (Right)', template: 'groups/details.tpl', location: 'right'}, + { name: 'Group Page (Left)', template: 'groups/details.tpl', location: 'left' }, + { name: 'Group Page (Right)', template: 'groups/details.tpl', location: 'right' }, ]; plugins.fireHook('filter:widgets.getAreas', defaultAreas, next); diff --git a/src/widgets/index.js b/src/widgets/index.js index abe63781ef..7ea6727a1e 100644 --- a/src/widgets/index.js +++ b/src/widgets/index.js @@ -26,7 +26,7 @@ widgets.render = function (uid, area, req, res, callback) { widgetsByLocation[location] = data.global[location].concat(data[area.template][location]); if (!widgetsByLocation[location].length) { - return done(null, {location: location, widgets: []}); + return done(null, { location: location, widgets: [] }); } async.map(widgetsByLocation[location], function (widget, next) { @@ -59,14 +59,14 @@ widgets.render = function (uid, area, req, res, callback) { body: html, }); - next(null, {html: html}); + next(null, { html: html }); }); } else { - next(null, {html: html}); + next(null, { html: html }); } }); }, function (err, result) { - done(err, {location: location, widgets: result.filter(Boolean)}); + done(err, { location: location, widgets: result.filter(Boolean) }); }); }, callback); }); diff --git a/test/authentication.js b/test/authentication.js index 3c7f58f7ac..7b49f69efa 100644 --- a/test/authentication.js +++ b/test/authentication.js @@ -12,7 +12,7 @@ describe('authentication', function () { var jar = request.jar(); var regularUid; before(function (done) { - user.create({username: 'regular', password: 'regularpwd', email: 'regular@nodebb.org' }, function (err, uid) { + user.create({ username: 'regular', password: 'regularpwd', email: 'regular@nodebb.org' }, function (err, uid) { assert.ifError(err); regularUid = uid; done(); @@ -136,7 +136,7 @@ describe('authentication', function () { db.sortedSetCard('uid:' + regularUid + ':sessions', function (err, count) { assert.ifError(err); assert(count); - socketAdmin.deleteAllSessions({uid: 1}, {}, function (err) { + socketAdmin.deleteAllSessions({ uid: 1 }, {}, function (err) { assert.ifError(err); db.sortedSetCard('uid:' + regularUid + ':sessions', function (err, count) { assert.ifError(err); diff --git a/test/categories.js b/test/categories.js index b183a3accd..bdd91602de 100644 --- a/test/categories.js +++ b/test/categories.js @@ -22,10 +22,10 @@ describe('Categories', function () { groups.resetCache(); async.parallel({ posterUid: function (next) { - User.create({username: 'poster'}, next); + User.create({ username: 'poster' }, next); }, adminUid: function (next) { - User.create({username: 'admin'}, next); + User.create({ username: 'admin' }, next); }, }, function (err, results) { assert.ifError(err); @@ -166,7 +166,7 @@ describe('Categories', function () { } moveCid = results.category.cid; moveTid = results.topic.topicData.tid; - Topics.reply({uid: posterUid, content: 'test post', tid: moveTid}, function (err) { + Topics.reply({ uid: posterUid, content: 'test post', tid: moveTid }, function (err) { done(err); }); }); @@ -202,7 +202,7 @@ describe('Categories', function () { }); it('should get recent replies in category', function (done) { - socketCategories.getRecentReplies({uid: posterUid}, categoryObj.cid, function (err, data) { + socketCategories.getRecentReplies({ uid: posterUid }, categoryObj.cid, function (err, data) { assert.ifError(err); assert(Array.isArray(data)); done(); @@ -210,7 +210,7 @@ describe('Categories', function () { }); it('should get categories', function (done) { - socketCategories.get({uid: posterUid}, {}, function (err, data) { + socketCategories.get({ uid: posterUid }, {}, function (err, data) { assert.ifError(err); assert(Array.isArray(data)); done(); @@ -218,7 +218,7 @@ describe('Categories', function () { }); it('should get watched categories', function (done) { - socketCategories.getWatchedCategories({uid: posterUid}, {}, function (err, data) { + socketCategories.getWatchedCategories({ uid: posterUid }, {}, function (err, data) { assert.ifError(err); assert(Array.isArray(data)); done(); @@ -226,7 +226,7 @@ describe('Categories', function () { }); it('should load more topics', function (done) { - socketCategories.loadMore({uid: posterUid}, {cid: categoryObj.cid, after: 0, author: 'poster', tag: 'nodebb'}, function (err, data) { + socketCategories.loadMore({ uid: posterUid }, { cid: categoryObj.cid, after: 0, author: 'poster', tag: 'nodebb' }, function (err, data) { assert.ifError(err); assert(Array.isArray(data.topics)); assert.equal(data.topics[0].user.username, 'poster'); @@ -237,7 +237,7 @@ describe('Categories', function () { }); it('should load page count', function (done) { - socketCategories.getPageCount({uid: posterUid}, categoryObj.cid, function (err, pageCount) { + socketCategories.getPageCount({ uid: posterUid }, categoryObj.cid, function (err, pageCount) { assert.ifError(err); assert.equal(pageCount, 1); done(); @@ -245,7 +245,7 @@ describe('Categories', function () { }); it('should load page count', function (done) { - socketCategories.getTopicCount({uid: posterUid}, categoryObj.cid, function (err, topicCount) { + socketCategories.getTopicCount({ uid: posterUid }, categoryObj.cid, function (err, topicCount) { assert.ifError(err); assert.equal(topicCount, 2); done(); @@ -253,7 +253,7 @@ describe('Categories', function () { }); it('should load category by privilege', function (done) { - socketCategories.getCategoriesByPrivilege({uid: posterUid}, 'find', function (err, data) { + socketCategories.getCategoriesByPrivilege({ uid: posterUid }, 'find', function (err, data) { assert.ifError(err); assert(Array.isArray(data)); done(); @@ -261,7 +261,7 @@ describe('Categories', function () { }); it('should get move categories', function (done) { - socketCategories.getMoveCategories({uid: posterUid}, {}, function (err, data) { + socketCategories.getMoveCategories({ uid: posterUid }, {}, function (err, data) { assert.ifError(err); assert(Array.isArray(data)); done(); @@ -269,7 +269,7 @@ describe('Categories', function () { }); it('should ignore category', function (done) { - socketCategories.ignore({uid: posterUid}, categoryObj.cid, function (err) { + socketCategories.ignore({ uid: posterUid }, categoryObj.cid, function (err) { assert.ifError(err); Categories.isIgnored([categoryObj.cid], posterUid, function (err, isIgnored) { assert.ifError(err); @@ -280,7 +280,7 @@ describe('Categories', function () { }); it('should watch category', function (done) { - socketCategories.watch({uid: posterUid}, categoryObj.cid, function (err) { + socketCategories.watch({ uid: posterUid }, categoryObj.cid, function (err) { assert.ifError(err); Categories.isIgnored([categoryObj.cid], posterUid, function (err, isIgnored) { assert.ifError(err); @@ -291,7 +291,7 @@ describe('Categories', function () { }); it('should check if user is moderator', function (done) { - socketCategories.isModerator({uid: posterUid}, {}, function (err, isModerator) { + socketCategories.isModerator({ uid: posterUid }, {}, function (err, isModerator) { assert.ifError(err); assert(!isModerator); done(); @@ -299,7 +299,7 @@ describe('Categories', function () { }); it('should get category data', function (done) { - socketCategories.getCategory({uid: posterUid}, categoryObj.cid, function (err, data) { + socketCategories.getCategory({ uid: posterUid }, categoryObj.cid, function (err, data) { assert.ifError(err); assert.equal(categoryObj.cid, data.cid); done(); @@ -311,7 +311,7 @@ describe('Categories', function () { var socketCategories = require('../src/socket.io/admin/categories'); var cid; before(function (done) { - socketCategories.create({uid: adminUid}, { + socketCategories.create({ uid: adminUid }, { name: 'update name', description: 'update description', parentCid: categoryObj.cid, @@ -326,7 +326,7 @@ describe('Categories', function () { }); it('should return error with invalid data', function (done) { - socketCategories.update({uid: adminUid}, null, function (err) { + socketCategories.update({ uid: adminUid }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); @@ -337,7 +337,7 @@ describe('Categories', function () { updateData[cid] = { parentCid: cid, }; - socketCategories.update({uid: adminUid}, updateData, function (err) { + socketCategories.update({ uid: adminUid }, updateData, function (err) { assert.equal(err.message, '[[error:cant-set-self-as-parent]]'); done(); }); @@ -352,7 +352,7 @@ describe('Categories', function () { order: 3, icon: 'fa-hammer', }; - socketCategories.update({uid: adminUid}, updateData, function (err) { + socketCategories.update({ uid: adminUid }, updateData, function (err) { assert.ifError(err); Categories.getCategoryData(cid, function (err, data) { assert.ifError(err); @@ -379,7 +379,7 @@ describe('Categories', function () { content: 'The content of test topic', }, function (err) { assert.ifError(err); - socketCategories.purge({uid: adminUid}, category.cid, function (err) { + socketCategories.purge({ uid: adminUid }, category.cid, function (err) { assert.ifError(err); done(); }); @@ -388,14 +388,14 @@ describe('Categories', function () { }); it('should get all categories', function (done) { - socketCategories.getAll({uid: adminUid}, {}, function (err, data) { + socketCategories.getAll({ uid: adminUid }, {}, function (err, data) { assert.ifError(err); done(); }); }); it('should get all category names', function (done) { - socketCategories.getNames({uid: adminUid}, {}, function (err, data) { + socketCategories.getNames({ uid: adminUid }, {}, function (err, data) { assert.ifError(err); assert(Array.isArray(data)); done(); @@ -403,7 +403,7 @@ describe('Categories', function () { }); it('should give privilege', function (done) { - socketCategories.setPrivilege({uid: adminUid}, {cid: categoryObj.cid, privilege: ['groups:topics:delete'], set: true, member: 'registered-users'}, function (err) { + socketCategories.setPrivilege({ uid: adminUid }, { cid: categoryObj.cid, privilege: ['groups:topics:delete'], set: true, member: 'registered-users' }, function (err) { assert.ifError(err); privileges.categories.can('topics:delete', categoryObj.cid, posterUid, function (err, canDeleteTopcis) { assert.ifError(err); @@ -414,7 +414,7 @@ describe('Categories', function () { }); it('should remove privilege', function (done) { - socketCategories.setPrivilege({uid: adminUid}, {cid: categoryObj.cid, privilege: 'groups:topics:delete', set: false, member: 'registered-users'}, function (err) { + socketCategories.setPrivilege({ uid: adminUid }, { cid: categoryObj.cid, privilege: 'groups:topics:delete', set: false, member: 'registered-users' }, function (err) { assert.ifError(err); privileges.categories.can('topics:delete', categoryObj.cid, posterUid, function (err, canDeleteTopcis) { assert.ifError(err); @@ -425,7 +425,7 @@ describe('Categories', function () { }); it('should get privilege settings', function (done) { - socketCategories.getPrivilegeSettings({uid: adminUid}, categoryObj.cid, function (err, data) { + socketCategories.getPrivilegeSettings({ uid: adminUid }, categoryObj.cid, function (err, data) { assert.ifError(err); assert(data); done(); @@ -438,22 +438,22 @@ describe('Categories', function () { var child2Cid; async.waterfall([ function (next) { - Categories.create({name: 'parent'}, next); + Categories.create({ name: 'parent' }, next); }, function (category, next) { parentCid = category.cid; - Categories.create({name: 'child1', parentCid: parentCid}, next); + Categories.create({ name: 'child1', parentCid: parentCid }, next); }, function (category, next) { child1Cid = category.cid; - Categories.create({name: 'child2', parentCid: child1Cid}, next); + Categories.create({ name: 'child2', parentCid: child1Cid }, next); }, function (category, next) { child2Cid = category.cid; - socketCategories.setPrivilege({uid: adminUid}, {cid: parentCid, privilege: 'groups:topics:delete', set: true, member: 'registered-users'}, next); + socketCategories.setPrivilege({ uid: adminUid }, { cid: parentCid, privilege: 'groups:topics:delete', set: true, member: 'registered-users' }, next); }, function (next) { - socketCategories.copyPrivilegesToChildren({uid: adminUid}, parentCid, next); + socketCategories.copyPrivilegesToChildren({ uid: adminUid }, parentCid, next); }, function (next) { privileges.categories.can('topics:delete', child2Cid, posterUid, next); @@ -470,15 +470,15 @@ describe('Categories', function () { var parentCid; async.waterfall([ function (next) { - Categories.create({name: 'parent', description: 'copy me'}, next); + Categories.create({ name: 'parent', description: 'copy me' }, next); }, function (category, next) { parentCid = category.cid; - Categories.create({name: 'child1'}, next); + Categories.create({ name: 'child1' }, next); }, function (category, next) { child1Cid = category.cid; - socketCategories.copySettingsFrom({uid: adminUid}, {fromCid: parentCid, toCid: child1Cid}, next); + socketCategories.copySettingsFrom({ uid: adminUid }, { fromCid: parentCid, toCid: child1Cid }, next); }, function (canDelete, next) { Categories.getCategoryField(child1Cid, 'description', next); @@ -495,18 +495,18 @@ describe('Categories', function () { var parentCid; async.waterfall([ function (next) { - Categories.create({name: 'parent', description: 'copy me'}, next); + Categories.create({ name: 'parent', description: 'copy me' }, next); }, function (category, next) { parentCid = category.cid; - Categories.create({name: 'child1'}, next); + Categories.create({ name: 'child1' }, next); }, function (category, next) { child1Cid = category.cid; - socketCategories.setPrivilege({uid: adminUid}, {cid: parentCid, privilege: 'groups:topics:delete', set: true, member: 'registered-users'}, next); + socketCategories.setPrivilege({ uid: adminUid }, { cid: parentCid, privilege: 'groups:topics:delete', set: true, member: 'registered-users' }, next); }, function (next) { - socketCategories.copyPrivilegesFrom({uid: adminUid}, {fromCid: parentCid, toCid: child1Cid}, next); + socketCategories.copyPrivilegesFrom({ uid: adminUid }, { fromCid: parentCid, toCid: child1Cid }, next); }, function (next) { privileges.categories.can('topics:delete', child1Cid, posterUid, next); @@ -554,14 +554,14 @@ describe('Categories', function () { }); it('should error if data is invalid', function (done) { - socketTopics.isTagAllowed({uid: posterUid}, null, function (err) { + socketTopics.isTagAllowed({ uid: posterUid }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should return true if category whitelist is empty', function (done) { - socketTopics.isTagAllowed({uid: posterUid}, {tag: 'notallowed', cid: cid}, function (err, allowed) { + socketTopics.isTagAllowed({ uid: posterUid }, { tag: 'notallowed', cid: cid }, function (err, allowed) { assert.ifError(err); assert(allowed); done(); @@ -584,7 +584,7 @@ describe('Categories', function () { }); it('should return false if category whitelist does not have tag', function (done) { - socketTopics.isTagAllowed({uid: posterUid}, {tag: 'notallowed', cid: cid}, function (err, allowed) { + socketTopics.isTagAllowed({ uid: posterUid }, { tag: 'notallowed', cid: cid }, function (err, allowed) { assert.ifError(err); assert(!allowed); done(); @@ -592,7 +592,7 @@ describe('Categories', function () { }); it('should return true if category whitelist has tag', function (done) { - socketTopics.isTagAllowed({uid: posterUid}, {tag: 'nodebb', cid: cid}, function (err, allowed) { + socketTopics.isTagAllowed({ uid: posterUid }, { tag: 'nodebb', cid: cid }, function (err, allowed) { assert.ifError(err); assert(allowed); done(); diff --git a/test/controllers-admin.js b/test/controllers-admin.js index e6edb82a18..ad59b4705d 100644 --- a/test/controllers-admin.js +++ b/test/controllers-admin.js @@ -29,10 +29,10 @@ describe('Admin Controllers', function () { }, next); }, adminUid: function (next) { - user.create({username: 'admin', password: 'barbar'}, next); + user.create({ username: 'admin', password: 'barbar' }, next); }, regularUid: function (next) { - user.create({username: 'regular'}, next); + user.create({ username: 'regular' }, next); }, }, function (err, results) { if (err) { @@ -42,7 +42,7 @@ describe('Admin Controllers', function () { regularUid = results.regularUid; cid = results.category.cid; - topics.post({uid: adminUid, title: 'test topic title', content: 'test topic content', cid: results.category.cid}, function (err, result) { + topics.post({ uid: adminUid, title: 'test topic title', content: 'test topic content', cid: results.category.cid }, function (err, result) { tid = result.topicData.tid; pid = result.postData.pid; done(err); @@ -54,7 +54,7 @@ describe('Admin Controllers', function () { helpers.loginUser('admin', 'barbar', function (err, _jar) { assert.ifError(err); jar = _jar; - request(nconf.get('url') + '/admin', {jar: jar}, function (err, res, body) { + request(nconf.get('url') + '/admin', { jar: jar }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 403); assert(body); @@ -66,7 +66,7 @@ describe('Admin Controllers', function () { it('should load admin dashboard', function (done) { groups.join('administrators', adminUid, function (err) { assert.ifError(err); - request(nconf.get('url') + '/admin', {jar: jar}, function (err, res, body) { + request(nconf.get('url') + '/admin', { jar: jar }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(body); @@ -76,7 +76,7 @@ describe('Admin Controllers', function () { }); it('should load groups page', function (done) { - request(nconf.get('url') + '/admin/manage/groups', {jar: jar}, function (err, res, body) { + request(nconf.get('url') + '/admin/manage/groups', { jar: jar }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(body); @@ -85,7 +85,7 @@ describe('Admin Controllers', function () { }); it('should load groups detail page', function (done) { - request(nconf.get('url') + '/admin/manage/groups/administrators', {jar: jar}, function (err, res, body) { + request(nconf.get('url') + '/admin/manage/groups/administrators', { jar: jar }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(body); @@ -95,7 +95,7 @@ describe('Admin Controllers', function () { it('should load general settings page', function (done) { - request(nconf.get('url') + '/admin/settings', {jar: jar}, function (err, res, body) { + request(nconf.get('url') + '/admin/settings', { jar: jar }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(body); @@ -104,7 +104,7 @@ describe('Admin Controllers', function () { }); it('should load email settings page', function (done) { - request(nconf.get('url') + '/admin/settings/email', {jar: jar}, function (err, res, body) { + request(nconf.get('url') + '/admin/settings/email', { jar: jar }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(body); @@ -113,7 +113,7 @@ describe('Admin Controllers', function () { }); it('should load info page for a user', function (done) { - request(nconf.get('url') + '/api/user/regular/info', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/user/regular/info', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(body.history); @@ -126,7 +126,7 @@ describe('Admin Controllers', function () { }); it('should 404 for edit/email page if user does not exist', function (done) { - request(nconf.get('url') + '/api/user/doesnotexist/edit/email', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/user/doesnotexist/edit/email', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 404); done(); @@ -134,7 +134,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/general/homepage', function (done) { - request(nconf.get('url') + '/api/admin/general/homepage', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/general/homepage', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(body.routes); @@ -143,7 +143,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/advanced/database', function (done) { - request(nconf.get('url') + '/api/admin/advanced/database', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/advanced/database', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); @@ -157,7 +157,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/extend/plugins', function (done) { - request(nconf.get('url') + '/api/admin/extend/plugins', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/extend/plugins', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body.hasOwnProperty('installed')); assert(body.hasOwnProperty('upgradeCount')); @@ -168,7 +168,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/manage/users', function (done) { - request(nconf.get('url') + '/api/admin/manage/users', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/manage/users', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -176,7 +176,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/manage/users/search', function (done) { - request(nconf.get('url') + '/api/admin/manage/users/search', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/manage/users/search', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body.users); done(); @@ -184,7 +184,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/manage/users/not-validated', function (done) { - request(nconf.get('url') + '/api/admin/manage/users/not-validated', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/manage/users/not-validated', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -192,7 +192,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/manage/users/no-posts', function (done) { - request(nconf.get('url') + '/api/admin/manage/users/no-posts', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/manage/users/no-posts', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -200,7 +200,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/manage/users/top-posters', function (done) { - request(nconf.get('url') + '/api/admin/manage/users/top-posters', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/manage/users/top-posters', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -208,7 +208,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/manage/users/most-reputation', function (done) { - request(nconf.get('url') + '/api/admin/manage/users/most-reputation', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/manage/users/most-reputation', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -216,7 +216,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/manage/users/inactive', function (done) { - request(nconf.get('url') + '/api/admin/manage/users/inactive', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/manage/users/inactive', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -224,7 +224,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/manage/users/flagged', function (done) { - request(nconf.get('url') + '/api/admin/manage/users/flagged', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/manage/users/flagged', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -232,7 +232,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/manage/users/banned', function (done) { - request(nconf.get('url') + '/api/admin/manage/users/banned', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/manage/users/banned', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -240,7 +240,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/manage/registration', function (done) { - request(nconf.get('url') + '/api/admin/manage/registration', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/manage/registration', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -248,7 +248,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/users/csv', function (done) { - request(nconf.get('url') + '/api/admin/users/csv', {jar: jar}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/users/csv', { jar: jar }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -256,7 +256,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/manage/flags', function (done) { - request(nconf.get('url') + '/api/admin/manage/flags', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/manage/flags', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -264,7 +264,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/advanced/cache', function (done) { - request(nconf.get('url') + '/api/admin/advanced/cache', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/advanced/cache', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -272,7 +272,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/advanced/errors', function (done) { - request(nconf.get('url') + '/api/admin/advanced/errors', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/advanced/errors', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -280,7 +280,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/advanced/errors/export', function (done) { - request(nconf.get('url') + '/api/admin/advanced/errors/export', {jar: jar}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/advanced/errors/export', { jar: jar }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -288,7 +288,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/advanced/logs', function (done) { - request(nconf.get('url') + '/api/admin/advanced/logs', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/advanced/logs', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -296,7 +296,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/general/navigation', function (done) { - request(nconf.get('url') + '/api/admin/general/navigation', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/general/navigation', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -304,7 +304,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/development/info', function (done) { - request(nconf.get('url') + '/api/admin/development/info', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/development/info', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -312,7 +312,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/development/logger', function (done) { - request(nconf.get('url') + '/api/admin/development/logger', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/development/logger', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -320,7 +320,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/advanced/events', function (done) { - request(nconf.get('url') + '/api/admin/advanced/events', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/advanced/events', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -328,7 +328,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/general/sounds', function (done) { - request(nconf.get('url') + '/api/admin/general/sounds', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/general/sounds', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -336,7 +336,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/manage/categories', function (done) { - request(nconf.get('url') + '/api/admin/manage/categories', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/manage/categories', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -344,7 +344,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/manage/categories/1', function (done) { - request(nconf.get('url') + '/api/admin/manage/categories/1', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/manage/categories/1', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -352,7 +352,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/manage/categories/1/analytics', function (done) { - request(nconf.get('url') + '/api/admin/manage/categories/1/analytics', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/manage/categories/1/analytics', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -360,7 +360,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/extend/rewards', function (done) { - request(nconf.get('url') + '/api/admin/extend/rewards', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/extend/rewards', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -368,7 +368,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/extend/widgets', function (done) { - request(nconf.get('url') + '/api/admin/extend/widgets', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/extend/widgets', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -376,7 +376,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/general/languages', function (done) { - request(nconf.get('url') + '/api/admin/general/languages', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/general/languages', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -384,7 +384,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/general/social', function (done) { - request(nconf.get('url') + '/api/admin/general/social', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/general/social', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -392,7 +392,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/manage/tags', function (done) { - request(nconf.get('url') + '/api/admin/manage/tags', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/manage/tags', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -400,7 +400,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/manage/ip-blacklist', function (done) { - request(nconf.get('url') + '/api/admin/manage/ip-blacklist', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/manage/ip-blacklist', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -408,7 +408,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/appearance/themes', function (done) { - request(nconf.get('url') + '/api/admin/appearance/themes', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/appearance/themes', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -416,7 +416,7 @@ describe('Admin Controllers', function () { }); it('should load /admin/appearance/customise', function (done) { - request(nconf.get('url') + '/api/admin/appearance/customise', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/appearance/customise', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); @@ -426,7 +426,7 @@ describe('Admin Controllers', function () { it('should load /recent in maintenance mode', function (done) { var meta = require('../src/meta'); meta.config.maintenanceMode = 1; - request(nconf.get('url') + '/api/recent', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/recent', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(body); @@ -437,7 +437,7 @@ describe('Admin Controllers', function () { it('should load /posts/flags', function (done) { - request(nconf.get('url') + '/api/posts/flags', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/posts/flags', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert(body); done(); diff --git a/test/controllers.js b/test/controllers.js index 73c8a2723b..6c10e24b26 100644 --- a/test/controllers.js +++ b/test/controllers.js @@ -27,7 +27,7 @@ describe('Controllers', function () { }, next); }, user: function (next) { - user.create({username: 'foo', password: 'barbar'}, next); + user.create({ username: 'foo', password: 'barbar' }, next); }, }, function (err, results) { if (err) { @@ -36,7 +36,7 @@ describe('Controllers', function () { cid = results.category.cid; fooUid = results.user; - topics.post({uid: results.user, title: 'test topic title', content: 'test topic content', cid: results.category.cid}, function (err, result) { + topics.post({ uid: results.user, title: 'test topic title', content: 'test topic content', cid: results.category.cid }, function (err, result) { tid = result.topicData.tid; pid = result.postData.pid; done(err); @@ -507,7 +507,7 @@ describe('Controllers', function () { var csrf_token; var helpers = require('./helpers'); before(function (done) { - user.create({username: 'revokeme', password: 'barbar'}, function (err, _uid) { + user.create({ username: 'revokeme', password: 'barbar' }, function (err, _uid) { assert.ifError(err); uid = _uid; helpers.loginUser('revokeme', 'barbar', function (err, _jar, io, _csrf_token) { @@ -602,7 +602,7 @@ describe('Controllers', function () { }); it('should return {} if there is no template or locations', function (done) { - request(nconf.get('url') + '/api/widgets/render', {json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/widgets/render', { json: true }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(body); @@ -613,7 +613,7 @@ describe('Controllers', function () { it('should render templates', function (done) { var url = nconf.get('url') + '/api/widgets/render?template=categories.tpl&url=&isMobile=false&locations%5B%5D=sidebar&locations%5B%5D=footer&locations%5B%5D=header'; - request(url, {json: true}, function (err, res, body) { + request(url, { json: true }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(body); @@ -639,7 +639,7 @@ describe('Controllers', function () { }); it('should render tags page', function (done) { - request(nconf.get('url') + '/api/tags', {json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/tags', { json: true }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(body); @@ -649,7 +649,7 @@ describe('Controllers', function () { }); it('should render tag page with no topics', function (done) { - request(nconf.get('url') + '/api/tags/notag', {json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/tags/notag', { json: true }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(body); @@ -660,7 +660,7 @@ describe('Controllers', function () { }); it('should render tag page with 1 topic', function (done) { - request(nconf.get('url') + '/api/tags/nodebb', {json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/tags/nodebb', { json: true }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(body); @@ -683,7 +683,7 @@ describe('Controllers', function () { }); it('should return 503 in maintenance mode', function (done) { - request(nconf.get('url') + '/recent', {json: true}, function (err, res, body) { + request(nconf.get('url') + '/recent', { json: true }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 503); done(); @@ -691,7 +691,7 @@ describe('Controllers', function () { }); it('should return 503 in maintenance mode', function (done) { - request(nconf.get('url') + '/api/recent', {json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/recent', { json: true }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 503); assert(body); @@ -700,7 +700,7 @@ describe('Controllers', function () { }); it('should return 200 in maintenance mode', function (done) { - request(nconf.get('url') + '/api/login', {json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/login', { json: true }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(body); @@ -739,7 +739,7 @@ describe('Controllers', function () { }); it('should load /user/foo/bookmarks', function (done) { - request(nconf.get('url') + '/api/user/foo/bookmarks', {jar: jar}, function (err, res, body) { + request(nconf.get('url') + '/api/user/foo/bookmarks', { jar: jar }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(body); @@ -748,7 +748,7 @@ describe('Controllers', function () { }); it('should load /user/foo/upvoted', function (done) { - request(nconf.get('url') + '/api/user/foo/upvoted', {jar: jar}, function (err, res, body) { + request(nconf.get('url') + '/api/user/foo/upvoted', { jar: jar }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(body); @@ -757,7 +757,7 @@ describe('Controllers', function () { }); it('should load /user/foo/downvoted', function (done) { - request(nconf.get('url') + '/api/user/foo/downvoted', {jar: jar}, function (err, res, body) { + request(nconf.get('url') + '/api/user/foo/downvoted', { jar: jar }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(body); @@ -775,7 +775,7 @@ describe('Controllers', function () { }); it('should load /user/foo/watched', function (done) { - request(nconf.get('url') + '/api/user/foo/watched', {jar: jar}, function (err, res, body) { + request(nconf.get('url') + '/api/user/foo/watched', { jar: jar }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(body); @@ -816,7 +816,7 @@ describe('Controllers', function () { setTimeout(next, 2500); }, function (next) { - request(nconf.get('url') + '/api/notifications', {jar: jar, json: true}, next); + request(nconf.get('url') + '/api/notifications', { jar: jar, json: true }, next); }, function (res, body, next) { assert.equal(res.statusCode, 200); @@ -837,12 +837,12 @@ describe('Controllers', function () { var socketUser = require('../src/socket.io/user'); var uid; before(function (done) { - user.create({username: 'follower'}, function (err, _uid) { + user.create({ username: 'follower' }, function (err, _uid) { assert.ifError(err); uid = _uid; - socketUser.follow({uid: uid}, {uid: fooUid}, function (err) { + socketUser.follow({ uid: uid }, { uid: fooUid }, function (err) { assert.ifError(err); - socketUser.isFollowing({uid: uid}, {uid: fooUid}, function (err, isFollowing) { + socketUser.isFollowing({ uid: uid }, { uid: fooUid }, function (err, isFollowing) { assert.ifError(err); assert(isFollowing); done(); @@ -852,7 +852,7 @@ describe('Controllers', function () { }); it('should get followers page', function (done) { - request(nconf.get('url') + '/api/user/foo/followers', {json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/user/foo/followers', { json: true }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert.equal(body.users[0].username, 'follower'); @@ -861,7 +861,7 @@ describe('Controllers', function () { }); it('should get following page', function (done) { - request(nconf.get('url') + '/api/user/follower/following', {json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/user/follower/following', { json: true }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert.equal(body.users[0].username, 'foo'); @@ -870,9 +870,9 @@ describe('Controllers', function () { }); it('should return empty after unfollow', function (done) { - socketUser.unfollow({uid: uid}, {uid: fooUid}, function (err) { + socketUser.unfollow({ uid: uid }, { uid: fooUid }, function (err) { assert.ifError(err); - request(nconf.get('url') + '/api/user/foo/followers', {json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/user/foo/followers', { json: true }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert.equal(body.users.length, 0); diff --git a/test/database/hash.js b/test/database/hash.js index 41428818f0..4da340b960 100644 --- a/test/database/hash.js +++ b/test/database/hash.js @@ -18,7 +18,7 @@ describe('Hash methods', function () { describe('setObject()', function () { it('should create a object', function (done) { - db.setObject('testObject1', {foo: 'baris', bar: 99}, function (err) { + db.setObject('testObject1', { foo: 'baris', bar: 99 }, function (err) { assert.equal(err, null); assert.equal(arguments.length, 1); done(); @@ -26,7 +26,7 @@ describe('Hash methods', function () { }); it('should do nothing if key is falsy', function (done) { - db.setObject('', {foo: 1, derp: 2}, function (err) { + db.setObject('', { foo: 1, derp: 2 }, function (err) { assert.ifError(err); done(); }); @@ -86,7 +86,7 @@ describe('Hash methods', function () { describe('getObjects()', function () { before(function (done) { async.parallel([ - async.apply(db.setObject, 'testObject4', {name: 'baris'}), + async.apply(db.setObject, 'testObject4', { name: 'baris' }), async.apply(db.setObjectField, 'testObject5', 'name', 'ginger'), ], done); }); @@ -161,8 +161,8 @@ describe('Hash methods', function () { describe('getObjectsFields()', function () { before(function (done) { async.parallel([ - async.apply(db.setObject, 'testObject8', {name: 'baris', age: 99}), - async.apply(db.setObject, 'testObject9', {name: 'ginger', age: 3}), + async.apply(db.setObject, 'testObject8', { name: 'baris', age: 99 }), + async.apply(db.setObject, 'testObject9', { name: 'ginger', age: 3 }), ], done); }); @@ -278,7 +278,7 @@ describe('Hash methods', function () { describe('deleteObjectField()', function () { before(function (done) { - db.setObject('testObject10', {foo: 'bar', delete: 'this', delete1: 'this', delete2: 'this'}, done); + db.setObject('testObject10', { foo: 'bar', delete: 'this', delete1: 'this', delete2: 'this' }, done); }); it('should delete an objects field', function (done) { @@ -312,7 +312,7 @@ describe('Hash methods', function () { describe('incrObjectField()', function () { before(function (done) { - db.setObject('testObject11', {age: 99}, done); + db.setObject('testObject11', { age: 99 }, done); }); it('should set an objects field to 1 if object does not exist', function (done) { @@ -336,7 +336,7 @@ describe('Hash methods', function () { describe('decrObjectField()', function () { before(function (done) { - db.setObject('testObject13', {age: 99}, done); + db.setObject('testObject13', { age: 99 }, done); }); it('should set an objects field to -1 if object does not exist', function (done) { @@ -360,7 +360,7 @@ describe('Hash methods', function () { describe('incrObjectFieldBy()', function () { before(function (done) { - db.setObject('testObject15', {age: 100}, done); + db.setObject('testObject15', { age: 100 }, done); }); it('should set an objects field to 5 if object does not exist', function (done) { diff --git a/test/database/sorted.js b/test/database/sorted.js index 0bd0ab31dc..939f4b259e 100644 --- a/test/database/sorted.js +++ b/test/database/sorted.js @@ -96,7 +96,7 @@ describe('Sorted Set methods', function () { db.getSortedSetRangeWithScores('sortedSetTest1', 0, -1, function (err, values) { assert.equal(err, null); assert.equal(arguments.length, 2); - assert.deepEqual(values, [{value: 'value1', score: 1.1}, {value: 'value2', score: 1.2}, {value: 'value3', score: 1.3}]); + assert.deepEqual(values, [{ value: 'value1', score: 1.1 }, { value: 'value2', score: 1.2 }, { value: 'value3', score: 1.3 }]); done(); }); }); @@ -107,7 +107,7 @@ describe('Sorted Set methods', function () { db.getSortedSetRevRangeWithScores('sortedSetTest1', 0, -1, function (err, values) { assert.equal(err, null); assert.equal(arguments.length, 2); - assert.deepEqual(values, [{value: 'value3', score: 1.3}, {value: 'value2', score: 1.2}, {value: 'value1', score: 1.1}]); + assert.deepEqual(values, [{ value: 'value3', score: 1.3 }, { value: 'value2', score: 1.2 }, { value: 'value1', score: 1.1 }]); done(); }); }); @@ -140,7 +140,7 @@ describe('Sorted Set methods', function () { db.getSortedSetRangeByScoreWithScores('sortedSetTest1', 0, -1, '-inf', 1.2, function (err, values) { assert.equal(err, null); assert.equal(arguments.length, 2); - assert.deepEqual(values, [{value: 'value1', score: 1.1}, {value: 'value2', score: 1.2}]); + assert.deepEqual(values, [{ value: 'value1', score: 1.1 }, { value: 'value2', score: 1.2 }]); done(); }); }); @@ -151,7 +151,7 @@ describe('Sorted Set methods', function () { db.getSortedSetRevRangeByScoreWithScores('sortedSetTest1', 0, -1, '+inf', 1.2, function (err, values) { assert.equal(err, null); assert.equal(arguments.length, 2); - assert.deepEqual(values, [{value: 'value3', score: 1.3}, {value: 'value2', score: 1.2}]); + assert.deepEqual(values, [{ value: 'value3', score: 1.3 }, { value: 'value2', score: 1.2 }]); done(); }); }); @@ -450,7 +450,7 @@ describe('Sorted Set methods', function () { describe('getSortedSetUnion()', function () { it('should return an array of values from both sorted sets sorted by scores lowest to highest', function (done) { - db.getSortedSetUnion({sets: ['sortedSetTest2', 'sortedSetTest3'], start: 0, stop: -1}, function (err, values) { + db.getSortedSetUnion({ sets: ['sortedSetTest2', 'sortedSetTest3'], start: 0, stop: -1 }, function (err, values) { assert.equal(err, null); assert.equal(arguments.length, 2); assert.deepEqual(values, ['value1', 'value2', 'value4']); @@ -461,7 +461,7 @@ describe('Sorted Set methods', function () { describe('getSortedSetRevUnion()', function () { it('should return an array of values from both sorted sets sorted by scores highest to lowest', function (done) { - db.getSortedSetRevUnion({sets: ['sortedSetTest2', 'sortedSetTest3'], start: 0, stop: -1}, function (err, values) { + db.getSortedSetRevUnion({ sets: ['sortedSetTest2', 'sortedSetTest3'], start: 0, stop: -1 }, function (err, values) { assert.equal(err, null); assert.equal(arguments.length, 2); assert.deepEqual(values, ['value4', 'value2', 'value1']); @@ -588,7 +588,7 @@ describe('Sorted Set methods', function () { withScores: true, }, function (err, data) { assert.ifError(err); - assert.deepEqual([{value: 'value2', score: 6}, {value: 'value3', score: 8}], data); + assert.deepEqual([{ value: 'value2', score: 6 }, { value: 'value3', score: 8 }], data); done(); }); }); @@ -602,7 +602,7 @@ describe('Sorted Set methods', function () { aggregate: 'MIN', }, function (err, data) { assert.ifError(err); - assert.deepEqual([{value: 'value2', score: 2}, {value: 'value3', score: 3}], data); + assert.deepEqual([{ value: 'value2', score: 2 }, { value: 'value3', score: 3 }], data); done(); }); }); @@ -616,7 +616,7 @@ describe('Sorted Set methods', function () { aggregate: 'MAX', }, function (err, data) { assert.ifError(err); - assert.deepEqual([{value: 'value2', score: 4}, {value: 'value3', score: 5}], data); + assert.deepEqual([{ value: 'value2', score: 4 }, { value: 'value3', score: 5 }], data); done(); }); }); @@ -630,7 +630,7 @@ describe('Sorted Set methods', function () { weights: [1, 0.5], }, function (err, data) { assert.ifError(err); - assert.deepEqual([{value: 'value2', score: 4}, {value: 'value3', score: 5.5}], data); + assert.deepEqual([{ value: 'value2', score: 4 }, { value: 'value3', score: 5.5 }], data); done(); }); }); diff --git a/test/groups.js b/test/groups.js index 426b5c42ca..8e70341e00 100644 --- a/test/groups.js +++ b/test/groups.js @@ -99,7 +99,7 @@ describe('Groups', function () { var socketGroups = require('../src/socket.io/groups'); it('should return the groups when search query is empty', function (done) { - socketGroups.search({uid: adminUid}, {query: ''}, function (err, groups) { + socketGroups.search({ uid: adminUid }, { query: '' }, function (err, groups) { assert.ifError(err); assert.equal(3, groups.length); done(); @@ -107,7 +107,7 @@ describe('Groups', function () { }); it('should return the "Test" group when searched for', function (done) { - socketGroups.search({uid: adminUid}, {query: 'test'}, function (err, groups) { + socketGroups.search({ uid: adminUid }, { query: 'test' }, function (err, groups) { assert.ifError(err); assert.equal(1, groups.length); assert.strictEqual('Test', groups[0].name); @@ -116,7 +116,7 @@ describe('Groups', function () { }); it('should return the "Test" group when searched for and sort by member count', function (done) { - Groups.search('test', {filterHidden: true, sort: 'count'}, function (err, groups) { + Groups.search('test', { filterHidden: true, sort: 'count' }, function (err, groups) { assert.ifError(err); assert.equal(1, groups.length); assert.strictEqual('Test', groups[0].name); @@ -125,7 +125,7 @@ describe('Groups', function () { }); it('should return the "Test" group when searched for and sort by creation time', function (done) { - Groups.search('test', {filterHidden: true, sort: 'date'}, function (err, groups) { + Groups.search('test', { filterHidden: true, sort: 'date' }, function (err, groups) { assert.ifError(err); assert.equal(1, groups.length); assert.strictEqual('Test', groups[0].name); @@ -141,7 +141,7 @@ describe('Groups', function () { assert.ifError(err); Groups.join('Test', uid, function (err) { assert.ifError(err); - socketGroups.searchMembers({uid: adminUid}, {groupName: 'Test', query: ''}, function (err, data) { + socketGroups.searchMembers({ uid: adminUid }, { groupName: 'Test', query: '' }, function (err, data) { assert.ifError(err); assert.equal(data.users.length, 2); done(); @@ -151,7 +151,7 @@ describe('Groups', function () { }); it('should search group members', function (done) { - socketGroups.searchMembers({uid: adminUid}, {groupName: 'Test', query: 'test'}, function (err, data) { + socketGroups.searchMembers({ uid: adminUid }, { groupName: 'Test', query: 'test' }, function (err, data) { assert.ifError(err); assert.strictEqual('testuser', data.users[0].username); done(); @@ -234,7 +234,7 @@ describe('Groups', function () { }); it('should fail to create group with duplicate group name', function (done) { - Groups.create({name: 'foo'}, function (err) { + Groups.create({ name: 'foo' }, function (err) { assert(err); assert.equal(err.message, '[[error:group-already-exists]]'); done(); @@ -242,21 +242,21 @@ describe('Groups', function () { }); it('should fail to create group if slug is empty', function (done) { - Groups.create({name: '>>>>'}, function (err) { + Groups.create({ name: '>>>>' }, function (err) { assert.equal(err.message, '[[error:invalid-group-name]]'); done(); }); }); it('should fail if group name is invalid', function (done) { - Groups.create({name: 'not/valid'}, function (err) { + Groups.create({ name: 'not/valid' }, function (err) { assert.equal(err.message, '[[error:invalid-group-name]]'); done(); }); }); it('should fail if group name is invalid', function (done) { - Groups.create({name: 'not:valid'}, function (err) { + Groups.create({ name: 'not:valid' }, function (err) { assert.equal(err.message, '[[error:invalid-group-name]]'); done(); }); @@ -434,35 +434,35 @@ describe('Groups', function () { it('should error if data is null', function (done) { - socketGroups.before({uid: 0}, 'groups.join', null, function (err) { + socketGroups.before({ uid: 0 }, 'groups.join', null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should not error if data is valid', function (done) { - socketGroups.before({uid: 0}, 'groups.join', {}, function (err) { + socketGroups.before({ uid: 0 }, 'groups.join', {}, function (err) { assert.ifError(err); done(); }); }); it('should return error if not logged in', function (done) { - socketGroups.join({uid: 0}, {}, function (err) { + socketGroups.join({ uid: 0 }, {}, function (err) { assert.equal(err.message, '[[error:invalid-uid]]'); done(); }); }); it('should return error if group name is special', function (done) { - socketGroups.join({uid: adminUid}, {groupName: 'administrators'}, function (err) { + socketGroups.join({ uid: adminUid }, { groupName: 'administrators' }, function (err) { assert.equal(err.message, '[[error:not-allowed]]'); done(); }); }); it('should error if group does not exist', function (done) { - socketGroups.join({uid: adminUid}, {groupName: 'doesnotexist'}, function (err) { + socketGroups.join({ uid: adminUid }, { groupName: 'doesnotexist' }, function (err) { assert.equal(err.message, '[[error:no-group]]'); done(); }); @@ -470,7 +470,7 @@ describe('Groups', function () { it('should join test group', function (done) { meta.config.allowPrivateGroups = 0; - socketGroups.join({uid: adminUid}, {groupName: 'Test'}, function (err) { + socketGroups.join({ uid: adminUid }, { groupName: 'Test' }, function (err) { assert.ifError(err); Groups.isMember(adminUid, 'Test', function (err, isMember) { assert.ifError(err); @@ -481,21 +481,21 @@ describe('Groups', function () { }); it('should error if not logged in', function (done) { - socketGroups.leave({uid: 0}, {}, function (err) { + socketGroups.leave({ uid: 0 }, {}, function (err) { assert.equal(err.message, '[[error:invalid-uid]]'); done(); }); }); it('should return error if group name is special', function (done) { - socketGroups.leave({uid: adminUid}, {groupName: 'administrators'}, function (err) { + socketGroups.leave({ uid: adminUid }, { groupName: 'administrators' }, function (err) { assert.equal(err.message, '[[error:cant-remove-self-as-admin]]'); done(); }); }); it('should leave test group', function (done) { - socketGroups.leave({uid: adminUid}, {groupName: 'Test'}, function (err) { + socketGroups.leave({ uid: adminUid }, { groupName: 'Test' }, function (err) { assert.ifError(err); Groups.isMember('Test', adminUid, function (err, isMember) { assert.ifError(err); @@ -507,14 +507,14 @@ describe('Groups', function () { it('should fail to join if group is private and join requests are disabled', function (done) { meta.config.allowPrivateGroups = 1; - socketGroups.join({uid: testUid}, {groupName: 'PrivateNoJoin'}, function (err) { + socketGroups.join({ uid: testUid }, { groupName: 'PrivateNoJoin' }, function (err) { assert.equal(err.message, '[[error:join-requests-disabled]]'); done(); }); }); it('should join if user is admin', function (done) { - socketGroups.join({uid: adminUid}, {groupName: 'PrivateCanJoin'}, function (err) { + socketGroups.join({ uid: adminUid }, { groupName: 'PrivateCanJoin' }, function (err) { assert.ifError(err); Groups.isMember(adminUid, 'PrivateCanJoin', function (err, isMember) { assert.ifError(err); @@ -525,7 +525,7 @@ describe('Groups', function () { }); it('should request membership for regular user', function (done) { - socketGroups.join({uid: testUid}, {groupName: 'PrivateCanJoin'}, function (err) { + socketGroups.join({ uid: testUid }, { groupName: 'PrivateCanJoin' }, function (err) { assert.ifError(err); Groups.isPending(testUid, 'PrivateCanJoin', function (err, isPending) { assert.ifError(err); @@ -536,7 +536,7 @@ describe('Groups', function () { }); it('should accept membership of user', function (done) { - socketGroups.accept({uid: adminUid}, {groupName: 'PrivateCanJoin', toUid: testUid}, function (err) { + socketGroups.accept({ uid: adminUid }, { groupName: 'PrivateCanJoin', toUid: testUid }, function (err) { assert.ifError(err); Groups.isMember(testUid, 'PrivateCanJoin', function (err, isMember) { assert.ifError(err); @@ -547,7 +547,7 @@ describe('Groups', function () { }); it('should grant ownership to user', function (done) { - socketGroups.grant({uid: adminUid}, {groupName: 'PrivateCanJoin', toUid: testUid}, function (err) { + socketGroups.grant({ uid: adminUid }, { groupName: 'PrivateCanJoin', toUid: testUid }, function (err) { assert.ifError(err); Groups.ownership.isOwner(testUid, 'PrivateCanJoin', function (err, isOwner) { assert.ifError(err); @@ -558,7 +558,7 @@ describe('Groups', function () { }); it('should rescind ownership from user', function (done) { - socketGroups.rescind({uid: adminUid}, {groupName: 'PrivateCanJoin', toUid: testUid}, function (err) { + socketGroups.rescind({ uid: adminUid }, { groupName: 'PrivateCanJoin', toUid: testUid }, function (err) { assert.ifError(err); Groups.ownership.isOwner(testUid, 'PrivateCanJoin', function (err, isOwner) { assert.ifError(err); @@ -569,7 +569,7 @@ describe('Groups', function () { }); it('should kick user from group', function (done) { - socketGroups.kick({uid: adminUid}, {groupName: 'PrivateCanJoin', uid: testUid}, function (err) { + socketGroups.kick({ uid: adminUid }, { groupName: 'PrivateCanJoin', uid: testUid }, function (err) { assert.ifError(err); Groups.isMember(testUid, 'PrivateCanJoin', function (err, isMember) { assert.ifError(err); @@ -584,21 +584,21 @@ describe('Groups', function () { var socketGroups = require('../src/socket.io/admin/groups'); it('should fail to create group with invalid data', function (done) { - socketGroups.create({uid: adminUid}, null, function (err) { + socketGroups.create({ uid: adminUid }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should fail to create group if group name is privilege group', function (done) { - socketGroups.create({uid: adminUid}, {name: 'cid:1:privileges:read'}, function (err) { + socketGroups.create({ uid: adminUid }, { name: 'cid:1:privileges:read' }, function (err) { assert.equal(err.message, '[[error:invalid-group-name]]'); done(); }); }); it('should create a group', function (done) { - socketGroups.create({uid: adminUid}, {name: 'newgroup', description: 'group created by admin'}, function (err, groupData) { + socketGroups.create({ uid: adminUid }, { name: 'newgroup', description: 'group created by admin' }, function (err, groupData) { assert.ifError(err); assert.equal(groupData.name, 'newgroup'); assert.equal(groupData.description, 'group created by admin'); @@ -610,14 +610,14 @@ describe('Groups', function () { }); it('should fail to join with invalid data', function (done) { - socketGroups.join({uid: adminUid}, null, function (err) { + socketGroups.join({ uid: adminUid }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should add user to group', function (done) { - socketGroups.join({uid: adminUid}, {uid: testUid, groupName: 'newgroup'}, function (err) { + socketGroups.join({ uid: adminUid }, { uid: testUid, groupName: 'newgroup' }, function (err) { assert.ifError(err); Groups.isMember(testUid, 'newgroup', function (err, isMember) { assert.ifError(err); @@ -628,35 +628,35 @@ describe('Groups', function () { }); it('should fail to if user is already member', function (done) { - socketGroups.join({uid: adminUid}, {uid: testUid, groupName: 'newgroup'}, function (err) { + socketGroups.join({ uid: adminUid }, { uid: testUid, groupName: 'newgroup' }, function (err) { assert.equal(err.message, '[[error:group-already-member]]'); done(); }); }); it('it should fail with invalid data', function (done) { - socketGroups.leave({uid: adminUid}, null, function (err) { + socketGroups.leave({ uid: adminUid }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('it should fail if admin tries to remove self', function (done) { - socketGroups.leave({uid: adminUid}, {uid: adminUid, groupName: 'administrators'}, function (err) { + socketGroups.leave({ uid: adminUid }, { uid: adminUid, groupName: 'administrators' }, function (err) { assert.equal(err.message, '[[error:cant-remove-self-as-admin]]'); done(); }); }); it('should fail if user is not member', function (done) { - socketGroups.leave({uid: adminUid}, {uid: 3, groupName: 'newgroup'}, function (err) { + socketGroups.leave({ uid: adminUid }, { uid: 3, groupName: 'newgroup' }, function (err) { assert.equal(err.message, '[[error:group-not-member]]'); done(); }); }); it('should remove user from group', function (done) { - socketGroups.leave({uid: adminUid}, {uid: testUid, groupName: 'newgroup'}, function (err) { + socketGroups.leave({ uid: adminUid }, { uid: testUid, groupName: 'newgroup' }, function (err) { assert.ifError(err); Groups.isMember(testUid, 'newgroup', function (err, isMember) { assert.ifError(err); @@ -667,7 +667,7 @@ describe('Groups', function () { }); it('should fail with invalid data', function (done) { - socketGroups.update({uid: adminUid}, null, function (err) { + socketGroups.update({ uid: adminUid }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); @@ -686,7 +686,7 @@ describe('Groups', function () { private: 0, }, }; - socketGroups.update({uid: adminUid}, data, function (err) { + socketGroups.update({ uid: adminUid }, data, function (err) { assert.ifError(err); Groups.get('renamedgroup', {}, function (err, groupData) { assert.ifError(err); @@ -708,7 +708,7 @@ describe('Groups', function () { var logoPath = path.join(__dirname, '../public/logo.png'); var imagePath = path.join(__dirname, '../public/groupcover.png'); before(function (done) { - User.create({username: 'regularuser', password: '123456'}, function (err, uid) { + User.create({ username: 'regularuser', password: '123456' }, function (err, uid) { assert.ifError(err); regularUid = uid; async.series([ @@ -726,9 +726,9 @@ describe('Groups', function () { }); it('should fail if user is not logged in or not owner', function (done) { - socketGroups.cover.update({uid: 0}, {}, function (err) { + socketGroups.cover.update({ uid: 0 }, {}, function (err) { assert.equal(err.message, '[[error:no-privileges]]'); - socketGroups.cover.update({uid: regularUid}, {}, function (err) { + socketGroups.cover.update({ uid: regularUid }, {}, function (err) { assert.equal(err.message, '[[error:no-privileges]]'); done(); }); @@ -740,7 +740,7 @@ describe('Groups', function () { groupName: 'Test', file: imagePath, }; - socketGroups.cover.update({uid: adminUid}, data, function (err, data) { + socketGroups.cover.update({ uid: adminUid }, data, function (err, data) { assert.ifError(err); Groups.getGroupFields('Test', ['cover:url'], function (err, groupData) { assert.ifError(err); @@ -756,7 +756,7 @@ describe('Groups', function () { groupName: 'Test', imageData: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAgCAYAAAABtRhCAAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAACcJJREFUeNqMl9tvnNV6xn/f+s5z8DCeg88Zj+NYdhJH4KShFoJAIkzVphLVJnsDaiV6gUKaC2qQUFVATbnoValAakuQYKMqBKUUJCgI9XBBSmOROMqGoCStHbA9sWM7nrFn/I3n9B17kcwoabfarj9gvet53+d9nmdJAwMDAAgh8DyPtbU1XNfFMAwkScK2bTzPw/M8dF1/SAhxKAiCxxVF2aeqqqTr+q+Af+7o6Ch0d3f/69TU1KwkSRiGwbFjx3jmmWd47rnn+OGHH1BVFYX/5QRBkPQ87xeSJP22YRi/oapqStM0PM/D931kWSYIgnHf98cXFxepVqtomjZt2/Zf2bb990EQ4Pv+PXfeU1CSpGYhfN9/TgjxQTQaJQgCwuEwQRBQKpUwDAPTNPF9n0ajAYDv+8zPzzM+Pr6/Wq2eqdVqfxOJRA6Zpnn57hrivyEC0IQQZ4Mg+MAwDCKRCJIkUa/XEUIQi8XQNI1QKIQkSQghUBQFIQSmaTI7OwtAuVxOTE9Pfzc9Pf27lUqlBUgulUoUi0VKpRKqqg4EQfAfiqLsDIfDAC0E4XCYaDSKEALXdalUKvfM1/d9hBBYlkUul2N4eJi3335bcl33mW+++aaUz+cvSJKE8uKLL6JpGo7j8Omnn/7d+vp6sr+/HyEEjuMgyzKu6yJJEsViEVVV8TyPjY2NVisV5fZkTNMkkUhw8+ZN6vU6Kysr7Nmzh9OnT7/12GOPDS8sLByT7rQR4A9XV1d/+cILLzA9PU0kEmF4eBhFUTh//jyWZaHrOkII0uk0jUaDWq1GJpOhWCyysrLC1tYWnuehqir79+9H13W6urp48803+f7773n++ef/4G7S/H4ikUCSJNbX11trcuvWLcrlMrIs4zgODzzwABMTE/i+T7lcpq2tjUqlwubmJrZts7y8jBCCkZERGo0G2WyWkydPkkql6Onp+eMmwihwc3JyMvrWW2+RTCYBcF0XWZbRdZ3l5WX27NnD008/TSwWQ1VVyuVy63GhUIhEIkEqlcJxHCzLIhaLMTQ0xJkzZ7Btm3379lmS53kIIczZ2dnFsbGxRK1Wo729HQDP8zAMg5WVFXp7e5mcnKSzs5N8Po/rutTrdVzXbQmHrutEo1FM00RVVXp7e0kkEgRBwMWLF9F1vaxUq1UikUjtlVdeuV6pVBJ9fX3Ytn2bwrLMysoKXV1dTE5OkslksCwLTdMwDANVVdnY2CAIApLJJJFIBMdxiMfj7Nq1C1VViUajLQCvvvrqkhKJRJiZmfmdb7/99jeTySSyLLfWodFoEAqFOH78OLt37yaXy2GaJoqisLy8zNTUFFevXiUIAtrb29m5cyePPPJIa+cymQz1eh2A0dFRCoXCsgIwNTW1J5/P093dTbFYRJZlJEmiWq1y4MABxsbGqNVqhEIh6vU6QRBQLpcxDIPh4WE8z2NxcZFTp05x7tw5Xn755ZY6dXZ2tliZzWa/EwD1ev3RsbExxsfHSafTVCoVGo0Gqqqya9cuIpEIQgh832dtbY3FxUUA+vr62LZtG2NjYxw5coTDhw+ztLTEyZMnuXr1KoVC4R4d3bt375R84sQJEY/H/2Jubq7N9326urqwbZt6vY5pmhw5coS+vr4W9YvFIrdu3WJqagohBFeuXOHcuXOtue7evRtN01rtfO+991haWmJkZGQrkUi8JIC9iqL0BkFAIpFACMETTzxBV1cXiUSC7u5uHMfB8zyCIMA0TeLxONlsFlmW8X2fwcFBHMdhfn6eer1Oe3s7Dz30EBMTE1y6dImjR49y6tSppR07dqwrjuM8+OWXXzI0NMTly5e5du0aQ0NDTExMkMvlCIKAIAhaIh2LxQiHw0QiEfL5POl0mlqtRq1Wo6OjA8uykGWZdDrN0tISvb29vPPOOzz++OPk83lELpf7rXfffRfDMOjo6MBxHEqlEocOHWLHjh00Gg0kSULTNIS4bS6qqhKPxxkaGmJ4eJjR0VH279/PwMAA27dvJ5vN4vs+X331FR9//DGzs7OEQiE++eQTlPb29keuX7/OtWvXOH78ONVqlZs3b9LW1kYmk8F13dZeCiGQJAnXdRFCYBgGsiwjhMC2bQqFAkEQoOs6P/74Iw8++CCDg4Pous6xY8f47LPPkIIguDo2Nrbzxo0bfPjhh9i2zczMTHNvcF2XpsZalkWj0cB1Xe4o1O3YoCisra3x008/EY/H6erqAuDAgQNEIhGCIODQoUP/ubCwMCKAjx599FHW19f56KOP6OjooFgsks/niUajKIqCbds4joMQAiFESxxs226xd2Zmhng8Tl9fH67r0mg0sG2bbDZLpVIhl8vd5gHwtysrKy8Dcdd1mZubo6enh1gsRrVabZlrk6VND/R9n3q9TqVSQdd1QqEQi4uLnD9/nlKpxODgIHv37gXAcRyCICiFQiHEzp07i1988cUfKYpCIpHANE22b9/eUhNFUVotDIKghc7zPCzLolKpsLW1RVtbG0EQ4DgOmqbR09NDM1qUSiWAPwdQ7ujjmf7+/kQymfxrSZJQVZWtra2WG+i63iKH53m4rku1WqVcLmNZFu3t7S2x7+/vJ51O89prr7VYfenSpcPAP1UqFeSHH36YeDxOKpW6eP/9988Bv9d09nw+T7VapVKptJjZnE2tVmNtbY1cLke5XGZra4vNzU16enp49tlnGRgYaD7iTxqNxgexWIzDhw+jNEPQHV87NT8/f+PChQtnR0ZGqFarrUVuOsDds2u2b2FhgVQqRSQSYWFhgStXrtDf308ymcwBf3nw4EEOHjx4O5c2lURVVRzHYXp6+t8uX7785IULFz7LZDLous59991HOBy+h31N9xgdHSWTyVCtVhkaGmLfvn1MT08zPz/PzMzM6c8//9xr+uE9QViWZer1OhsbGxiG8fns7OzPc7ncx729vXR3d1OpVNi2bRuhUAhZljEMA9/3sW0bVVVZWlri4sWLjI+P8/rrr/P111/z5JNPXrIs69cn76ZeGoaBpmm0tbX9Q6FQeHhubu7fC4UCkUiE1dVVstks8Xgc0zSRZZlGo9ESAdM02djYoNFo8MYbb2BZ1mYoFOKuZPjr/xZBEHCHred83x/b3Nz8l/X19aRlWWxsbNDZ2cnw8DDhcBjf96lWq/T09HD06FGeeuopXnrpJc6ePUs6nb4hhPi/C959ZFn+TtO0lG3bJ0ql0p85jsPW1haFQoG2tjYkSWpF/Uwmw9raGu+//z7A977vX2+GrP93wSZiTdNOGIbxy3K5/DPHcfYXCoVe27Yzpmm2m6bppVKp/Orqqnv69OmoZVn/mEwm/9TzvP9x138NAMpJ4VFTBr6SAAAAAElFTkSuQmCC', }; - socketGroups.cover.update({uid: adminUid}, data, function (err, data) { + socketGroups.cover.update({ uid: adminUid }, data, function (err, data) { assert.ifError(err); Groups.getGroupFields('Test', ['cover:url'], function (err, groupData) { assert.ifError(err); @@ -771,7 +771,7 @@ describe('Groups', function () { groupName: 'Test', position: '50% 50%', }; - socketGroups.cover.update({uid: adminUid}, data, function (err) { + socketGroups.cover.update({ uid: adminUid }, data, function (err) { assert.ifError(err); Groups.getGroupFields('Test', ['cover:position'], function (err, groupData) { assert.ifError(err); @@ -791,7 +791,7 @@ describe('Groups', function () { it('should error if user is not owner of group', function (done) { helpers.loginUser('regularuser', '123456', function (err, jar, io, csrf_token) { assert.ifError(err); - helpers.uploadFile(nconf.get('url') + '/api/groups/uploadpicture', logoPath, {params: JSON.stringify({groupName: 'Test'})}, jar, csrf_token, function (err, res, body) { + helpers.uploadFile(nconf.get('url') + '/api/groups/uploadpicture', logoPath, { params: JSON.stringify({ groupName: 'Test' }) }, jar, csrf_token, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 500); assert.equal(body.error, '[[error:no-privileges]]'); @@ -803,7 +803,7 @@ describe('Groups', function () { it('should upload group cover with api route', function (done) { helpers.loginUser('admin', '123456', function (err, jar, io, csrf_token) { assert.ifError(err); - helpers.uploadFile(nconf.get('url') + '/api/groups/uploadpicture', logoPath, {params: JSON.stringify({groupName: 'Test'})}, jar, csrf_token, function (err, res, body) { + helpers.uploadFile(nconf.get('url') + '/api/groups/uploadpicture', logoPath, { params: JSON.stringify({ groupName: 'Test' }) }, jar, csrf_token, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); Groups.getGroupFields('Test', ['cover:url'], function (err, groupData) { @@ -816,14 +816,14 @@ describe('Groups', function () { }); it('should fail to remove cover if not owner', function (done) { - socketGroups.cover.remove({uid: regularUid}, {groupName: 'Test'}, function (err) { + socketGroups.cover.remove({ uid: regularUid }, { groupName: 'Test' }, function (err) { assert.equal(err.message, '[[error:no-privileges]]'); done(); }); }); it('should remove cover', function (done) { - socketGroups.cover.remove({uid: adminUid}, {groupName: 'Test'}, function (err) { + socketGroups.cover.remove({ uid: adminUid }, { groupName: 'Test' }, function (err) { assert.ifError(err); Groups.getGroupFields('Test', ['cover:url'], function (err, groupData) { assert.ifError(err); diff --git a/test/helpers/index.js b/test/helpers/index.js index 0edb10a4a0..1cf5aca5bd 100644 --- a/test/helpers/index.js +++ b/test/helpers/index.js @@ -45,7 +45,7 @@ helpers.loginUser = function (username, password, callback) { var socketClient = require('socket.io-client'); - var io = socketClient.connect(nconf.get('url'), {forceNew: true, multiplex: false}); + var io = socketClient.connect(nconf.get('url'), { forceNew: true, multiplex: false }); io.on('connect', function () { callback(null, jar, io, body.csrf_token); }); @@ -77,7 +77,7 @@ helpers.initSocketIO = function (callback) { }; }; - var io = require('socket.io-client')(nconf.get('url'), {forceNew: true}); + var io = require('socket.io-client')(nconf.get('url'), { forceNew: true }); io.on('connect', function () { callback(null, jar, io); diff --git a/test/messaging.js b/test/messaging.js index 76c05b3a1f..879bdda209 100644 --- a/test/messaging.js +++ b/test/messaging.js @@ -80,7 +80,7 @@ describe('Messaging Library', function () { describe('rooms', function () { var socketModules = require('../src/socket.io/modules'); it('should create a new chat room', function (done) { - socketModules.chats.newRoom({uid: fooUid}, {touid: bazUid}, function (err, _roomId) { + socketModules.chats.newRoom({ uid: fooUid }, { touid: bazUid }, function (err, _roomId) { roomId = _roomId; assert.ifError(err); assert(roomId); @@ -89,14 +89,14 @@ describe('Messaging Library', function () { }); it('should add a user to room', function (done) { - socketModules.chats.addUserToRoom({uid: fooUid}, {roomId: roomId, username: 'herp'}, function (err) { + socketModules.chats.addUserToRoom({ uid: fooUid }, { roomId: roomId, username: 'herp' }, function (err) { assert.ifError(err); done(); }); }); it('should leave the chat room', function (done) { - socketModules.chats.leave({uid: bazUid}, roomId, function (err) { + socketModules.chats.leave({ uid: bazUid }, roomId, function (err) { assert.ifError(err); Messaging.isUserInRoom(bazUid, roomId, function (err, isUserInRoom) { assert.ifError(err); @@ -107,13 +107,13 @@ describe('Messaging Library', function () { }); it('should send a message to a room', function (done) { - socketModules.chats.send({uid: fooUid}, {roomId: roomId, message: 'first chat message'}, function (err, messageData) { + socketModules.chats.send({ uid: fooUid }, { roomId: roomId, message: 'first chat message' }, function (err, messageData) { assert.ifError(err); assert(messageData); assert.equal(messageData.content, 'first chat message'); assert(messageData.fromUser); assert(messageData.roomId, roomId); - socketModules.chats.getRaw({uid: fooUid}, {roomId: roomId, mid: messageData.mid}, function (err, raw) { + socketModules.chats.getRaw({ uid: fooUid }, { roomId: roomId, mid: messageData.mid }, function (err, raw) { assert.ifError(err); assert.equal(raw, 'first chat message'); done(); @@ -122,7 +122,7 @@ describe('Messaging Library', function () { }); it('should get messages from room', function (done) { - socketModules.chats.getMessages({uid: fooUid}, { + socketModules.chats.getMessages({ uid: fooUid }, { uid: fooUid, roomId: roomId, start: 0, @@ -136,21 +136,21 @@ describe('Messaging Library', function () { }); it('should mark room read', function (done) { - socketModules.chats.markRead({uid: fooUid}, roomId, function (err) { + socketModules.chats.markRead({ uid: fooUid }, roomId, function (err) { assert.ifError(err); done(); }); }); it('should mark all rooms read', function (done) { - socketModules.chats.markAllRead({uid: fooUid}, {}, function (err) { + socketModules.chats.markAllRead({ uid: fooUid }, {}, function (err) { assert.ifError(err); done(); }); }); it('should rename room', function (done) { - socketModules.chats.renameRoom({uid: fooUid}, {roomId: roomId, newName: 'new room name'}, function (err) { + socketModules.chats.renameRoom({ uid: fooUid }, { roomId: roomId, newName: 'new room name' }, function (err) { assert.ifError(err); done(); @@ -158,7 +158,7 @@ describe('Messaging Library', function () { }); it('should load chat room', function (done) { - socketModules.chats.loadRoom({uid: fooUid}, {roomId: roomId}, function (err, data) { + socketModules.chats.loadRoom({ uid: fooUid }, { roomId: roomId }, function (err, data) { assert.ifError(err); assert(data); assert.equal(data.roomName, 'new room name'); @@ -171,7 +171,7 @@ describe('Messaging Library', function () { var socketModules = require('../src/socket.io/modules'); var mid; before(function (done) { - socketModules.chats.send({uid: fooUid}, {roomId: roomId, message: 'first chat message'}, function (err, messageData) { + socketModules.chats.send({ uid: fooUid }, { roomId: roomId, message: 'first chat message' }, function (err, messageData) { assert.ifError(err); mid = messageData.mid; done(); @@ -179,9 +179,9 @@ describe('Messaging Library', function () { }); it('should edit message', function (done) { - socketModules.chats.edit({uid: fooUid}, {mid: mid, roomId: roomId, message: 'message edited'}, function (err) { + socketModules.chats.edit({ uid: fooUid }, { mid: mid, roomId: roomId, message: 'message edited' }, function (err) { assert.ifError(err); - socketModules.chats.getRaw({uid: fooUid}, {roomId: roomId, mid: mid}, function (err, raw) { + socketModules.chats.getRaw({ uid: fooUid }, { roomId: roomId, mid: mid }, function (err, raw) { assert.ifError(err); assert.equal(raw, 'message edited'); done(); @@ -190,7 +190,7 @@ describe('Messaging Library', function () { }); it('should delete message', function (done) { - socketModules.chats.delete({uid: fooUid}, {messageId: mid, roomId: roomId}, function (err) { + socketModules.chats.delete({ uid: fooUid }, { messageId: mid, roomId: roomId }, function (err) { assert.ifError(err); db.exists('message:' + mid, function (err, exists) { assert.ifError(err); @@ -240,7 +240,7 @@ describe('Messaging Library', function () { }); it('should return chats page data', function (done) { - request(nconf.get('url') + '/api/user/herp/chats', {json: true, jar: jar}, function (err, response, body) { + request(nconf.get('url') + '/api/user/herp/chats', { json: true, jar: jar }, function (err, response, body) { assert.ifError(err); assert.equal(response.statusCode, 200); assert(Array.isArray(body.rooms)); @@ -251,7 +251,7 @@ describe('Messaging Library', function () { }); it('should return room data', function (done) { - request(nconf.get('url') + '/api/user/herp/chats/' + roomId, {json: true, jar: jar}, function (err, response, body) { + request(nconf.get('url') + '/api/user/herp/chats/' + roomId, { json: true, jar: jar }, function (err, response, body) { assert.ifError(err); assert.equal(response.statusCode, 200); assert.equal(body.roomId, roomId); @@ -261,7 +261,7 @@ describe('Messaging Library', function () { }); it('should redirect to chats page', function (done) { - request(nconf.get('url') + '/api/chats', {jar: jar}, function (err, response, body) { + request(nconf.get('url') + '/api/chats', { jar: jar }, function (err, response, body) { assert.ifError(err); assert.equal(body, '"/user/herp/chats"'); assert.equal(response.statusCode, 308); @@ -272,7 +272,7 @@ describe('Messaging Library', function () { it('should return 404 if user is not in room', function (done) { helpers.loginUser('baz', 'quuxquux', function (err, jar) { assert.ifError(err); - request(nconf.get('url') + '/api/user/baz/chats/' + roomId, {json: true, jar: jar}, function (err, response, body) { + request(nconf.get('url') + '/api/user/baz/chats/' + roomId, { json: true, jar: jar }, function (err, response, body) { assert.ifError(err); assert.equal(response.statusCode, 404); done(); diff --git a/test/meta.js b/test/meta.js index 5d9284030c..9d1a69b00c 100644 --- a/test/meta.js +++ b/test/meta.js @@ -36,7 +36,7 @@ describe('meta', function () { describe('settings', function () { var socketAdmin = require('../src/socket.io/admin'); it('it should set setting', function (done) { - socketAdmin.settings.set({uid: fooUid}, {hash: 'some:hash', values: {foo: '1', derp: 'value'}}, function (err) { + socketAdmin.settings.set({ uid: fooUid }, { hash: 'some:hash', values: { foo: '1', derp: 'value' } }, function (err) { assert.ifError(err); db.getObject('settings:some:hash', function (err, data) { assert.ifError(err); @@ -48,7 +48,7 @@ describe('meta', function () { }); it('it should get setting', function (done) { - socketAdmin.settings.get({uid: fooUid}, {hash: 'some:hash'}, function (err, data) { + socketAdmin.settings.get({ uid: fooUid }, { hash: 'some:hash' }, function (err, data) { assert.ifError(err); assert.equal(data.foo, '1'); assert.equal(data.derp, 'value'); @@ -57,7 +57,7 @@ describe('meta', function () { }); it('should not set setting if not empty', function (done) { - meta.settings.setOnEmpty('some:hash', {foo: 2}, function (err) { + meta.settings.setOnEmpty('some:hash', { foo: 2 }, function (err) { assert.ifError(err); db.getObject('settings:some:hash', function (err, data) { assert.ifError(err); @@ -69,7 +69,7 @@ describe('meta', function () { }); it('should set setting if empty', function (done) { - meta.settings.setOnEmpty('some:hash', {empty: '2'}, function (err) { + meta.settings.setOnEmpty('some:hash', { empty: '2' }, function (err) { assert.ifError(err); db.getObject('settings:some:hash', function (err, data) { assert.ifError(err); @@ -97,7 +97,7 @@ describe('meta', function () { describe('config', function () { var socketAdmin = require('../src/socket.io/admin'); before(function (done) { - db.setObject('config', {minimumTagLength: 3, maximumTagLength: 15}, done); + db.setObject('config', { minimumTagLength: 3, maximumTagLength: 15 }, done); }); it('should get config fields', function (done) { @@ -117,7 +117,7 @@ describe('meta', function () { }); it('should fail if data is invalid', function (done) { - socketAdmin.config.set({uid: fooUid}, null, function (err) { + socketAdmin.config.set({ uid: fooUid }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); @@ -135,14 +135,14 @@ describe('meta', function () { }); it('should fail if data is invalid', function (done) { - socketAdmin.config.setMultiple({uid: fooUid}, null, function (err) { + socketAdmin.config.setMultiple({ uid: fooUid }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should set multiple values', function (done) { - socketAdmin.config.setMultiple({uid: fooUid}, { + socketAdmin.config.setMultiple({ uid: fooUid }, { someField1: 'someValue1', someField2: 'someValue2', customCSS: '.derp{color:#00ff00;}', @@ -158,7 +158,7 @@ describe('meta', function () { }); it('should not set config if not empty', function (done) { - meta.configs.setOnEmpty({someField1: 'foo'}, function (err) { + meta.configs.setOnEmpty({ someField1: 'foo' }, function (err) { assert.ifError(err); db.getObjectField('config', 'someField1', function (err, value) { assert.ifError(err); @@ -169,7 +169,7 @@ describe('meta', function () { }); it('should remove config field', function (done) { - socketAdmin.config.remove({uid: fooUid}, 'someField1', function (err) { + socketAdmin.config.remove({ uid: fooUid }, 'someField1', function (err) { assert.ifError(err); db.isObjectField('config', 'someField1', function (err, isObjectField) { assert.ifError(err); diff --git a/test/notifications.js b/test/notifications.js index e0a856b961..f21d46cf32 100644 --- a/test/notifications.js +++ b/test/notifications.js @@ -14,7 +14,7 @@ describe('Notifications', function () { var notification; before(function (done) { - user.create({username: 'poster'}, function (err, _uid) { + user.create({ username: 'poster' }, function (err, _uid) { if (err) { return done(err); } @@ -95,7 +95,7 @@ describe('Notifications', function () { }); it('should mark a notification read', function (done) { - socketNotifications.markRead({uid: uid}, notification.nid, function (err) { + socketNotifications.markRead({ uid: uid }, notification.nid, function (err) { assert.ifError(err); db.isSortedSetMember('uid:' + uid + ':notifications:unread', notification.nid, function (err, isMember) { assert.ifError(err); @@ -110,7 +110,7 @@ describe('Notifications', function () { }); it('should mark a notification unread', function (done) { - socketNotifications.markUnread({uid: uid}, notification.nid, function (err) { + socketNotifications.markUnread({ uid: uid }, notification.nid, function (err) { assert.ifError(err); db.isSortedSetMember('uid:' + uid + ':notifications:unread', notification.nid, function (err, isMember) { assert.ifError(err); @@ -118,7 +118,7 @@ describe('Notifications', function () { db.isSortedSetMember('uid:' + uid + ':notifications:read', notification.nid, function (err, isMember) { assert.ifError(err); assert.equal(isMember, false); - socketNotifications.getCount({uid: uid}, null, function (err, count) { + socketNotifications.getCount({ uid: uid }, null, function (err, count) { assert.ifError(err); assert.equal(count, 1); done(); @@ -129,7 +129,7 @@ describe('Notifications', function () { }); it('should mark all notifications read', function (done) { - socketNotifications.markAllRead({uid: uid}, null, function (err) { + socketNotifications.markAllRead({ uid: uid }, null, function (err) { assert.ifError(err); db.isSortedSetMember('uid:' + uid + ':notifications:unread', notification.nid, function (err, isMember) { assert.ifError(err); @@ -154,7 +154,7 @@ describe('Notifications', function () { async.waterfall([ function (next) { - user.create({username: 'watcher'}, next); + user.create({ username: 'watcher' }, next); }, function (_watcherUid, next) { watcherUid = _watcherUid; @@ -214,7 +214,7 @@ describe('Notifications', function () { }); it('should get notification by nid', function (done) { - socketNotifications.get({uid: uid}, {nids: [notification.nid]}, function (err, data) { + socketNotifications.get({ uid: uid }, { nids: [notification.nid] }, function (err, data) { assert.ifError(err); assert.equal(data[0].bodyShort, 'bodyShort'); assert.equal(data[0].nid, 'notification_id'); @@ -224,7 +224,7 @@ describe('Notifications', function () { }); it('should get user\'s notifications', function (done) { - socketNotifications.get({uid: uid}, {}, function (err, data) { + socketNotifications.get({ uid: uid }, {}, function (err, data) { assert.ifError(err); assert.equal(data.unread.length, 0); assert.equal(data.read[0].nid, 'notification_id'); @@ -233,21 +233,21 @@ describe('Notifications', function () { }); it('should error with invalid data', function (done) { - socketNotifications.loadMore({uid: uid}, {after: 'test'}, function (err) { + socketNotifications.loadMore({ uid: uid }, { after: 'test' }, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should error if not logged in', function (done) { - socketNotifications.loadMore({uid: 0}, {after: 10}, function (err) { + socketNotifications.loadMore({ uid: 0 }, { after: 10 }, function (err) { assert.equal(err.message, '[[error:no-privileges]]'); done(); }); }); it('should load more notifications', function (done) { - socketNotifications.loadMore({uid: uid}, {after: 0}, function (err, data) { + socketNotifications.loadMore({ uid: uid }, { after: 0 }, function (err, data) { assert.ifError(err); assert.equal(data.notifications[0].bodyShort, 'bodyShort'); assert.equal(data.notifications[0].nid, 'notification_id'); @@ -258,16 +258,16 @@ describe('Notifications', function () { it('should error if not logged in', function (done) { - socketNotifications.deleteAll({uid: 0}, null, function (err) { + socketNotifications.deleteAll({ uid: 0 }, null, function (err) { assert.equal(err.message, '[[error:no-privileges]]'); done(); }); }); it('should delete all user notifications', function (done) { - socketNotifications.deleteAll({uid: uid}, null, function (err) { + socketNotifications.deleteAll({ uid: uid }, null, function (err) { assert.ifError(err); - socketNotifications.get({uid: uid}, {}, function (err, data) { + socketNotifications.get({ uid: uid }, {}, function (err, data) { assert.ifError(err); assert.equal(data.unread.length, 0); assert.equal(data.read.length, 0); diff --git a/test/pagination.js b/test/pagination.js index 8ca2cdf586..30f79a718e 100644 --- a/test/pagination.js +++ b/test/pagination.js @@ -27,7 +27,7 @@ describe('Pagination', function () { }); it('should create pagination for 3 pages with query params', function (done) { - var data = pagination.create(1, 3, {key: 'value'}); + var data = pagination.create(1, 3, { key: 'value' }); assert.equal(data.pages.length, 3); assert.equal(data.rel.length, 1); assert.equal(data.pageCount, 3); diff --git a/test/plugins.js b/test/plugins.js index a9936ba819..97a9c1908b 100644 --- a/test/plugins.js +++ b/test/plugins.js @@ -37,10 +37,10 @@ describe('Plugins', function () { callback(null, data); } - plugins.registerHook('test-plugin', {hook: 'filter:test.hook', method: filterMethod1}); - plugins.registerHook('test-plugin', {hook: 'filter:test.hook', method: filterMethod2}); + plugins.registerHook('test-plugin', { hook: 'filter:test.hook', method: filterMethod1 }); + plugins.registerHook('test-plugin', { hook: 'filter:test.hook', method: filterMethod2 }); - plugins.fireHook('filter:test.hook', {foo: 1}, function (err, data) { + plugins.fireHook('filter:test.hook', { foo: 1 }, function (err, data) { assert.ifError(err); assert.equal(data.foo, 7); done(); @@ -53,8 +53,8 @@ describe('Plugins', function () { done(); } - plugins.registerHook('test-plugin', {hook: 'action:test.hook', method: actionMethod}); - plugins.fireHook('action:test.hook', {bar: 'test'}); + plugins.registerHook('test-plugin', { hook: 'action:test.hook', method: actionMethod }); + plugins.fireHook('action:test.hook', { bar: 'test' }); }); it('should register and fire a static hook', function (done) { @@ -63,8 +63,8 @@ describe('Plugins', function () { callback(); } - plugins.registerHook('test-plugin', {hook: 'static:test.hook', method: actionMethod}); - plugins.fireHook('static:test.hook', {bar: 'test'}, function (err) { + plugins.registerHook('test-plugin', { hook: 'static:test.hook', method: actionMethod }); + plugins.fireHook('static:test.hook', { bar: 'test' }, function (err) { assert.ifError(err); done(); }); diff --git a/test/posts.js b/test/posts.js index 646182fdeb..2c21178801 100644 --- a/test/posts.js +++ b/test/posts.js @@ -24,13 +24,13 @@ describe('Post\'s', function () { groups.resetCache(); async.series({ voterUid: function (next) { - user.create({username: 'upvoter'}, next); + user.create({ username: 'upvoter' }, next); }, voteeUid: function (next) { - user.create({username: 'upvotee'}, next); + user.create({ username: 'upvotee' }, next); }, globalModUid: function (next) { - user.create({username: 'globalmod'}, next); + user.create({ username: 'globalmod' }, next); }, category: function (next) { categories.create({ @@ -68,7 +68,7 @@ describe('Post\'s', function () { describe('voting', function () { var socketPosts = require('../src/socket.io/posts'); it('should upvote a post', function (done) { - socketPosts.upvote({uid: voterUid}, {pid: postData.pid, room_id: 'topic_1'}, function (err, result) { + socketPosts.upvote({ uid: voterUid }, { pid: postData.pid, room_id: 'topic_1' }, function (err, result) { assert.ifError(err); assert.equal(result.post.upvotes, 1); assert.equal(result.post.downvotes, 0); @@ -84,7 +84,7 @@ describe('Post\'s', function () { }); it('should get voters', function (done) { - socketPosts.getVoters({uid: globalModUid}, {pid: postData.pid, cid: cid}, function (err, data) { + socketPosts.getVoters({ uid: globalModUid }, { pid: postData.pid, cid: cid }, function (err, data) { assert.ifError(err); assert.equal(data.upvoteCount, 1); assert.equal(data.downvoteCount, 0); @@ -95,7 +95,7 @@ describe('Post\'s', function () { }); it('should get upvoters', function (done) { - socketPosts.getUpvoters({uid: globalModUid}, [postData.pid], function (err, data) { + socketPosts.getUpvoters({ uid: globalModUid }, [postData.pid], function (err, data) { assert.ifError(err); assert.equal(data[0].otherCount, 0); assert.equal(data[0].usernames, 'upvoter'); @@ -104,7 +104,7 @@ describe('Post\'s', function () { }); it('should unvote a post', function (done) { - socketPosts.unvote({uid: voterUid}, {pid: postData.pid, room_id: 'topic_1'}, function (err, result) { + socketPosts.unvote({ uid: voterUid }, { pid: postData.pid, room_id: 'topic_1' }, function (err, result) { assert.ifError(err); assert.equal(result.post.upvotes, 0); assert.equal(result.post.downvotes, 0); @@ -120,7 +120,7 @@ describe('Post\'s', function () { }); it('should downvote a post', function (done) { - socketPosts.downvote({uid: voterUid}, {pid: postData.pid, room_id: 'topic_1'}, function (err, result) { + socketPosts.downvote({ uid: voterUid }, { pid: postData.pid, room_id: 'topic_1' }, function (err, result) { assert.ifError(err); assert.equal(result.post.upvotes, 0); assert.equal(result.post.downvotes, 1); @@ -166,14 +166,14 @@ describe('Post\'s', function () { var socketPosts = require('../src/socket.io/posts'); it('should error if data is invalid', function (done) { - socketPosts.loadPostTools({uid: globalModUid}, null, function (err) { + socketPosts.loadPostTools({ uid: globalModUid }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should load post tools', function (done) { - socketPosts.loadPostTools({uid: globalModUid}, {pid: postData.pid, cid: cid}, function (err, data) { + socketPosts.loadPostTools({ uid: globalModUid }, { pid: postData.pid, cid: cid }, function (err, data) { assert.ifError(err); assert(data.posts.display_edit_tools); assert(data.posts.display_delete_tools); @@ -220,14 +220,14 @@ describe('Post\'s', function () { }); it('should error with invalid data', function (done) { - socketPosts.delete({uid: voterUid}, null, function (err) { + socketPosts.delete({ uid: voterUid }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should delete a post', function (done) { - socketPosts.delete({uid: voterUid}, {pid: replyPid, tid: tid}, function (err) { + socketPosts.delete({ uid: voterUid }, { pid: replyPid, tid: tid }, function (err) { assert.ifError(err); posts.getPostField(replyPid, 'deleted', function (err, isDeleted) { assert.ifError(err); @@ -238,7 +238,7 @@ describe('Post\'s', function () { }); it('should restore a post', function (done) { - socketPosts.restore({uid: voterUid}, {pid: replyPid, tid: tid}, function (err) { + socketPosts.restore({ uid: voterUid }, { pid: replyPid, tid: tid }, function (err) { assert.ifError(err); posts.getPostField(replyPid, 'deleted', function (err, isDeleted) { assert.ifError(err); @@ -249,7 +249,7 @@ describe('Post\'s', function () { }); it('should delete posts', function (done) { - socketPosts.deletePosts({uid: globalModUid}, {pids: [replyPid, mainPid], tid: tid}, function (err) { + socketPosts.deletePosts({ uid: globalModUid }, { pids: [replyPid, mainPid], tid: tid }, function (err) { assert.ifError(err); posts.getPostField(replyPid, 'deleted', function (err, deleted) { assert.ifError(err); @@ -264,9 +264,9 @@ describe('Post\'s', function () { }); it('should delete topic if last main post is deleted', function (done) { - topics.post({uid: voterUid, cid: cid, title: 'test topic', content: 'test topic'}, function (err, data) { + topics.post({ uid: voterUid, cid: cid, title: 'test topic', content: 'test topic' }, function (err, data) { assert.ifError(err); - socketPosts.deletePosts({uid: globalModUid}, {pids: [data.postData.pid], tid: data.topicData.tid}, function (err) { + socketPosts.deletePosts({ uid: globalModUid }, { pids: [data.postData.pid], tid: data.topicData.tid }, function (err) { assert.ifError(err); topics.getTopicField(data.topicData.tid, 'deleted', function (err, deleted) { assert.ifError(err); @@ -279,7 +279,7 @@ describe('Post\'s', function () { it('should purge posts and delete topic', function (done) { createTopicWithReply(function (topicPostData, replyData) { - socketPosts.purgePosts({uid: voterUid}, {pids: [replyData.pid, topicPostData.postData.pid], tid: topicPostData.topicData.tid}, function (err) { + socketPosts.purgePosts({ uid: voterUid }, { pids: [replyData.pid, topicPostData.postData.pid], tid: topicPostData.topicData.tid }, function (err) { assert.ifError(err); posts.exists('post:' + replyData.pid, function (err, exists) { assert.ifError(err); @@ -325,21 +325,21 @@ describe('Post\'s', function () { }); it('should error if user is not logged in', function (done) { - socketPosts.edit({uid: 0}, {}, function (err) { + socketPosts.edit({ uid: 0 }, {}, function (err) { assert.equal(err.message, '[[error:not-logged-in]]'); done(); }); }); it('should error if data is invalid or missing', function (done) { - socketPosts.edit({uid: voterUid}, {}, function (err) { + socketPosts.edit({ uid: voterUid }, {}, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should error if title is too short', function (done) { - socketPosts.edit({uid: voterUid}, {pid: pid, content: 'edited post content', title: 'a'}, function (err) { + socketPosts.edit({ uid: voterUid }, { pid: pid, content: 'edited post content', title: 'a' }, function (err) { assert.equal(err.message, '[[error:title-too-short, ' + meta.config.minimumTitleLength + ']]'); done(); }); @@ -347,7 +347,7 @@ describe('Post\'s', function () { it('should error if title is too long', function (done) { var longTitle = new Array(parseInt(meta.config.maximumTitleLength, 10) + 2).join('a'); - socketPosts.edit({uid: voterUid}, {pid: pid, content: 'edited post content', title: longTitle}, function (err) { + socketPosts.edit({ uid: voterUid }, { pid: pid, content: 'edited post content', title: longTitle }, function (err) { assert.equal(err.message, '[[error:title-too-long, ' + meta.config.maximumTitleLength + ']]'); done(); }); @@ -356,7 +356,7 @@ describe('Post\'s', function () { it('should error with too few tags', function (done) { var oldValue = meta.config.minimumTagsPerTopic; meta.config.minimumTagsPerTopic = 1; - socketPosts.edit({uid: voterUid}, {pid: pid, content: 'edited post content', tags: []}, function (err) { + socketPosts.edit({ uid: voterUid }, { pid: pid, content: 'edited post content', tags: [] }, function (err) { assert.equal(err.message, '[[error:not-enough-tags, ' + meta.config.minimumTagsPerTopic + ']]'); meta.config.minimumTagsPerTopic = oldValue; done(); @@ -368,14 +368,14 @@ describe('Post\'s', function () { for (var i = 0; i < meta.config.maximumTagsPerTopic + 1; i += 1) { tags.push('tag' + i); } - socketPosts.edit({uid: voterUid}, {pid: pid, content: 'edited post content', tags: tags}, function (err) { + socketPosts.edit({ uid: voterUid }, { pid: pid, content: 'edited post content', tags: tags }, function (err) { assert.equal(err.message, '[[error:too-many-tags, ' + meta.config.maximumTagsPerTopic + ']]'); done(); }); }); it('should error if content is too short', function (done) { - socketPosts.edit({uid: voterUid}, {pid: pid, content: 'e'}, function (err) { + socketPosts.edit({ uid: voterUid }, { pid: pid, content: 'e' }, function (err) { assert.equal(err.message, '[[error:content-too-short, ' + meta.config.minimumPostLength + ']]'); done(); }); @@ -383,14 +383,14 @@ describe('Post\'s', function () { it('should error if content is too long', function (done) { var longContent = new Array(parseInt(meta.config.maximumPostLength, 10) + 2).join('a'); - socketPosts.edit({uid: voterUid}, {pid: pid, content: longContent}, function (err) { + socketPosts.edit({ uid: voterUid }, { pid: pid, content: longContent }, function (err) { assert.equal(err.message, '[[error:content-too-long, ' + meta.config.maximumPostLength + ']]'); done(); }); }); it('should edit post', function (done) { - socketPosts.edit({uid: voterUid}, {pid: pid, content: 'edited post content', title: 'edited title', tags: ['edited']}, function (err, data) { + socketPosts.edit({ uid: voterUid }, { pid: pid, content: 'edited post content', title: 'edited title', tags: ['edited'] }, function (err, data) { assert.ifError(err); assert.equal(data.content, 'edited post content'); assert.equal(data.editor, voterUid); @@ -401,9 +401,9 @@ describe('Post\'s', function () { }); it('should edit a deleted post', function (done) { - socketPosts.delete({uid: voterUid}, {pid: pid, tid: tid}, function (err) { + socketPosts.delete({ uid: voterUid }, { pid: pid, tid: tid }, function (err) { assert.ifError(err); - socketPosts.edit({uid: voterUid}, {pid: pid, content: 'edited deleted content', title: 'edited deleted title', tags: ['deleted']}, function (err, data) { + socketPosts.edit({ uid: voterUid }, { pid: pid, content: 'edited deleted content', title: 'edited deleted title', tags: ['deleted'] }, function (err, data) { assert.ifError(err); assert.equal(data.content, 'edited deleted content'); assert.equal(data.editor, voterUid); @@ -415,7 +415,7 @@ describe('Post\'s', function () { }); it('should edit a reply post', function (done) { - socketPosts.edit({uid: voterUid}, {pid: replyPid, content: 'edited reply'}, function (err, data) { + socketPosts.edit({ uid: voterUid }, { pid: replyPid, content: 'edited reply' }, function (err, data) { assert.ifError(err); assert.equal(data.content, 'edited reply'); assert.equal(data.editor, voterUid); @@ -468,21 +468,21 @@ describe('Post\'s', function () { }); it('should error if uid is not logged in', function (done) { - socketPosts.movePost({uid: 0}, {}, function (err) { + socketPosts.movePost({ uid: 0 }, {}, function (err) { assert.equal(err.message, '[[error:not-logged-in]]'); done(); }); }); it('should error if data is invalid', function (done) { - socketPosts.movePost({uid: globalModUid}, {}, function (err) { + socketPosts.movePost({ uid: globalModUid }, {}, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should error if user does not have move privilege', function (done) { - socketPosts.movePost({uid: voterUid}, {pid: replyPid, tid: moveTid}, function (err) { + socketPosts.movePost({ uid: voterUid }, { pid: replyPid, tid: moveTid }, function (err) { assert.equal(err.message, '[[error:no-privileges]]'); done(); }); @@ -490,7 +490,7 @@ describe('Post\'s', function () { it('should move a post', function (done) { - socketPosts.movePost({uid: globalModUid}, {pid: replyPid, tid: moveTid}, function (err) { + socketPosts.movePost({ uid: globalModUid }, { pid: replyPid, tid: moveTid }, function (err) { assert.ifError(err); posts.getPostField(replyPid, 'tid', function (err, tid) { assert.ifError(err); @@ -521,9 +521,9 @@ describe('Post\'s', function () { }); it('should return nothing without a uid or a reason', function (done) { - socketPosts.flag({uid: 0}, {pid: postData.pid, reason: 'reason'}, function (err) { + socketPosts.flag({ uid: 0 }, { pid: postData.pid, reason: 'reason' }, function (err) { assert.equal(err.message, '[[error:not-logged-in]]'); - socketPosts.flag({uid: voteeUid}, {}, function (err) { + socketPosts.flag({ uid: voteeUid }, {}, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); @@ -531,14 +531,14 @@ describe('Post\'s', function () { }); it('should return an error without an existing post', function (done) { - socketPosts.flag({uid: voteeUid}, {pid: 12312312, reason: 'reason'}, function (err) { + socketPosts.flag({ uid: voteeUid }, { pid: 12312312, reason: 'reason' }, function (err) { assert.equal(err.message, '[[error:no-post]]'); done(); }); }); it('should return an error if the flag already exists', function (done) { - socketPosts.flag({uid: voteeUid}, {pid: postData.pid, reason: 'reason'}, function (err) { + socketPosts.flag({ uid: voteeUid }, { pid: postData.pid, reason: 'reason' }, function (err) { assert.equal(err.message, '[[error:already-flagged]]'); done(); }); @@ -547,7 +547,7 @@ describe('Post\'s', function () { function flagPost(next) { var socketPosts = require('../src/socket.io/posts'); - socketPosts.flag({uid: voteeUid}, {pid: postData.pid, reason: 'reason'}, next); + socketPosts.flag({ uid: voteeUid }, { pid: postData.pid, reason: 'reason' }, next); } describe('get flag data', function () { @@ -582,11 +582,11 @@ describe('Post\'s', function () { it('should update a flag', function (done) { async.waterfall([ function (next) { - socketPosts.updateFlag({uid: globalModUid}, { + socketPosts.updateFlag({ uid: globalModUid }, { pid: postData.pid, data: [ - {name: 'assignee', value: `${globalModUid}`}, - {name: 'notes', value: 'notes'}, + { name: 'assignee', value: `${globalModUid}` }, + { name: 'notes', value: 'notes' }, ], }, function (err) { assert.ifError(err); @@ -674,7 +674,7 @@ describe('Post\'s', function () { var socketPosts = require('../src/socket.io/posts'); it('should dismiss a flag', function (done) { - socketPosts.dismissFlag({uid: globalModUid}, postData.pid, function (err) { + socketPosts.dismissFlag({ uid: globalModUid }, postData.pid, function (err) { assert.ifError(err); posts.isFlaggedByUser(postData.pid, voteeUid, function (err, hasFlagged) { assert.ifError(err); @@ -702,7 +702,7 @@ describe('Post\'s', function () { }); it('should dismiss all flags', function (done) { - socketPosts.dismissAllFlags({uid: globalModUid}, {}, function (err) { + socketPosts.dismissAllFlags({ uid: globalModUid }, {}, function (err) { assert.ifError(err); posts.isFlaggedByUser(postData.pid, voteeUid, function (err, hasFlagged) { assert.ifError(err); diff --git a/test/rewards.js b/test/rewards.js index 8eabf6d4e2..67a00fe911 100644 --- a/test/rewards.js +++ b/test/rewards.js @@ -57,7 +57,7 @@ describe('rewards', function () { }, ]; - socketAdmin.rewards.save({uid: adminUid}, data, function (err) { + socketAdmin.rewards.save({ uid: adminUid }, data, function (err) { assert.ifError(err); done(); }); diff --git a/test/search.js b/test/search.js index e6b5c6d9cb..a18f6b3b41 100644 --- a/test/search.js +++ b/test/search.js @@ -29,10 +29,10 @@ describe('Search', function () { function (next) { async.series({ phoebe: function (next) { - user.create({username: 'phoebe'}, next); + user.create({ username: 'phoebe' }, next); }, ginger: function (next) { - user.create({username: 'ginger'}, next); + user.create({ username: 'ginger' }, next); }, category1: function (next) { categories.create({ diff --git a/test/socket.io.js b/test/socket.io.js index f5de533401..7cfbbdcb9d 100644 --- a/test/socket.io.js +++ b/test/socket.io.js @@ -28,7 +28,7 @@ describe('socket.io', function () { before(function (done) { async.series([ async.apply(user.create, { username: 'admin', password: 'adminpwd' }), - async.apply(user.create, { username: 'regular', password: 'regularpwd', email: 'regular@test.com'}), + async.apply(user.create, { username: 'regular', password: 'regularpwd', email: 'regular@test.com' }), async.apply(categories.create, { name: 'Test Category', description: 'Test category created by testing script', @@ -76,7 +76,7 @@ describe('socket.io', function () { }; }; - io = require('socket.io-client')(nconf.get('url'), {forceNew: true}); + io = require('socket.io-client')(nconf.get('url'), { forceNew: true }); io.on('connect', function () { done(); @@ -113,7 +113,7 @@ describe('socket.io', function () { }); it('should post a topic', function (done) { - io.emit('topics.post', {title: 'test topic title', content: 'test topic main post content', uid: adminUid, cid: cid}, function (err, result) { + io.emit('topics.post', { title: 'test topic title', content: 'test topic main post content', uid: adminUid, cid: cid }, function (err, result) { assert.ifError(err); assert.equal(result.user.username, 'admin'); assert.equal(result.category.cid, cid); @@ -124,7 +124,7 @@ describe('socket.io', function () { }); it('should reply to topic', function (done) { - io.emit('posts.reply', {tid: tid, uid: adminUid, content: 'test post content'}, function (err, result) { + io.emit('posts.reply', { tid: tid, uid: adminUid, content: 'test post content' }, function (err, result) { assert.ifError(err); assert.equal(result.uid, adminUid); assert.equal(result.user.username, 'admin'); @@ -135,7 +135,7 @@ describe('socket.io', function () { it('should ban a user', function (done) { var socketUser = require('../src/socket.io/user'); - socketUser.banUsers({uid: adminUid}, {uids: [regularUid], reason: 'spammer'}, function (err) { + socketUser.banUsers({ uid: adminUid }, { uids: [regularUid], reason: 'spammer' }, function (err) { assert.ifError(err); user.getLatestBanInfo(regularUid, function (err, data) { assert.ifError(err); @@ -159,7 +159,7 @@ describe('socket.io', function () { it('should unban a user', function (done) { var socketUser = require('../src/socket.io/user'); - socketUser.unbanUsers({uid: adminUid}, [regularUid], function (err) { + socketUser.unbanUsers({ uid: adminUid }, [regularUid], function (err) { assert.ifError(err); user.isBanned(regularUid, function (err, isBanned) { assert.ifError(err); @@ -171,7 +171,7 @@ describe('socket.io', function () { it('should make user admin', function (done) { var socketAdmin = require('../src/socket.io/admin'); - socketAdmin.user.makeAdmins({uid: adminUid}, [regularUid], function (err) { + socketAdmin.user.makeAdmins({ uid: adminUid }, [regularUid], function (err) { assert.ifError(err); groups.isMember(regularUid, 'administrators', function (err, isMember) { assert.ifError(err); @@ -183,7 +183,7 @@ describe('socket.io', function () { it('should make user non-admin', function (done) { var socketAdmin = require('../src/socket.io/admin'); - socketAdmin.user.removeAdmins({uid: adminUid}, [regularUid], function (err) { + socketAdmin.user.removeAdmins({ uid: adminUid }, [regularUid], function (err) { assert.ifError(err); groups.isMember(regularUid, 'administrators', function (err, isMember) { assert.ifError(err); @@ -197,7 +197,7 @@ describe('socket.io', function () { var socketAdmin = require('../src/socket.io/admin'); var uid; it('should create a user', function (done) { - socketAdmin.user.createUser({uid: adminUid}, {username: 'foo1'}, function (err, _uid) { + socketAdmin.user.createUser({ uid: adminUid }, { username: 'foo1' }, function (err, _uid) { assert.ifError(err); uid = _uid; groups.isMember(uid, 'registered-users', function (err, isMember) { @@ -209,7 +209,7 @@ describe('socket.io', function () { }); it('should delete users', function (done) { - socketAdmin.user.deleteUsers({uid: adminUid}, [uid], function (err) { + socketAdmin.user.deleteUsers({ uid: adminUid }, [uid], function (err) { assert.ifError(err); groups.isMember(uid, 'registered-users', function (err, isMember) { assert.ifError(err); @@ -220,7 +220,7 @@ describe('socket.io', function () { }); it('should delete users and their content', function (done) { - socketAdmin.user.deleteUsersAndContent({uid: adminUid}, [uid], function (err) { + socketAdmin.user.deleteUsersAndContent({ uid: adminUid }, [uid], function (err) { assert.ifError(err); done(); }); @@ -229,7 +229,7 @@ describe('socket.io', function () { it('should error with invalid data', function (done) { var socketAdmin = require('../src/socket.io/admin'); - socketAdmin.user.createUser({uid: adminUid}, null, function (err) { + socketAdmin.user.createUser({ uid: adminUid }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); @@ -237,7 +237,7 @@ describe('socket.io', function () { it('should reset lockouts', function (done) { var socketAdmin = require('../src/socket.io/admin'); - socketAdmin.user.resetLockouts({uid: adminUid}, [regularUid], function (err) { + socketAdmin.user.resetLockouts({ uid: adminUid }, [regularUid], function (err) { assert.ifError(err); done(); }); @@ -245,7 +245,7 @@ describe('socket.io', function () { it('should reset flags', function (done) { var socketAdmin = require('../src/socket.io/admin'); - socketAdmin.user.resetFlags({uid: adminUid}, [regularUid], function (err) { + socketAdmin.user.resetFlags({ uid: adminUid }, [regularUid], function (err) { assert.ifError(err); done(); }); @@ -257,7 +257,7 @@ describe('socket.io', function () { var meta = require('../src/meta'); it('should validate emails', function (done) { - socketAdmin.user.validateEmail({uid: adminUid}, [regularUid], function (err) { + socketAdmin.user.validateEmail({ uid: adminUid }, [regularUid], function (err) { assert.ifError(err); user.getUserField(regularUid, 'email:confirmed', function (err, emailConfirmed) { assert.ifError(err); @@ -269,7 +269,7 @@ describe('socket.io', function () { it('should error with invalid uids', function (done) { var socketAdmin = require('../src/socket.io/admin'); - socketAdmin.user.sendValidationEmail({uid: adminUid}, null, function (err) { + socketAdmin.user.sendValidationEmail({ uid: adminUid }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); @@ -277,7 +277,7 @@ describe('socket.io', function () { it('should error if email validation is not required', function (done) { var socketAdmin = require('../src/socket.io/admin'); - socketAdmin.user.sendValidationEmail({uid: adminUid}, [regularUid], function (err) { + socketAdmin.user.sendValidationEmail({ uid: adminUid }, [regularUid], function (err) { assert.equal(err.message, '[[error:email-confirmations-are-disabled]]'); done(); }); @@ -286,7 +286,7 @@ describe('socket.io', function () { it('should send validation email', function (done) { var socketAdmin = require('../src/socket.io/admin'); meta.config.requireEmailConfirmation = 1; - socketAdmin.user.sendValidationEmail({uid: adminUid}, [regularUid], function (err) { + socketAdmin.user.sendValidationEmail({ uid: adminUid }, [regularUid], function (err) { assert.ifError(err); meta.config.requireEmailConfirmation = 0; done(); @@ -296,7 +296,7 @@ describe('socket.io', function () { it('should search users', function (done) { var socketAdmin = require('../src/socket.io/admin'); - socketAdmin.user.search({uid: adminUid}, {query: 'reg', searchBy: 'username'}, function (err, data) { + socketAdmin.user.search({ uid: adminUid }, { query: 'reg', searchBy: 'username' }, function (err, data) { assert.ifError(err); assert.equal(data.matchCount, 1); assert.equal(data.users[0].username, 'regular'); @@ -306,7 +306,7 @@ describe('socket.io', function () { it('should push unread notifications on reconnect', function (done) { var socketMeta = require('../src/socket.io/meta'); - socketMeta.reconnected({uid: 1}, {}, function (err) { + socketMeta.reconnected({ uid: 1 }, {}, function (err) { assert.ifError(err); done(); }); @@ -322,14 +322,14 @@ describe('socket.io', function () { it('should return if uid is 0', function (done) { var socketMeta = require('../src/socket.io/meta'); - socketMeta.rooms.enter({uid: 0}, null, function (err) { + socketMeta.rooms.enter({ uid: 0 }, null, function (err) { assert.ifError(err); done(); }); }); it('should join a room', function (done) { - io.emit('meta.rooms.enter', {enter: 'recent_topics'}, function (err) { + io.emit('meta.rooms.enter', { enter: 'recent_topics' }, function (err) { assert.ifError(err); done(); }); @@ -344,7 +344,7 @@ describe('socket.io', function () { it('should get server time', function (done) { var socketMeta = require('../src/socket.io/meta'); - socketMeta.getServerTime({uid: 1}, null, function (err, time) { + socketMeta.getServerTime({ uid: 1 }, null, function (err, time) { assert.ifError(err); assert(time); done(); @@ -352,7 +352,7 @@ describe('socket.io', function () { }); it('should get daily analytics', function (done) { - io.emit('admin.analytics.get', {graph: 'traffic', units: 'days'}, function (err, data) { + io.emit('admin.analytics.get', { graph: 'traffic', units: 'days' }, function (err, data) { assert.ifError(err); assert(data); assert(data.monthlyPageViews); @@ -361,7 +361,7 @@ describe('socket.io', function () { }); it('should get hourly analytics', function (done) { - io.emit('admin.analytics.get', {graph: 'traffic', units: 'hours'}, function (err, data) { + io.emit('admin.analytics.get', { graph: 'traffic', units: 'hours' }, function (err, data) { assert.ifError(err); assert(data); assert(data.monthlyPageViews); @@ -371,7 +371,7 @@ describe('socket.io', function () { it('should return error', function (done) { var socketAdmin = require('../src/socket.io/admin'); - socketAdmin.before({uid: 10}, 'someMethod', {}, function (err) { + socketAdmin.before({ uid: 10 }, 'someMethod', {}, function (err) { assert.equal(err.message, '[[error:no-privileges]]'); done(); }); @@ -380,12 +380,12 @@ describe('socket.io', function () { it('should get room stats', function (done) { var socketAdmin = require('../src/socket.io/admin'); - io.emit('meta.rooms.enter', {enter: 'topic_1'}, function (err) { + io.emit('meta.rooms.enter', { enter: 'topic_1' }, function (err) { assert.ifError(err); - socketAdmin.rooms.getAll({uid: 10}, {}, function (err) { + socketAdmin.rooms.getAll({ uid: 10 }, {}, function (err) { assert.ifError(err); setTimeout(function () { - socketAdmin.rooms.getAll({uid: 10}, {}, function (err, data) { + socketAdmin.rooms.getAll({ uid: 10 }, {}, function (err, data) { assert.ifError(err); assert(data.hasOwnProperty('onlineGuestCount')); assert(data.hasOwnProperty('onlineRegisteredCount')); @@ -403,12 +403,12 @@ describe('socket.io', function () { it('should get room stats', function (done) { var socketAdmin = require('../src/socket.io/admin'); - io.emit('meta.rooms.enter', {enter: 'category_1'}, function (err) { + io.emit('meta.rooms.enter', { enter: 'category_1' }, function (err) { assert.ifError(err); - socketAdmin.rooms.getAll({uid: 10}, {}, function (err) { + socketAdmin.rooms.getAll({ uid: 10 }, {}, function (err) { assert.ifError(err); setTimeout(function () { - socketAdmin.rooms.getAll({uid: 10}, {}, function (err, data) { + socketAdmin.rooms.getAll({ uid: 10 }, {}, function (err, data) { assert.ifError(err); assert.equal(data.users.category, 1); done(); @@ -420,7 +420,7 @@ describe('socket.io', function () { it('should get admin search dictionary', function (done) { var socketAdmin = require('../src/socket.io/admin'); - socketAdmin.getSearchDict({uid: adminUid}, {}, function (err, data) { + socketAdmin.getSearchDict({ uid: adminUid }, {}, function (err, data) { assert.ifError(err); assert(Array.isArray(data)); assert(data[0].namespace); diff --git a/test/topics.js b/test/topics.js index e5190f6d00..40a6a8bed4 100644 --- a/test/topics.js +++ b/test/topics.js @@ -19,7 +19,7 @@ describe('Topic\'s', function () { before(function (done) { groups.resetCache(); - User.create({username: 'admin'}, function (err, uid) { + User.create({ username: 'admin' }, function (err, uid) { if (err) { return done(err); } @@ -49,7 +49,7 @@ describe('Topic\'s', function () { describe('.post', function () { it('should create a new topic with proper parameters', function (done) { - topics.post({uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId}, function (err, result) { + topics.post({ uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId }, function (err, result) { assert.equal(err, null, 'was created with error'); assert.ok(result); @@ -58,28 +58,28 @@ describe('Topic\'s', function () { }); it('should fail to create new topic with invalid user id', function (done) { - topics.post({uid: null, title: topic.title, content: topic.content, cid: topic.categoryId}, function (err) { + topics.post({ uid: null, title: topic.title, content: topic.content, cid: topic.categoryId }, function (err) { assert.equal(err.message, '[[error:no-privileges]]'); done(); }); }); it('should fail to create new topic with empty title', function (done) { - topics.post({uid: topic.userId, title: '', content: topic.content, cid: topic.categoryId}, function (err) { + topics.post({ uid: topic.userId, title: '', content: topic.content, cid: topic.categoryId }, function (err) { assert.ok(err); done(); }); }); it('should fail to create new topic with empty content', function (done) { - topics.post({uid: topic.userId, title: topic.title, content: '', cid: topic.categoryId}, function (err) { + topics.post({ uid: topic.userId, title: topic.title, content: '', cid: topic.categoryId }, function (err) { assert.ok(err); done(); }); }); it('should fail to create new topic with non-existant category id', function (done) { - topics.post({uid: topic.userId, title: topic.title, content: topic.content, cid: 99}, function (err) { + topics.post({ uid: topic.userId, title: topic.title, content: topic.content, cid: 99 }, function (err) { assert.equal(err.message, '[[error:no-category]]', 'received no error'); done(); }); @@ -91,7 +91,7 @@ describe('Topic\'s', function () { var newPost; before(function (done) { - topics.post({uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId}, function (err, result) { + topics.post({ uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId }, function (err, result) { if (err) { return done(err); } @@ -103,7 +103,7 @@ describe('Topic\'s', function () { }); it('should create a new reply with proper parameters', function (done) { - topics.reply({uid: topic.userId, content: 'test post', tid: newTopic.tid}, function (err, result) { + topics.reply({ uid: topic.userId, content: 'test post', tid: newTopic.tid }, function (err, result) { assert.equal(err, null, 'was created with error'); assert.ok(result); @@ -112,11 +112,11 @@ describe('Topic\'s', function () { }); it('should handle direct replies', function (done) { - topics.reply({uid: topic.userId, content: 'test reply', tid: newTopic.tid, toPid: newPost.pid}, function (err, result) { + topics.reply({ uid: topic.userId, content: 'test reply', tid: newTopic.tid, toPid: newPost.pid }, function (err, result) { assert.equal(err, null, 'was created with error'); assert.ok(result); - socketPosts.getReplies({uid: 0}, newPost.pid, function (err, postData) { + socketPosts.getReplies({ uid: 0 }, newPost.pid, function (err, postData) { assert.equal(err, null, 'posts.getReplies returned error'); assert.ok(postData); @@ -130,28 +130,28 @@ describe('Topic\'s', function () { }); it('should fail to create new reply with invalid user id', function (done) { - topics.reply({uid: null, content: 'test post', tid: newTopic.tid}, function (err) { + topics.reply({ uid: null, content: 'test post', tid: newTopic.tid }, function (err) { assert.equal(err.message, '[[error:no-privileges]]'); done(); }); }); it('should fail to create new reply with empty content', function (done) { - topics.reply({uid: topic.userId, content: '', tid: newTopic.tid}, function (err) { + topics.reply({ uid: topic.userId, content: '', tid: newTopic.tid }, function (err) { assert.ok(err); done(); }); }); it('should fail to create new reply with invalid topic id', function (done) { - topics.reply({uid: null, content: 'test post', tid: 99}, function (err) { + topics.reply({ uid: null, content: 'test post', tid: 99 }, function (err) { assert.equal(err.message, '[[error:no-topic]]'); done(); }); }); it('should fail to create new reply with invalid toPid', function (done) { - topics.reply({uid: topic.userId, content: 'test post', tid: newTopic.tid, toPid: '"onmouseover=alert(1);//'}, function (err) { + topics.reply({ uid: topic.userId, content: 'test post', tid: newTopic.tid, toPid: '"onmouseover=alert(1);//' }, function (err) { assert.equal(err.message, '[[error:invalid-pid]]'); done(); }); @@ -163,7 +163,7 @@ describe('Topic\'s', function () { var newPost; before(function (done) { - topics.post({uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId}, function (err, result) { + topics.post({ uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId }, function (err, result) { if (err) { return done(err); } @@ -207,7 +207,7 @@ describe('Topic\'s', function () { it('should properly escape topic title', function (done) { var title = '" new topic test'; var titleEscaped = validator.escape(title); - topics.post({uid: topic.userId, title: title, content: topic.content, cid: topic.categoryId}, function (err, result) { + topics.post({ uid: topic.userId, title: title, content: topic.content, cid: topic.categoryId }, function (err, result) { assert.ifError(err); topics.getTopicData(result.topicData.tid, function (err, topicData) { assert.ifError(err); @@ -230,14 +230,14 @@ describe('Topic\'s', function () { groups.join('administrators', adminUid, next); }, function (next) { - topics.post({uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId}, function (err, result) { + topics.post({ uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId }, function (err, result) { assert.ifError(err); newTopic = result.topicData; next(); }); }, function (next) { - User.create({username: 'topicFollower', password: '123456'}, next); + User.create({ username: 'topicFollower', password: '123456' }, next); }, function (_uid, next) { followerUid = _uid; @@ -259,7 +259,7 @@ describe('Topic\'s', function () { }); it('should load topic tools', function (done) { - socketTopics.loadTopicTools({uid: 1}, {tid: newTopic.tid}, function (err, data) { + socketTopics.loadTopicTools({ uid: 1 }, { tid: newTopic.tid }, function (err, data) { assert.ifError(err); assert(data); done(); @@ -267,21 +267,21 @@ describe('Topic\'s', function () { }); it('should delete the topic', function (done) { - socketTopics.delete({uid: 1}, {tids: [newTopic.tid], cid: categoryObj.cid}, function (err) { + socketTopics.delete({ uid: 1 }, { tids: [newTopic.tid], cid: categoryObj.cid }, function (err) { assert.ifError(err); done(); }); }); it('should restore the topic', function (done) { - socketTopics.restore({uid: 1}, {tids: [newTopic.tid], cid: categoryObj.cid}, function (err) { + socketTopics.restore({ uid: 1 }, { tids: [newTopic.tid], cid: categoryObj.cid }, function (err) { assert.ifError(err); done(); }); }); it('should lock topic', function (done) { - socketTopics.lock({uid: 1}, {tids: [newTopic.tid], cid: categoryObj.cid}, function (err) { + socketTopics.lock({ uid: 1 }, { tids: [newTopic.tid], cid: categoryObj.cid }, function (err) { assert.ifError(err); topics.isLocked(newTopic.tid, function (err, isLocked) { assert.ifError(err); @@ -292,7 +292,7 @@ describe('Topic\'s', function () { }); it('should unlock topic', function (done) { - socketTopics.unlock({uid: 1}, {tids: [newTopic.tid], cid: categoryObj.cid}, function (err) { + socketTopics.unlock({ uid: 1 }, { tids: [newTopic.tid], cid: categoryObj.cid }, function (err) { assert.ifError(err); topics.isLocked(newTopic.tid, function (err, isLocked) { assert.ifError(err); @@ -303,7 +303,7 @@ describe('Topic\'s', function () { }); it('should pin topic', function (done) { - socketTopics.pin({uid: 1}, {tids: [newTopic.tid], cid: categoryObj.cid}, function (err) { + socketTopics.pin({ uid: 1 }, { tids: [newTopic.tid], cid: categoryObj.cid }, function (err) { assert.ifError(err); db.getObjectField('topic:' + newTopic.tid, 'pinned', function (err, pinned) { assert.ifError(err); @@ -314,7 +314,7 @@ describe('Topic\'s', function () { }); it('should unpin topic', function (done) { - socketTopics.unpin({uid: 1}, {tids: [newTopic.tid], cid: categoryObj.cid}, function (err) { + socketTopics.unpin({ uid: 1 }, { tids: [newTopic.tid], cid: categoryObj.cid }, function (err) { assert.ifError(err); db.getObjectField('topic:' + newTopic.tid, 'pinned', function (err, pinned) { assert.ifError(err); @@ -325,7 +325,7 @@ describe('Topic\'s', function () { }); it('should move all topics', function (done) { - socketTopics.moveAll({uid: 1}, {cid: moveCid, currentCid: categoryObj.cid}, function (err) { + socketTopics.moveAll({ uid: 1 }, { cid: moveCid, currentCid: categoryObj.cid }, function (err) { assert.ifError(err); topics.getTopicField(newTopic.tid, 'cid', function (err, cid) { assert.ifError(err); @@ -336,7 +336,7 @@ describe('Topic\'s', function () { }); it('should move a topic', function (done) { - socketTopics.move({uid: 1}, {cid: categoryObj.cid, tids: [newTopic.tid]}, function (err) { + socketTopics.move({ uid: 1 }, { cid: categoryObj.cid, tids: [newTopic.tid] }, function (err) { assert.ifError(err); topics.getTopicField(newTopic.tid, 'cid', function (err, cid) { assert.ifError(err); @@ -347,7 +347,7 @@ describe('Topic\'s', function () { }); it('should purge the topic', function (done) { - socketTopics.purge({uid: 1}, {tids: [newTopic.tid], cid: categoryObj.cid}, function (err) { + socketTopics.purge({ uid: 1 }, { tids: [newTopic.tid], cid: categoryObj.cid }, function (err) { assert.ifError(err); db.isSortedSetMember('uid:' + followerUid + ':followed_tids', newTopic.tid, function (err, isMember) { assert.ifError(err); @@ -399,28 +399,28 @@ describe('Topic\'s', function () { var socketTopics = require('../src/socket.io/topics'); it('should error with invalid data', function (done) { - socketTopics.orderPinnedTopics({uid: adminUid}, null, function (err) { + socketTopics.orderPinnedTopics({ uid: adminUid }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should error with invalid data', function (done) { - socketTopics.orderPinnedTopics({uid: adminUid}, [null, null], function (err) { + socketTopics.orderPinnedTopics({ uid: adminUid }, [null, null], function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should error with unprivileged user', function (done) { - socketTopics.orderPinnedTopics({uid: 0}, [{tid: tid1}, {tid: tid2}], function (err) { + socketTopics.orderPinnedTopics({ uid: 0 }, [{ tid: tid1 }, { tid: tid2 }], function (err) { assert.equal(err.message, '[[error:no-privileges]]'); done(); }); }); it('should not do anything if topics are not pinned', function (done) { - socketTopics.orderPinnedTopics({uid: adminUid}, [{tid: tid3}], function (err) { + socketTopics.orderPinnedTopics({ uid: adminUid }, [{ tid: tid3 }], function (err) { assert.ifError(err); db.isSortedSetMember('cid:' + topic.categoryId + ':tids:pinned', tid3, function (err, isMember) { assert.ifError(err); @@ -435,7 +435,7 @@ describe('Topic\'s', function () { assert.ifError(err); assert.equal(pinnedTids[0], tid2); assert.equal(pinnedTids[1], tid1); - socketTopics.orderPinnedTopics({uid: adminUid}, [{tid: tid1, order: 1}, {tid: tid2, order: 0}], function (err) { + socketTopics.orderPinnedTopics({ uid: adminUid }, [{ tid: tid1, order: 1 }, { tid: tid2, order: 0 }], function (err) { assert.ifError(err); db.getSortedSetRevRange('cid:' + topic.categoryId + ':tids:pinned', 0, -1, function (err, pinnedTids) { assert.ifError(err); @@ -457,7 +457,7 @@ describe('Topic\'s', function () { uid = topic.userId; async.waterfall([ function (done) { - topics.post({uid: topic.userId, title: 'Topic to be ignored', content: 'Just ignore me, please!', cid: topic.categoryId}, function (err, result) { + topics.post({ uid: topic.userId, title: 'Topic to be ignored', content: 'Just ignore me, please!', cid: topic.categoryId }, function (err, result) { if (err) { return done(err); } @@ -561,7 +561,7 @@ describe('Topic\'s', function () { var topicPids; var originalBookmark = 5; function postReply(next) { - topics.reply({uid: topic.userId, content: 'test post ' + replies.length, tid: newTopic.tid}, function (err, result) { + topics.reply({ uid: topic.userId, content: 'test post ' + replies.length, tid: newTopic.tid }, function (err, result) { assert.equal(err, null, 'was created with error'); assert.ok(result); replies.push(result); @@ -576,7 +576,7 @@ describe('Topic\'s', function () { groups.join('administrators', topic.userId, next); }, function (next) { - topics.post({uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId}, function (err, result) { + topics.post({ uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId }, function (err, result) { assert.ifError(err); newTopic = result.topicData; next(); @@ -671,7 +671,7 @@ describe('Topic\'s', function () { var socketTopics = require('../src/socket.io/topics'); var tid; before(function (done) { - topics.post({uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId}, function (err, result) { + topics.post({ uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId }, function (err, result) { assert.ifError(err); tid = result.topicData.tid; done(); @@ -679,14 +679,14 @@ describe('Topic\'s', function () { }); it('should error with invalid data', function (done) { - socketTopics.loadMore({uid: adminUid}, {}, function (err) { + socketTopics.loadMore({ uid: adminUid }, {}, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should infinite load topic posts', function (done) { - socketTopics.loadMore({uid: adminUid}, {tid: tid, after: 0}, function (err, data) { + socketTopics.loadMore({ uid: adminUid }, { tid: tid, after: 0 }, function (err, data) { assert.ifError(err); assert(data.mainPost); assert(data.posts); @@ -696,16 +696,16 @@ describe('Topic\'s', function () { }); it('should error with invalid data', function (done) { - socketTopics.loadMoreUnreadTopics({uid: adminUid}, {after: 'invalid'}, function (err) { + socketTopics.loadMoreUnreadTopics({ uid: adminUid }, { after: 'invalid' }, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should load more unread topics', function (done) { - socketTopics.markUnread({uid: adminUid}, tid, function (err) { + socketTopics.markUnread({ uid: adminUid }, tid, function (err) { assert.ifError(err); - socketTopics.loadMoreUnreadTopics({uid: adminUid}, {cid: topic.categoryId, after: 0}, function (err, data) { + socketTopics.loadMoreUnreadTopics({ uid: adminUid }, { cid: topic.categoryId, after: 0 }, function (err, data) { assert.ifError(err); assert(data); assert(Array.isArray(data.topics)); @@ -715,7 +715,7 @@ describe('Topic\'s', function () { }); it('should error with invalid data', function (done) { - socketTopics.loadMoreRecentTopics({uid: adminUid}, {after: 'invalid'}, function (err) { + socketTopics.loadMoreRecentTopics({ uid: adminUid }, { after: 'invalid' }, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); @@ -723,7 +723,7 @@ describe('Topic\'s', function () { it('should load more recent topics', function (done) { - socketTopics.loadMoreRecentTopics({uid: adminUid}, {cid: topic.categoryId, after: 0}, function (err, data) { + socketTopics.loadMoreRecentTopics({ uid: adminUid }, { cid: topic.categoryId, after: 0 }, function (err, data) { assert.ifError(err); assert(data); assert(Array.isArray(data.topics)); @@ -732,14 +732,14 @@ describe('Topic\'s', function () { }); it('should error with invalid data', function (done) { - socketTopics.loadMoreFromSet({uid: adminUid}, {after: 'invalid'}, function (err) { + socketTopics.loadMoreFromSet({ uid: adminUid }, { after: 'invalid' }, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should load more from custom set', function (done) { - socketTopics.loadMoreFromSet({uid: adminUid}, {set: 'uid:' + adminUid + ':topics', after: 0}, function (err, data) { + socketTopics.loadMoreFromSet({ uid: adminUid }, { set: 'uid:' + adminUid + ':topics', after: 0 }, function (err, data) { assert.ifError(err); assert(data); assert(Array.isArray(data.topics)); @@ -754,10 +754,10 @@ describe('Topic\'s', function () { before(function (done) { async.parallel({ topic1: function (next) { - topics.post({uid: adminUid, tags: ['nodebb'], title: 'topic title 1', content: 'topic 1 content', cid: topic.categoryId}, next); + topics.post({ uid: adminUid, tags: ['nodebb'], title: 'topic title 1', content: 'topic 1 content', cid: topic.categoryId }, next); }, topic2: function (next) { - topics.post({uid: adminUid, tags: ['nodebb'], title: 'topic title 2', content: 'topic 2 content', cid: topic.categoryId}, next); + topics.post({ uid: adminUid, tags: ['nodebb'], title: 'topic title 2', content: 'topic 2 content', cid: topic.categoryId }, next); }, }, function (err, results) { assert.ifError(err); @@ -784,10 +784,10 @@ describe('Topic\'s', function () { before(function (done) { async.parallel({ topic: function (next) { - topics.post({uid: topic.userId, title: 'unread topic', content: 'unread topic content', cid: topic.categoryId}, next); + topics.post({ uid: topic.userId, title: 'unread topic', content: 'unread topic content', cid: topic.categoryId }, next); }, user: function (next) { - User.create({username: 'regularJoe'}, next); + User.create({ username: 'regularJoe' }, next); }, }, function (err, results) { assert.ifError(err); @@ -799,21 +799,21 @@ describe('Topic\'s', function () { }); it('should fail with invalid data', function (done) { - socketTopics.markUnread({uid: adminUid}, null, function (err) { + socketTopics.markUnread({ uid: adminUid }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should fail if topic does not exist', function (done) { - socketTopics.markUnread({uid: adminUid}, 1231082, function (err) { + socketTopics.markUnread({ uid: adminUid }, 1231082, function (err) { assert.equal(err.message, '[[error:no-topic]]'); done(); }); }); it('should mark topic unread', function (done) { - socketTopics.markUnread({uid: adminUid}, tid, function (err) { + socketTopics.markUnread({ uid: adminUid }, tid, function (err) { assert.ifError(err); topics.hasReadTopic(tid, adminUid, function (err, hasRead) { assert.ifError(err); @@ -825,7 +825,7 @@ describe('Topic\'s', function () { it('should fail with invalid data', function (done) { - socketTopics.markAsRead({uid: 0}, null, function (err) { + socketTopics.markAsRead({ uid: 0 }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); @@ -833,7 +833,7 @@ describe('Topic\'s', function () { it('should mark topic read', function (done) { - socketTopics.markAsRead({uid: adminUid}, [tid], function (err) { + socketTopics.markAsRead({ uid: adminUid }, [tid], function (err) { assert.ifError(err); topics.hasReadTopic(tid, adminUid, function (err, hasRead) { assert.ifError(err); @@ -844,7 +844,7 @@ describe('Topic\'s', function () { }); it('should fail with invalid data', function (done) { - socketTopics.markTopicNotificationsRead({uid: 0}, null, function (err) { + socketTopics.markTopicNotificationsRead({ uid: 0 }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); @@ -855,10 +855,10 @@ describe('Topic\'s', function () { async.waterfall([ function (next) { - socketTopics.follow({uid: adminUid}, tid, next); + socketTopics.follow({ uid: adminUid }, tid, next); }, function (next) { - socketPosts.reply({uid: uid}, {content: 'some content', tid: tid}, next); + socketPosts.reply({ uid: uid }, { content: 'some content', tid: tid }, next); }, function (data, next) { setTimeout(next, 2500); @@ -868,7 +868,7 @@ describe('Topic\'s', function () { }, function (count, next) { assert.equal(count, 1); - socketTopics.markTopicNotificationsRead({uid: adminUid}, [tid], next); + socketTopics.markTopicNotificationsRead({ uid: adminUid }, [tid], next); }, function (next) { User.notifications.getUnreadCount(adminUid, next); @@ -884,16 +884,16 @@ describe('Topic\'s', function () { }); it('should fail with invalid data', function (done) { - socketTopics.markAllRead({uid: 0}, null, function (err) { + socketTopics.markAllRead({ uid: 0 }, null, function (err) { assert.equal(err.message, '[[error:invalid-uid]]'); done(); }); }); it('should mark all read', function (done) { - socketTopics.markUnread({uid: adminUid}, tid, function (err) { + socketTopics.markUnread({ uid: adminUid }, tid, function (err) { assert.ifError(err); - socketTopics.markAllRead({uid: adminUid}, {}, function (err) { + socketTopics.markAllRead({ uid: adminUid }, {}, function (err) { assert.ifError(err); topics.hasReadTopic(tid, adminUid, function (err, hasRead) { assert.ifError(err); @@ -905,9 +905,9 @@ describe('Topic\'s', function () { }); it('should mark all read', function (done) { - socketTopics.markUnread({uid: adminUid}, tid, function (err) { + socketTopics.markUnread({ uid: adminUid }, tid, function (err) { assert.ifError(err); - socketTopics.markCategoryTopicsRead({uid: adminUid}, topic.categoryId, function (err) { + socketTopics.markCategoryTopicsRead({ uid: adminUid }, topic.categoryId, function (err) { assert.ifError(err); topics.hasReadTopic(tid, adminUid, function (err, hasRead) { assert.ifError(err); @@ -920,35 +920,35 @@ describe('Topic\'s', function () { it('should fail with invalid data', function (done) { - socketTopics.markAsUnreadForAll({uid: adminUid}, null, function (err) { + socketTopics.markAsUnreadForAll({ uid: adminUid }, null, function (err) { assert.equal(err.message, '[[error:invalid-tid]]'); done(); }); }); it('should fail with invalid data', function (done) { - socketTopics.markAsUnreadForAll({uid: 0}, [tid], function (err) { + socketTopics.markAsUnreadForAll({ uid: 0 }, [tid], function (err) { assert.equal(err.message, '[[error:no-privileges]]'); done(); }); }); it('should fail if user is not admin', function (done) { - socketTopics.markAsUnreadForAll({uid: uid}, [tid], function (err) { + socketTopics.markAsUnreadForAll({ uid: uid }, [tid], function (err) { assert.equal(err.message, '[[error:no-privileges]]'); done(); }); }); it('should fail if topic does not exist', function (done) { - socketTopics.markAsUnreadForAll({uid: uid}, [12312313], function (err) { + socketTopics.markAsUnreadForAll({ uid: uid }, [12312313], function (err) { assert.equal(err.message, '[[error:no-topic]]'); done(); }); }); it('should mark topic unread for everyone', function (done) { - socketTopics.markAsUnreadForAll({uid: adminUid}, [tid], function (err) { + socketTopics.markAsUnreadForAll({ uid: adminUid }, [tid], function (err) { assert.ifError(err); async.parallel({ adminRead: function (next) { @@ -974,10 +974,10 @@ describe('Topic\'s', function () { before(function (done) { async.parallel({ topic1: function (next) { - topics.post({uid: adminUid, tags: ['php', 'nosql', 'psql', 'nodebb'], title: 'topic title 1', content: 'topic 1 content', cid: topic.categoryId}, next); + topics.post({ uid: adminUid, tags: ['php', 'nosql', 'psql', 'nodebb'], title: 'topic title 1', content: 'topic 1 content', cid: topic.categoryId }, next); }, topic2: function (next) { - topics.post({uid: adminUid, tags: ['javascript', 'mysql', 'python', 'nodejs'], title: 'topic title 2', content: 'topic 2 content', cid: topic.categoryId}, next); + topics.post({ uid: adminUid, tags: ['javascript', 'mysql', 'python', 'nodejs'], title: 'topic title 2', content: 'topic 2 content', cid: topic.categoryId }, next); }, }, function (err) { assert.ifError(err); @@ -986,7 +986,7 @@ describe('Topic\'s', function () { }); it('should return empty array if query is falsy', function (done) { - socketTopics.autocompleteTags({uid: adminUid}, {query: ''}, function (err, data) { + socketTopics.autocompleteTags({ uid: adminUid }, { query: '' }, function (err, data) { assert.ifError(err); assert.deepEqual([], data); done(); @@ -994,7 +994,7 @@ describe('Topic\'s', function () { }); it('should autocomplete tags', function (done) { - socketTopics.autocompleteTags({uid: adminUid}, {query: 'p'}, function (err, data) { + socketTopics.autocompleteTags({ uid: adminUid }, { query: 'p' }, function (err, data) { assert.ifError(err); ['php', 'psql', 'python'].forEach(function (tag) { assert.notEqual(data.indexOf(tag), -1); @@ -1004,7 +1004,7 @@ describe('Topic\'s', function () { }); it('should return empty array if query is falsy', function (done) { - socketTopics.searchTags({uid: adminUid}, {query: ''}, function (err, data) { + socketTopics.searchTags({ uid: adminUid }, { query: '' }, function (err, data) { assert.ifError(err); assert.deepEqual([], data); done(); @@ -1012,7 +1012,7 @@ describe('Topic\'s', function () { }); it('should search tags', function (done) { - socketTopics.searchTags({uid: adminUid}, {query: 'no'}, function (err, data) { + socketTopics.searchTags({ uid: adminUid }, { query: 'no' }, function (err, data) { assert.ifError(err); ['nodebb', 'nodejs', 'nosql'].forEach(function (tag) { assert.notEqual(data.indexOf(tag), -1); @@ -1022,7 +1022,7 @@ describe('Topic\'s', function () { }); it('should return empty array if query is falsy', function (done) { - socketTopics.searchAndLoadTags({uid: adminUid}, {query: ''}, function (err, data) { + socketTopics.searchAndLoadTags({ uid: adminUid }, { query: '' }, function (err, data) { assert.ifError(err); assert.equal(data.matchCount, 0); assert.equal(data.pageCount, 1); @@ -1032,7 +1032,7 @@ describe('Topic\'s', function () { }); it('should search and load tags', function (done) { - socketTopics.searchAndLoadTags({uid: adminUid}, {query: 'no'}, function (err, data) { + socketTopics.searchAndLoadTags({ uid: adminUid }, { query: 'no' }, function (err, data) { assert.ifError(err); assert.equal(data.matchCount, 3); assert.equal(data.pageCount, 1); @@ -1048,14 +1048,14 @@ describe('Topic\'s', function () { }); it('should return error if data is invalid', function (done) { - socketTopics.loadMoreTags({uid: adminUid}, {after: 'asd'}, function (err) { + socketTopics.loadMoreTags({ uid: adminUid }, { after: 'asd' }, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should load more tags', function (done) { - socketTopics.loadMoreTags({uid: adminUid}, {after: 0}, function (err, data) { + socketTopics.loadMoreTags({ uid: adminUid }, { after: 0 }, function (err, data) { assert.ifError(err); assert(Array.isArray(data.tags)); assert.equal(data.nextStart, 100); @@ -1064,28 +1064,28 @@ describe('Topic\'s', function () { }); it('should error if data is invalid', function (done) { - socketAdmin.tags.create({uid: adminUid}, null, function (err) { + socketAdmin.tags.create({ uid: adminUid }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should error if tag is invalid', function (done) { - socketAdmin.tags.create({uid: adminUid}, {tag: ''}, function (err) { + socketAdmin.tags.create({ uid: adminUid }, { tag: '' }, function (err) { assert.equal(err.message, '[[error:invalid-tag]]'); done(); }); }); it('should error if tag is too short', function (done) { - socketAdmin.tags.create({uid: adminUid}, {tag: 'as'}, function (err) { + socketAdmin.tags.create({ uid: adminUid }, { tag: 'as' }, function (err) { assert.equal(err.message, '[[error:tag-too-short]]'); done(); }); }); it('should create empty tag', function (done) { - socketAdmin.tags.create({uid: adminUid}, {tag: 'emptytag'}, function (err) { + socketAdmin.tags.create({ uid: adminUid }, { tag: 'emptytag' }, function (err) { assert.ifError(err); db.sortedSetScore('tags:topic:count', 'emptytag', function (err, score) { assert.ifError(err); @@ -1096,7 +1096,7 @@ describe('Topic\'s', function () { }); it('should do nothing if tag exists', function (done) { - socketAdmin.tags.create({uid: adminUid}, {tag: 'emptytag'}, function (err) { + socketAdmin.tags.create({ uid: adminUid }, { tag: 'emptytag' }, function (err) { assert.ifError(err); db.sortedSetScore('tags:topic:count', 'emptytag', function (err, score) { assert.ifError(err); @@ -1107,14 +1107,14 @@ describe('Topic\'s', function () { }); it('should error if data is invalid', function (done) { - socketAdmin.tags.update({uid: adminUid}, null, function (err) { + socketAdmin.tags.update({ uid: adminUid }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should error if data.tag is invalid', function (done) { - socketAdmin.tags.update({uid: adminUid}, { + socketAdmin.tags.update({ uid: adminUid }, { bgColor: '#ff0000', color: '#00ff00', }, function (err) { @@ -1124,7 +1124,7 @@ describe('Topic\'s', function () { }); it('should update tag', function (done) { - socketAdmin.tags.update({uid: adminUid}, { + socketAdmin.tags.update({ uid: adminUid }, { tag: 'emptytag', bgColor: '#ff0000', color: '#00ff00', @@ -1143,7 +1143,7 @@ describe('Topic\'s', function () { var meta = require('../src/meta'); meta.config.maximumRelatedTopics = 2; var topicData = { - tags: [{value: 'javascript'}], + tags: [{ value: 'javascript' }], }; topics.getRelatedTopics(topicData, 0, function (err, data) { assert.ifError(err); @@ -1155,23 +1155,23 @@ describe('Topic\'s', function () { }); it('should return error with invalid data', function (done) { - socketAdmin.tags.deleteTags({uid: adminUid}, null, function (err) { + socketAdmin.tags.deleteTags({ uid: adminUid }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should do nothing if arrays is empty', function (done) { - socketAdmin.tags.deleteTags({uid: adminUid}, {tags: []}, function (err) { + socketAdmin.tags.deleteTags({ uid: adminUid }, { tags: [] }, function (err) { assert.ifError(err); done(); }); }); it('should delete tags', function (done) { - socketAdmin.tags.create({uid: adminUid}, {tag: 'emptytag2'}, function (err) { + socketAdmin.tags.create({ uid: adminUid }, { tag: 'emptytag2' }, function (err) { assert.ifError(err); - socketAdmin.tags.deleteTags({uid: adminUid}, {tags: ['emptytag', 'emptytag2', 'nodebb', 'nodejs']}, function (err) { + socketAdmin.tags.deleteTags({ uid: adminUid }, { tags: ['emptytag', 'emptytag2', 'nodebb', 'nodejs'] }, function (err) { assert.ifError(err); db.getObjects(['tag:emptytag', 'tag:emptytag2'], function (err, data) { assert.ifError(err); @@ -1200,12 +1200,12 @@ describe('Topic\'s', function () { var tid; var followerUid; before(function (done) { - User.create({username: 'follower'}, function (err, uid) { + User.create({ username: 'follower' }, function (err, uid) { if (err) { return done(err); } followerUid = uid; - topics.post({uid: adminUid, title: 'topic title', content: 'some content', cid: topic.categoryId}, function (err, result) { + topics.post({ uid: adminUid, title: 'topic title', content: 'some content', cid: topic.categoryId }, function (err, result) { if (err) { return done(err); } @@ -1216,7 +1216,7 @@ describe('Topic\'s', function () { }); it('should filter ignoring uids', function (done) { - socketTopics.changeWatching({uid: followerUid}, {tid: tid, type: 'ignore'}, function (err) { + socketTopics.changeWatching({ uid: followerUid }, { tid: tid, type: 'ignore' }, function (err) { assert.ifError(err); topics.filterIgnoringUids(tid, [adminUid, followerUid], function (err, uids) { assert.ifError(err); @@ -1228,14 +1228,14 @@ describe('Topic\'s', function () { }); it('should error with invalid data', function (done) { - socketTopics.changeWatching({uid: followerUid}, {}, function (err) { + socketTopics.changeWatching({ uid: followerUid }, {}, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should error with invalid type', function (done) { - socketTopics.changeWatching({uid: followerUid}, {tid: tid, type: 'derp'}, function (err) { + socketTopics.changeWatching({ uid: followerUid }, { tid: tid, type: 'derp' }, function (err) { assert.equal(err.message, '[[error:invalid-command]]'); done(); }); diff --git a/test/uploads.js b/test/uploads.js index 328e29ae94..17408a4170 100644 --- a/test/uploads.js +++ b/test/uploads.js @@ -31,10 +31,10 @@ describe('Upload Controllers', function () { }, next); }, adminUid: function (next) { - user.create({username: 'admin', password: 'barbar'}, next); + user.create({ username: 'admin', password: 'barbar' }, next); }, regularUid: function (next) { - user.create({username: 'regular', password: 'zugzug'}, next); + user.create({ username: 'regular', password: 'zugzug' }, next); }, }, function (err, results) { if (err) { @@ -44,7 +44,7 @@ describe('Upload Controllers', function () { regularUid = results.regularUid; cid = results.category.cid; - topics.post({uid: adminUid, title: 'test topic title', content: 'test topic content', cid: results.category.cid}, function (err, result) { + topics.post({ uid: adminUid, title: 'test topic title', content: 'test topic content', cid: results.category.cid }, function (err, result) { tid = result.topicData.tid; pid = result.postData.pid; done(err); @@ -77,7 +77,7 @@ describe('Upload Controllers', function () { }); it('should upload an image to a post', function (done) { - helpers.uploadFile(nconf.get('url') + '/api/post/upload', path.join(__dirname, '../public/logo.png'), {cid: cid}, jar, csrf_token, function (err, res, body) { + helpers.uploadFile(nconf.get('url') + '/api/post/upload', path.join(__dirname, '../public/logo.png'), { cid: cid }, jar, csrf_token, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(Array.isArray(body)); @@ -90,7 +90,7 @@ describe('Upload Controllers', function () { it('should upload a file to a post', function (done) { meta.config.allowFileUploads = 1; - helpers.uploadFile(nconf.get('url') + '/api/post/upload', path.join(__dirname, '../public/503.html'), {cid: cid}, jar, csrf_token, function (err, res, body) { + helpers.uploadFile(nconf.get('url') + '/api/post/upload', path.join(__dirname, '../public/503.html'), { cid: cid }, jar, csrf_token, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(Array.isArray(body)); @@ -126,7 +126,7 @@ describe('Upload Controllers', function () { }); it('should upload category image', function (done) { - helpers.uploadFile(nconf.get('url') + '/api/admin/category/uploadpicture', path.join(__dirname, '../public/logo.png'), {params: JSON.stringify({cid: cid})}, jar, csrf_token, function (err, res, body) { + helpers.uploadFile(nconf.get('url') + '/api/admin/category/uploadpicture', path.join(__dirname, '../public/logo.png'), { params: JSON.stringify({ cid: cid }) }, jar, csrf_token, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(Array.isArray(body)); diff --git a/test/user.js b/test/user.js index 672079a322..8eed9d67c7 100644 --- a/test/user.js +++ b/test/user.js @@ -51,7 +51,7 @@ describe('User', function () { describe('.create(), when created', function () { it('should be created properly', function (done) { - User.create({username: userData.username, password: userData.password, email: userData.email}, function (error, userId) { + User.create({ username: userData.username, password: userData.password, email: userData.email }, function (error, userId) { assert.equal(error, null, 'was created with error'); assert.ok(userId); @@ -61,7 +61,7 @@ describe('User', function () { }); it('should have a valid email, if using an email', function (done) { - User.create({username: userData.username, password: userData.password, email: 'fakeMail'}, function (err) { + User.create({ username: userData.username, password: userData.password, email: 'fakeMail' }, function (err) { assert(err); assert.equal(err.message, '[[error:invalid-email]]'); done(); @@ -173,7 +173,7 @@ describe('User', function () { describe('.search()', function () { var socketUser = require('../src/socket.io/user'); it('should return an object containing an array of matching users', function (done) { - User.search({query: 'john'}, function (err, searchData) { + User.search({ query: 'john' }, function (err, searchData) { assert.ifError(err); assert.equal(Array.isArray(searchData.users) && searchData.users.length > 0, true); assert.equal(searchData.users[0].username, 'John Smith'); @@ -182,7 +182,7 @@ describe('User', function () { }); it('should search user', function (done) { - socketUser.search({uid: testUid}, {query: 'john'}, function (err, searchData) { + socketUser.search({ uid: testUid }, { query: 'john' }, function (err, searchData) { assert.ifError(err); assert.equal(searchData.users[0].username, 'John Smith'); done(); @@ -191,7 +191,7 @@ describe('User', function () { it('should error for guest', function (done) { Meta.config.allowGuestUserSearching = 0; - socketUser.search({uid: 0}, {query: 'john'}, function (err) { + socketUser.search({ uid: 0 }, { query: 'john' }, function (err) { assert.equal(err.message, '[[error:not-logged-in]]'); Meta.config.allowGuestUserSearching = 1; done(); @@ -199,7 +199,7 @@ describe('User', function () { }); it('should error with invalid data', function (done) { - socketUser.search({uid: testUid}, null, function (err) { + socketUser.search({ uid: testUid }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); @@ -209,7 +209,7 @@ describe('User', function () { describe('.delete()', function () { var uid; before(function (done) { - User.create({username: 'usertodelete', password: '123456', email: 'delete@me.com'}, function (err, newUid) { + User.create({ username: 'usertodelete', password: '123456', email: 'delete@me.com' }, function (err, newUid) { assert.ifError(err); uid = newUid; done(); @@ -232,7 +232,7 @@ describe('User', function () { var uid; var code; before(function (done) { - User.create({username: 'resetuser', password: '123456', email: 'reset@me.com'}, function (err, newUid) { + User.create({ username: 'resetuser', password: '123456', email: 'reset@me.com' }, function (err, newUid) { assert.ifError(err); uid = newUid; done(); @@ -342,7 +342,7 @@ describe('User', function () { var io; before(function (done) { - User.create({username: 'updateprofile', email: 'update@me.com', password: '123456'}, function (err, newUid) { + User.create({ username: 'updateprofile', email: 'update@me.com', password: '123456' }, function (err, newUid) { assert.ifError(err); uid = newUid; helpers.loginUser('updateprofile', '123456', function (err, _jar, _io) { @@ -362,7 +362,7 @@ describe('User', function () { }); it('should return error if data is missing uid', function (done) { - io.emit('user.updateProfile', {username: 'bip', email: 'bop'}, function (err) { + io.emit('user.updateProfile', { username: 'bip', email: 'bop' }, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); @@ -399,7 +399,7 @@ describe('User', function () { it('should change a user\'s password', function (done) { this.timeout(20000); - io.emit('user.changePassword', {uid: uid, newPassword: '654321', currentPassword: '123456'}, function (err) { + io.emit('user.changePassword', { uid: uid, newPassword: '654321', currentPassword: '123456' }, function (err) { assert.ifError(err); User.isPasswordCorrect(uid, '654321', function (err, correct) { assert.ifError(err); @@ -410,7 +410,7 @@ describe('User', function () { }); it('should change username', function (done) { - io.emit('user.changeUsernameEmail', {uid: uid, username: 'updatedAgain', password: '654321'}, function (err) { + io.emit('user.changeUsernameEmail', { uid: uid, username: 'updatedAgain', password: '654321' }, function (err) { assert.ifError(err); db.getObjectField('user:' + uid, 'username', function (err, username) { assert.ifError(err); @@ -421,7 +421,7 @@ describe('User', function () { }); it('should change email', function (done) { - io.emit('user.changeUsernameEmail', {uid: uid, email: 'updatedAgain@me.com', password: '654321'}, function (err) { + io.emit('user.changeUsernameEmail', { uid: uid, email: 'updatedAgain@me.com', password: '654321' }, function (err) { assert.ifError(err); db.getObjectField('user:' + uid, 'email', function (err, email) { assert.ifError(err); @@ -434,7 +434,7 @@ describe('User', function () { it('should update cover image', function (done) { var imageData = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAgCAYAAAABtRhCAAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAACcJJREFUeNqMl9tvnNV6xn/f+s5z8DCeg88Zj+NYdhJH4KShFoJAIkzVphLVJnsDaiV6gUKaC2qQUFVATbnoValAakuQYKMqBKUUJCgI9XBBSmOROMqGoCStHbA9sWM7nrFn/I3n9B17kcwoabfarj9gvet53+d9nmdJAwMDAAgh8DyPtbU1XNfFMAwkScK2bTzPw/M8dF1/SAhxKAiCxxVF2aeqqqTr+q+Af+7o6Ch0d3f/69TU1KwkSRiGwbFjx3jmmWd47rnn+OGHH1BVFYX/5QRBkPQ87xeSJP22YRi/oapqStM0PM/D931kWSYIgnHf98cXFxepVqtomjZt2/Zf2bb990EQ4Pv+PXfeU1CSpGYhfN9/TgjxQTQaJQgCwuEwQRBQKpUwDAPTNPF9n0ajAYDv+8zPzzM+Pr6/Wq2eqdVqfxOJRA6Zpnn57hrivyEC0IQQZ4Mg+MAwDCKRCJIkUa/XEUIQi8XQNI1QKIQkSQghUBQFIQSmaTI7OwtAuVxOTE9Pfzc9Pf27lUqlBUgulUoUi0VKpRKqqg4EQfAfiqLsDIfDAC0E4XCYaDSKEALXdalUKvfM1/d9hBBYlkUul2N4eJi3335bcl33mW+++aaUz+cvSJKE8uKLL6JpGo7j8Omnn/7d+vp6sr+/HyEEjuMgyzKu6yJJEsViEVVV8TyPjY2NVisV5fZkTNMkkUhw8+ZN6vU6Kysr7Nmzh9OnT7/12GOPDS8sLByT7rQR4A9XV1d/+cILLzA9PU0kEmF4eBhFUTh//jyWZaHrOkII0uk0jUaDWq1GJpOhWCyysrLC1tYWnuehqir79+9H13W6urp48803+f7773n++ef/4G7S/H4ikUCSJNbX11trcuvWLcrlMrIs4zgODzzwABMTE/i+T7lcpq2tjUqlwubmJrZts7y8jBCCkZERGo0G2WyWkydPkkql6Onp+eMmwihwc3JyMvrWW2+RTCYBcF0XWZbRdZ3l5WX27NnD008/TSwWQ1VVyuVy63GhUIhEIkEqlcJxHCzLIhaLMTQ0xJkzZ7Btm3379lmS53kIIczZ2dnFsbGxRK1Wo729HQDP8zAMg5WVFXp7e5mcnKSzs5N8Po/rutTrdVzXbQmHrutEo1FM00RVVXp7e0kkEgRBwMWLF9F1vaxUq1UikUjtlVdeuV6pVBJ9fX3Ytn2bwrLMysoKXV1dTE5OkslksCwLTdMwDANVVdnY2CAIApLJJJFIBMdxiMfj7Nq1C1VViUajLQCvvvrqkhKJRJiZmfmdb7/99jeTySSyLLfWodFoEAqFOH78OLt37yaXy2GaJoqisLy8zNTUFFevXiUIAtrb29m5cyePPPJIa+cymQz1eh2A0dFRCoXCsgIwNTW1J5/P093dTbFYRJZlJEmiWq1y4MABxsbGqNVqhEIh6vU6QRBQLpcxDIPh4WE8z2NxcZFTp05x7tw5Xn755ZY6dXZ2tliZzWa/EwD1ev3RsbExxsfHSafTVCoVGo0Gqqqya9cuIpEIQgh832dtbY3FxUUA+vr62LZtG2NjYxw5coTDhw+ztLTEyZMnuXr1KoVC4R4d3bt375R84sQJEY/H/2Jubq7N9326urqwbZt6vY5pmhw5coS+vr4W9YvFIrdu3WJqagohBFeuXOHcuXOtue7evRtN01rtfO+991haWmJkZGQrkUi8JIC9iqL0BkFAIpFACMETTzxBV1cXiUSC7u5uHMfB8zyCIMA0TeLxONlsFlmW8X2fwcFBHMdhfn6eer1Oe3s7Dz30EBMTE1y6dImjR49y6tSppR07dqwrjuM8+OWXXzI0NMTly5e5du0aQ0NDTExMkMvlCIKAIAhaIh2LxQiHw0QiEfL5POl0mlqtRq1Wo6OjA8uykGWZdDrN0tISvb29vPPOOzz++OPk83lELpf7rXfffRfDMOjo6MBxHEqlEocOHWLHjh00Gg0kSULTNIS4bS6qqhKPxxkaGmJ4eJjR0VH279/PwMAA27dvJ5vN4vs+X331FR9//DGzs7OEQiE++eQTlPb29keuX7/OtWvXOH78ONVqlZs3b9LW1kYmk8F13dZeCiGQJAnXdRFCYBgGsiwjhMC2bQqFAkEQoOs6P/74Iw8++CCDg4Pous6xY8f47LPPkIIguDo2Nrbzxo0bfPjhh9i2zczMTHNvcF2XpsZalkWj0cB1Xe4o1O3YoCisra3x008/EY/H6erqAuDAgQNEIhGCIODQoUP/ubCwMCKAjx599FHW19f56KOP6OjooFgsks/niUajKIqCbds4joMQAiFESxxs226xd2Zmhng8Tl9fH67r0mg0sG2bbDZLpVIhl8vd5gHwtysrKy8Dcdd1mZubo6enh1gsRrVabZlrk6VND/R9n3q9TqVSQdd1QqEQi4uLnD9/nlKpxODgIHv37gXAcRyCICiFQiHEzp07i1988cUfKYpCIpHANE22b9/eUhNFUVotDIKghc7zPCzLolKpsLW1RVtbG0EQ4DgOmqbR09NDM1qUSiWAPwdQ7ujjmf7+/kQymfxrSZJQVZWtra2WG+i63iKH53m4rku1WqVcLmNZFu3t7S2x7+/vJ51O89prr7VYfenSpcPAP1UqFeSHH36YeDxOKpW6eP/9988Bv9d09nw+T7VapVKptJjZnE2tVmNtbY1cLke5XGZra4vNzU16enp49tlnGRgYaD7iTxqNxgexWIzDhw+jNEPQHV87NT8/f+PChQtnR0ZGqFarrUVuOsDds2u2b2FhgVQqRSQSYWFhgStXrtDf308ymcwBf3nw4EEOHjx4O5c2lURVVRzHYXp6+t8uX7785IULFz7LZDLous59991HOBy+h31N9xgdHSWTyVCtVhkaGmLfvn1MT08zPz/PzMzM6c8//9xr+uE9QViWZer1OhsbGxiG8fns7OzPc7ncx729vXR3d1OpVNi2bRuhUAhZljEMA9/3sW0bVVVZWlri4sWLjI+P8/rrr/P111/z5JNPXrIs69cn76ZeGoaBpmm0tbX9Q6FQeHhubu7fC4UCkUiE1dVVstks8Xgc0zSRZZlGo9ESAdM02djYoNFo8MYbb2BZ1mYoFOKuZPjr/xZBEHCHred83x/b3Nz8l/X19aRlWWxsbNDZ2cnw8DDhcBjf96lWq/T09HD06FGeeuopXnrpJc6ePUs6nb4hhPi/C959ZFn+TtO0lG3bJ0ql0p85jsPW1haFQoG2tjYkSWpF/Uwmw9raGu+//z7A977vX2+GrP93wSZiTdNOGIbxy3K5/DPHcfYXCoVe27Yzpmm2m6bppVKp/Orqqnv69OmoZVn/mEwm/9TzvP9x138NAMpJ4VFTBr6SAAAAAElFTkSuQmCC'; var position = '50.0301% 19.2464%'; - io.emit('user.updateCover', {uid: uid, imageData: imageData, position: position}, function (err, result) { + io.emit('user.updateCover', { uid: uid, imageData: imageData, position: position }, function (err, result) { assert.ifError(err); assert(result.url); db.getObjectFields('user:' + uid, ['cover:url', 'cover:position'], function (err, data) { @@ -447,7 +447,7 @@ describe('User', function () { }); it('should remove cover image', function (done) { - io.emit('user.removeCover', {uid: uid}, function (err) { + io.emit('user.removeCover', { uid: uid }, function (err) { assert.ifError(err); db.getObjectField('user:' + uid, 'cover:url', function (err, url) { assert.ifError(err); @@ -482,7 +482,7 @@ describe('User', function () { }); it('should change user picture', function (done) { - io.emit('user.changePicture', {type: 'default', uid: uid}, function (err) { + io.emit('user.changePicture', { type: 'default', uid: uid }, function (err) { assert.ifError(err); User.getUserField(uid, 'picture', function (err, picture) { assert.ifError(err); @@ -564,7 +564,7 @@ describe('User', function () { callback(null, data); } - plugins.registerHook('test-plugin', {hook: 'filter:uploadImage', method: filterMethod}); + plugins.registerHook('test-plugin', { hook: 'filter:uploadImage', method: filterMethod }); User.uploadFromUrl(uid, url, function (err, uploadedPicture) { assert.equal(err.message, '[[error:invalid-image-extension]]'); @@ -581,7 +581,7 @@ describe('User', function () { callback(null, data); } - plugins.registerHook('test-plugin', {hook: 'filter:uploadImage', method: filterMethod}); + plugins.registerHook('test-plugin', { hook: 'filter:uploadImage', method: filterMethod }); User.uploadFromUrl(uid, url, function (err, uploadedPicture) { assert.equal(err.message, '[[error:file-too-big, ' + meta.config.maximumProfileImageSize + ']]'); @@ -595,10 +595,10 @@ describe('User', function () { function filterMethod(data, callback) { data.foo += 5; - callback(null, {url: url}); + callback(null, { url: url }); } - plugins.registerHook('test-plugin', {hook: 'filter:uploadImage', method: filterMethod}); + plugins.registerHook('test-plugin', { hook: 'filter:uploadImage', method: filterMethod }); User.uploadFromUrl(uid, url, function (err, uploadedPicture) { assert.ifError(err); @@ -608,7 +608,7 @@ describe('User', function () { }); it('should get profile pictures', function (done) { - io.emit('user.getProfilePictures', {uid: uid}, function (err, data) { + io.emit('user.getProfilePictures', { uid: uid }, function (err, data) { assert.ifError(err); assert(data); assert(Array.isArray(data)); @@ -619,7 +619,7 @@ describe('User', function () { }); it('should remove uploaded picture', function (done) { - io.emit('user.removeUploadedPicture', {uid: uid}, function (err) { + io.emit('user.removeUploadedPicture', { uid: uid }, function (err) { assert.ifError(err); User.getUserField(uid, 'uploadedpicture', function (err, uploadedpicture) { assert.ifError(err); @@ -630,7 +630,7 @@ describe('User', function () { }); it('should load profile page', function (done) { - request(nconf.get('url') + '/api/user/updatedagain', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/user/updatedagain', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(body); @@ -639,7 +639,7 @@ describe('User', function () { }); it('should load settings page', function (done) { - request(nconf.get('url') + '/api/user/updatedagain/settings', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/user/updatedagain/settings', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(body.settings); @@ -650,7 +650,7 @@ describe('User', function () { }); it('should load edit page', function (done) { - request(nconf.get('url') + '/api/user/updatedagain/edit', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/user/updatedagain/edit', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(body); @@ -659,7 +659,7 @@ describe('User', function () { }); it('should load edit/email page', function (done) { - request(nconf.get('url') + '/api/user/updatedagain/edit/email', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/user/updatedagain/edit/email', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(body); @@ -675,7 +675,7 @@ describe('User', function () { assert.ifError(err); groups.join('Test', uid, function (err) { assert.ifError(err); - request(nconf.get('url') + '/api/user/updatedagain/groups', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/user/updatedagain/groups', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert(Array.isArray(body.groups)); @@ -718,7 +718,7 @@ describe('User', function () { describe('digests', function () { var uid; before(function (done) { - User.create({username: 'digestuser', email: 'test@example.com'}, function (err, _uid) { + User.create({ username: 'digestuser', email: 'test@example.com' }, function (err, _uid) { assert.ifError(err); uid = _uid; done(); @@ -740,14 +740,14 @@ describe('User', function () { var socketUser = require('../src/socket.io/user'); it('should fail with invalid data', function (done) { - socketUser.exists({uid: testUid}, null, function (err) { + socketUser.exists({ uid: testUid }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should return true if user/group exists', function (done) { - socketUser.exists({uid: testUid}, {username: 'registered-users'}, function (err, exists) { + socketUser.exists({ uid: testUid }, { username: 'registered-users' }, function (err, exists) { assert.ifError(err); assert(exists); done(); @@ -755,7 +755,7 @@ describe('User', function () { }); it('should return true if user/group exists', function (done) { - socketUser.exists({uid: testUid}, {username: 'John Smith'}, function (err, exists) { + socketUser.exists({ uid: testUid }, { username: 'John Smith' }, function (err, exists) { assert.ifError(err); assert(exists); done(); @@ -763,7 +763,7 @@ describe('User', function () { }); it('should return false if user/group does not exists', function (done) { - socketUser.exists({uid: testUid}, {username: 'doesnot exist'}, function (err, exists) { + socketUser.exists({ uid: testUid }, { username: 'doesnot exist' }, function (err, exists) { assert.ifError(err); assert(!exists); done(); @@ -771,11 +771,11 @@ describe('User', function () { }); it('should delete user', function (done) { - User.create({username: 'tobedeleted'}, function (err, _uid) { + User.create({ username: 'tobedeleted' }, function (err, _uid) { assert.ifError(err); - socketUser.deleteAccount({uid: _uid}, {}, function (err) { + socketUser.deleteAccount({ uid: _uid }, {}, function (err) { assert.ifError(err); - socketUser.exists({uid: testUid}, {username: 'doesnot exist'}, function (err, exists) { + socketUser.exists({ uid: testUid }, { username: 'doesnot exist' }, function (err, exists) { assert.ifError(err); assert(!exists); done(); @@ -785,14 +785,14 @@ describe('User', function () { }); it('should fail if data is invalid', function (done) { - socketUser.emailExists({uid: testUid}, null, function (err) { + socketUser.emailExists({ uid: testUid }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should return true if email exists', function (done) { - socketUser.emailExists({uid: testUid}, {email: 'john@example.com'}, function (err, exists) { + socketUser.emailExists({ uid: testUid }, { email: 'john@example.com' }, function (err, exists) { assert.ifError(err); assert(exists); done(); @@ -800,7 +800,7 @@ describe('User', function () { }); it('should return false if email does not exist', function (done) { - socketUser.emailExists({uid: testUid}, {email: 'does@not.exist'}, function (err, exists) { + socketUser.emailExists({ uid: testUid }, { email: 'does@not.exist' }, function (err, exists) { assert.ifError(err); assert(!exists); done(); @@ -808,7 +808,7 @@ describe('User', function () { }); it('should error if requireEmailConfirmation is disabled', function (done) { - socketUser.emailConfirm({uid: testUid}, {}, function (err) { + socketUser.emailConfirm({ uid: testUid }, {}, function (err) { assert.equal(err.message, '[[error:email-confirmations-are-disabled]]'); done(); }); @@ -816,7 +816,7 @@ describe('User', function () { it('should send email confirm', function (done) { Meta.config.requireEmailConfirmation = 1; - socketUser.emailConfirm({uid: testUid}, {}, function (err) { + socketUser.emailConfirm({ uid: testUid }, {}, function (err) { assert.ifError(err); Meta.config.requireEmailConfirmation = 0; done(); @@ -824,21 +824,21 @@ describe('User', function () { }); it('should send reset email', function (done) { - socketUser.reset.send({uid: 0}, 'john@example.com', function (err) { + socketUser.reset.send({ uid: 0 }, 'john@example.com', function (err) { assert.ifError(err); done(); }); }); it('should return invalid-data error', function (done) { - socketUser.reset.send({uid: 0}, null, function (err) { + socketUser.reset.send({ uid: 0 }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should not error', function (done) { - socketUser.reset.send({uid: 0}, 'doestnot@exist.com', function (err) { + socketUser.reset.send({ uid: 0 }, 'doestnot@exist.com', function (err) { assert.ifError(err); done(); }); @@ -848,7 +848,7 @@ describe('User', function () { db.getObject('reset:uid', function (err, data) { assert.ifError(err); var code = Object.keys(data)[0]; - socketUser.reset.commit({uid: 0}, {code: code, password: 'swordfish'}, function (err) { + socketUser.reset.commit({ uid: 0 }, { code: code, password: 'swordfish' }, function (err) { assert.ifError(err); done(); }); @@ -879,18 +879,18 @@ describe('User', function () { outgoingChatSound: '', }, }; - socketUser.saveSettings({uid: testUid}, data, function (err) { + socketUser.saveSettings({ uid: testUid }, data, function (err) { assert.ifError(err); done(); }); }); it('should set moderation note', function (done) { - User.create({username: 'noteadmin'}, function (err, adminUid) { + User.create({ username: 'noteadmin' }, function (err, adminUid) { assert.ifError(err); groups.join('administrators', adminUid, function (err) { assert.ifError(err); - socketUser.setModerationNote({uid: adminUid}, {uid: testUid, note: 'this is a test user'}, function (err) { + socketUser.setModerationNote({ uid: adminUid }, { uid: testUid, note: 'this is a test user' }, function (err) { assert.ifError(err); User.getUserField(testUid, 'moderationNote', function (err, note) { assert.ifError(err); @@ -911,7 +911,7 @@ describe('User', function () { before(function (done) { oldRegistrationType = Meta.config.registrationType; Meta.config.registrationType = 'admin-approval'; - User.create({username: 'admin', password: '123456'}, function (err, uid) { + User.create({ username: 'admin', password: '123456' }, function (err, uid) { assert.ifError(err); adminUid = uid; groups.join('administrators', uid, done); @@ -932,7 +932,7 @@ describe('User', function () { assert.ifError(err); helpers.loginUser('admin', '123456', function (err, jar) { assert.ifError(err); - request(nconf.get('url') + '/api/admin/manage/registration', {jar: jar, json: true}, function (err, res, body) { + request(nconf.get('url') + '/api/admin/manage/registration', { jar: jar, json: true }, function (err, res, body) { assert.ifError(err); assert.equal(body.users[0].username, 'rejectme'); assert.equal(body.users[0].email, 'reject@me.com'); @@ -943,7 +943,7 @@ describe('User', function () { }); it('should reject user registration', function (done) { - socketAdmin.user.rejectRegistration({uid: adminUid}, {username: 'rejectme'}, function (err) { + socketAdmin.user.rejectRegistration({ uid: adminUid }, { username: 'rejectme' }, function (err) { assert.ifError(err); User.getRegistrationQueue(0, -1, function (err, users) { assert.ifError(err); @@ -960,7 +960,7 @@ describe('User', function () { email: 'accept@me.com', }, function (err) { assert.ifError(err); - socketAdmin.user.acceptRegistration({uid: adminUid}, {username: 'acceptme'}, function (err, uid) { + socketAdmin.user.acceptRegistration({ uid: adminUid }, { username: 'acceptme' }, function (err, uid) { assert.ifError(err); User.exists(uid, function (err, exists) { assert.ifError(err); diff --git a/test/utils.js b/test/utils.js index 547a673aee..e5d0666931 100644 --- a/test/utils.js +++ b/test/utils.js @@ -70,8 +70,8 @@ describe('Utility Methods', function () { }); it('should shallow merge two objects', function (done) { - var a = {foo: 1, cat1: 'ginger'}; - var b = {baz: 2, cat2: 'phoebe'}; + var a = { foo: 1, cat1: 'ginger' }; + var b = { baz: 2, cat2: 'phoebe' }; var obj = utils.merge(a, b); assert.strictEqual(obj.foo, 1); assert.strictEqual(obj.baz, 2);