fix(style): switch..case

v1.18.x
Julian Lam 5 years ago
parent d7ab0894d4
commit 922d49be0b

@ -15,25 +15,25 @@ define('admin/advanced/logs', function () {
var action = btnEl.attr('data-action');
switch (action) {
case 'reload':
socket.emit('admin.logs.get', function (err, logs) {
if (!err) {
logsEl.text(logs);
logsEl.scrollTop(logsEl.prop('scrollHeight'));
} else {
app.alertError(err.message);
}
});
break;
case 'reload':
socket.emit('admin.logs.get', function (err, logs) {
if (!err) {
logsEl.text(logs);
logsEl.scrollTop(logsEl.prop('scrollHeight'));
} else {
app.alertError(err.message);
}
});
break;
case 'clear':
socket.emit('admin.logs.clear', function (err) {
if (!err) {
app.alertSuccess('[[admin/advanced/logs:clear-success]]');
btnEl.prev().click();
}
});
break;
case 'clear':
socket.emit('admin.logs.clear', function (err) {
if (!err) {
app.alertSuccess('[[admin/advanced/logs:clear-success]]');
btnEl.prev().click();
}
});
break;
}
});
};

@ -56,18 +56,18 @@ define('admin/extend/rewards', ['translator', 'benchpress'], function (translato
function select(el) {
el.val(el.attr('data-selected'));
switch (el.attr('name')) {
case 'rid':
selectReward(el);
break;
case 'rid':
selectReward(el);
break;
}
}
function update(el) {
el.attr('data-selected', el.val());
switch (el.attr('name')) {
case 'rid':
selectReward(el);
break;
case 'rid':
selectReward(el);
break;
}
}
@ -94,15 +94,15 @@ define('admin/extend/rewards', ['translator', 'benchpress'], function (translato
inputs.forEach(function (input) {
html += '<label for="' + input.name + '">' + input.label + '<br />';
switch (input.type) {
case 'select':
html += '<select name="' + input.name + '">';
input.values.forEach(function (value) {
html += '<option value="' + value.value + '">' + value.name + '</option>';
});
break;
case 'text':
html += '<input type="text" name="' + input.name + '" />';
break;
case 'select':
html += '<select name="' + input.name + '">';
input.values.forEach(function (value) {
html += '<option value="' + value.value + '">' + value.name + '</option>';
});
break;
case 'text':
html += '<input type="text" name="' + input.name + '" />';
break;
}
html += '</label><br />';
});

@ -45,36 +45,36 @@ define('admin/manage/group', [
var action = btnEl.attr('data-action');
switch (action) {
case 'toggleOwnership':
socket.emit('groups.' + (isOwner ? 'rescind' : 'grant'), {
toUid: uid,
groupName: groupName,
}, function (err) {
if (err) {
return app.alertError(err.message);
}
ownerFlagEl.toggleClass('invisible');
});
break;
case 'kick':
bootbox.confirm('[[admin/manage/groups:edit.confirm-remove-user]]', function (confirm) {
if (!confirm) {
return;
}
socket.emit('admin.groups.leave', {
uid: uid,
case 'toggleOwnership':
socket.emit('groups.' + (isOwner ? 'rescind' : 'grant'), {
toUid: uid,
groupName: groupName,
}, function (err) {
if (err) {
return app.alertError(err.message);
}
userRow.slideUp().remove();
ownerFlagEl.toggleClass('invisible');
});
});
break;
default:
break;
break;
case 'kick':
bootbox.confirm('[[admin/manage/groups:edit.confirm-remove-user]]', function (confirm) {
if (!confirm) {
return;
}
socket.emit('admin.groups.leave', {
uid: uid,
groupName: groupName,
}, function (err) {
if (err) {
return app.alertError(err.message);
}
userRow.slideUp().remove();
});
});
break;
default:
break;
}
});

@ -58,21 +58,21 @@ define('admin/manage/groups', ['translator', 'benchpress'], function (translator
var groupName = el.parents('tr[data-groupname]').attr('data-groupname');
switch (action) {
case 'delete':
bootbox.confirm('[[admin/manage/groups:alerts.confirm-delete]]', function (confirm) {
if (confirm) {
socket.emit('groups.delete', {
groupName: groupName,
}, function (err) {
if (err) {
return app.alertError(err.message);
}
ajaxify.refresh();
});
}
});
break;
case 'delete':
bootbox.confirm('[[admin/manage/groups:alerts.confirm-delete]]', function (confirm) {
if (confirm) {
socket.emit('groups.delete', {
groupName: groupName,
}, function (err) {
if (err) {
return app.alertError(err.message);
}
ajaxify.refresh();
});
}
});
break;
}
});
};

@ -156,17 +156,17 @@ define('admin/settings', ['uploader'], function (uploader) {
if (field.is('input')) {
inputType = field.attr('type');
switch (inputType) {
case 'text':
case 'password':
case 'hidden':
case 'textarea':
case 'number':
value = field.val();
break;
case 'checkbox':
value = field.prop('checked') ? '1' : '0';
break;
case 'text':
case 'password':
case 'hidden':
case 'textarea':
case 'number':
value = field.val();
break;
case 'checkbox':
value = field.prop('checked') ? '1' : '0';
break;
}
} else if (field.is('textarea') || field.is('select')) {
value = field.val();

@ -275,25 +275,25 @@ app.cacheBuster = null;
function showAlert(type, message) {
switch (messages[type].format) {
case 'alert':
app.alert({
type: 'success',
title: messages[type].title,
message: messages[type].message,
timeout: 5000,
});
break;
case 'modal':
require(['translator'], function (translator) {
translator.translate(message || messages[type].message, function (translated) {
bootbox.alert({
title: messages[type].title,
message: translated,
case 'alert':
app.alert({
type: 'success',
title: messages[type].title,
message: messages[type].message,
timeout: 5000,
});
break;
case 'modal':
require(['translator'], function (translator) {
translator.translate(message || messages[type].message, function (translated) {
bootbox.alert({
title: messages[type].title,
message: translated,
});
});
});
});
break;
break;
}
}

@ -61,13 +61,13 @@ define('forum/account/settings', ['forum/account/header', 'components', 'sounds'
}
switch (input.attr('type')) {
case 'text':
case 'textarea':
settings[setting] = input.val();
break;
case 'checkbox':
settings[setting] = input.is(':checked') ? 1 : 0;
break;
case 'text':
case 'textarea':
settings[setting] = input.val();
break;
case 'checkbox':
settings[setting] = input.is(':checked') ? 1 : 0;
break;
}
});

@ -157,18 +157,18 @@ define('forum/chats', [
var action = this.getAttribute('data-action');
switch (action) {
case 'edit':
var inputEl = $('[data-roomid="' + roomId + '"] [component="chat/input"]');
messages.prepEdit(inputEl, messageId, roomId);
break;
case 'delete':
messages.delete(messageId, roomId);
break;
case 'restore':
messages.restore(messageId, roomId);
break;
case 'edit':
var inputEl = $('[data-roomid="' + roomId + '"] [component="chat/input"]');
messages.prepEdit(inputEl, messageId, roomId);
break;
case 'delete':
messages.delete(messageId, roomId);
break;
case 'restore':
messages.restore(messageId, roomId);
break;
}
});
};

@ -13,44 +13,44 @@ define('forum/flags/detail', ['forum/flags/list', 'components', 'translator', 'b
var uid = $(this).parents('[data-uid]').attr('data-uid');
switch (action) {
case 'update':
socket.emit('flags.update', {
flagId: ajaxify.data.flagId,
data: $('#attributes').serializeArray(),
}, function (err, history) {
if (err) {
return app.alertError(err.message);
}
app.alertSuccess('[[flags:updated]]');
Detail.reloadHistory(history);
});
break;
case 'update':
socket.emit('flags.update', {
flagId: ajaxify.data.flagId,
data: $('#attributes').serializeArray(),
}, function (err, history) {
if (err) {
return app.alertError(err.message);
}
app.alertSuccess('[[flags:updated]]');
Detail.reloadHistory(history);
});
break;
case 'appendNote':
socket.emit('flags.appendNote', {
flagId: ajaxify.data.flagId,
note: document.getElementById('note').value,
}, function (err, payload) {
if (err) {
return app.alertError(err.message);
}
app.alertSuccess('[[flags:note-added]]');
Detail.reloadNotes(payload.notes);
Detail.reloadHistory(payload.history);
});
break;
case 'appendNote':
socket.emit('flags.appendNote', {
flagId: ajaxify.data.flagId,
note: document.getElementById('note').value,
}, function (err, payload) {
if (err) {
return app.alertError(err.message);
}
app.alertSuccess('[[flags:note-added]]');
Detail.reloadNotes(payload.notes);
Detail.reloadHistory(payload.history);
});
break;
case 'chat':
app.newChat(uid);
break;
case 'chat':
app.newChat(uid);
break;
case 'ban':
AccountHeader.banAccount(uid, ajaxify.refresh);
break;
case 'ban':
AccountHeader.banAccount(uid, ajaxify.refresh);
break;
case 'delete':
AccountHeader.deleteAccount(uid, ajaxify.refresh);
break;
case 'delete':
AccountHeader.deleteAccount(uid, ajaxify.refresh);
break;
}
});

@ -63,69 +63,69 @@ define('forum/groups/details', [
var action = btnEl.attr('data-action');
switch (action) {
case 'toggleOwnership':
socket.emit('groups.' + (isOwner ? 'rescind' : 'grant'), {
toUid: uid,
groupName: groupName,
}, function (err) {
if (!err) {
ownerFlagEl.toggleClass('invisible');
} else {
app.alertError(err.message);
}
});
break;
case 'kick':
translator.translate('[[groups:details.kick_confirm]]', function (translated) {
bootbox.confirm(translated, function (confirm) {
if (!confirm) {
return;
case 'toggleOwnership':
socket.emit('groups.' + (isOwner ? 'rescind' : 'grant'), {
toUid: uid,
groupName: groupName,
}, function (err) {
if (!err) {
ownerFlagEl.toggleClass('invisible');
} else {
app.alertError(err.message);
}
});
break;
socket.emit('groups.kick', {
uid: uid,
groupName: groupName,
}, function (err) {
if (!err) {
userRow.slideUp().remove();
} else {
app.alertError(err.message);
case 'kick':
translator.translate('[[groups:details.kick_confirm]]', function (translated) {
bootbox.confirm(translated, function (confirm) {
if (!confirm) {
return;
}
socket.emit('groups.kick', {
uid: uid,
groupName: groupName,
}, function (err) {
if (!err) {
userRow.slideUp().remove();
} else {
app.alertError(err.message);
}
});
});
});
});
break;
case 'update':
Details.update();
break;
case 'delete':
Details.deleteGroup();
break;
case 'join': // intentional fall-throughs!
case 'leave':
case 'accept':
case 'reject':
case 'issueInvite':
case 'rescindInvite':
case 'acceptInvite':
case 'rejectInvite':
case 'acceptAll':
case 'rejectAll':
socket.emit('groups.' + action, {
toUid: uid,
groupName: groupName,
}, function (err) {
if (!err) {
ajaxify.refresh();
} else {
app.alertError(err.message);
}
});
break;
break;
case 'update':
Details.update();
break;
case 'delete':
Details.deleteGroup();
break;
case 'join': // intentional fall-throughs!
case 'leave':
case 'accept':
case 'reject':
case 'issueInvite':
case 'rescindInvite':
case 'acceptInvite':
case 'rejectInvite':
case 'acceptAll':
case 'rejectAll':
socket.emit('groups.' + action, {
toUid: uid,
groupName: groupName,
}, function (err) {
if (!err) {
ajaxify.refresh();
} else {
app.alertError(err.message);
}
});
break;
}
});
};

@ -107,16 +107,16 @@ $('document').ready(function () {
}
switch (type) {
case 'admin:username':
return validateUsername(field);
case 'admin:password':
return validatePassword(field);
case 'admin:passwordConfirm':
return validateConfirmPassword(field);
case 'admin:email':
return validateEmail(field);
case 'database':
return switchDatabase(field);
case 'admin:username':
return validateUsername(field);
case 'admin:password':
return validatePassword(field);
case 'admin:passwordConfirm':
return validateConfirmPassword(field);
case 'admin:email':
return validateEmail(field);
case 'database':
return switchDatabase(field);
}
}

@ -225,49 +225,49 @@
var icons = '';
switch (data.platform) {
case 'Linux':
icons += '<i class="fa fa-fw fa-linux"></i>';
break;
case 'Microsoft Windows':
icons += '<i class="fa fa-fw fa-windows"></i>';
break;
case 'Apple Mac':
icons += '<i class="fa fa-fw fa-apple"></i>';
break;
case 'Android':
icons += '<i class="fa fa-fw fa-android"></i>';
break;
case 'iPad':
icons += '<i class="fa fa-fw fa-tablet"></i>';
break;
case 'iPod': // intentional fall-through
case 'iPhone':
icons += '<i class="fa fa-fw fa-mobile"></i>';
break;
default:
icons += '<i class="fa fa-fw fa-question-circle"></i>';
break;
case 'Linux':
icons += '<i class="fa fa-fw fa-linux"></i>';
break;
case 'Microsoft Windows':
icons += '<i class="fa fa-fw fa-windows"></i>';
break;
case 'Apple Mac':
icons += '<i class="fa fa-fw fa-apple"></i>';
break;
case 'Android':
icons += '<i class="fa fa-fw fa-android"></i>';
break;
case 'iPad':
icons += '<i class="fa fa-fw fa-tablet"></i>';
break;
case 'iPod': // intentional fall-through
case 'iPhone':
icons += '<i class="fa fa-fw fa-mobile"></i>';
break;
default:
icons += '<i class="fa fa-fw fa-question-circle"></i>';
break;
}
switch (data.browser) {
case 'Chrome':
icons += '<i class="fa fa-fw fa-chrome"></i>';
break;
case 'Firefox':
icons += '<i class="fa fa-fw fa-firefox"></i>';
break;
case 'Safari':
icons += '<i class="fa fa-fw fa-safari"></i>';
break;
case 'IE':
icons += '<i class="fa fa-fw fa-internet-explorer"></i>';
break;
case 'Edge':
icons += '<i class="fa fa-fw fa-edge"></i>';
break;
default:
icons += '<i class="fa fa-fw fa-question-circle"></i>';
break;
case 'Chrome':
icons += '<i class="fa fa-fw fa-chrome"></i>';
break;
case 'Firefox':
icons += '<i class="fa fa-fw fa-firefox"></i>';
break;
case 'Safari':
icons += '<i class="fa fa-fw fa-safari"></i>';
break;
case 'IE':
icons += '<i class="fa fa-fw fa-internet-explorer"></i>';
break;
case 'Edge':
icons += '<i class="fa fa-fw fa-edge"></i>';
break;
default:
icons += '<i class="fa fa-fw fa-question-circle"></i>';
break;
}
return icons;

@ -141,28 +141,28 @@ define('settings/key', function () {
for (var i = 0; i < parts.length; i += 1) {
var part = parts[i];
switch (part) {
case 'C':
case 'Ctrl':
key.c = true;
break;
case 'A':
case 'Alt':
key.a = true;
break;
case 'S':
case 'Shift':
key.s = true;
break;
case 'M':
case 'Meta':
key.m = true;
break;
default:
var num = /\d+/.exec(part);
if (num != null) {
key.code = num[0];
}
key.char = convertKeyCodeToChar(key.code);
case 'C':
case 'Ctrl':
key.c = true;
break;
case 'A':
case 'Alt':
key.a = true;
break;
case 'S':
case 'Shift':
key.s = true;
break;
case 'M':
case 'Meta':
key.m = true;
break;
default:
var num = /\d+/.exec(part);
if (num != null) {
key.code = num[0];
}
key.char = convertKeyCodeToChar(key.code);
}
}
return key;

@ -183,18 +183,18 @@ define('taskbar', ['benchpress', 'translator'], function (Benchpress, translator
var processUpdate = function (element, key, value) {
switch (key) {
case 'title':
element.find('[component="taskbar/title"]').text(value);
break;
case 'icon':
element.find('i').attr('class', 'fa fa-' + value);
break;
case 'image':
element.find('a').css('background-image', 'url("' + value + '")');
break;
case 'background-color':
element.find('a').css('background-color', value);
break;
case 'title':
element.find('[component="taskbar/title"]').text(value);
break;
case 'icon':
element.find('i').attr('class', 'fa fa-' + value);
break;
case 'image':
element.find('a').css('background-image', 'url("' + value + '")');
break;
case 'background-color':
element.find('a').css('background-color', value);
break;
}
};

@ -109,30 +109,30 @@ app.isConnected = false;
var room;
switch (url_parts[0]) {
case 'user':
room = 'user/' + (ajaxify.data ? ajaxify.data.theirid : 0);
break;
case 'topic':
room = 'topic_' + url_parts[1];
break;
case 'category':
room = 'category_' + url_parts[1];
break;
case 'recent':
room = 'recent_topics';
break;
case 'unread':
room = 'unread_topics';
break;
case 'popular':
room = 'popular_topics';
break;
case 'admin':
room = 'admin';
break;
case 'categories':
room = 'categories';
break;
case 'user':
room = 'user/' + (ajaxify.data ? ajaxify.data.theirid : 0);
break;
case 'topic':
room = 'topic_' + url_parts[1];
break;
case 'category':
room = 'category_' + url_parts[1];
break;
case 'recent':
room = 'recent_topics';
break;
case 'unread':
room = 'unread_topics';
break;
case 'popular':
room = 'popular_topics';
break;
case 'admin':
room = 'admin';
break;
case 'categories':
room = 'categories';
break;
}
app.currentRoom = '';
app.enterRoom(room);

@ -175,15 +175,15 @@ function info() {
var config = require('../../config.json');
switch (config.database) {
case 'redis':
console.log(' version: ' + info.redis_version);
console.log(' disk sync: ' + info.rdb_last_bgsave_status);
break;
case 'mongo':
console.log(' version: ' + info.version);
console.log(' engine: ' + info.storageEngine);
break;
case 'redis':
console.log(' version: ' + info.redis_version);
console.log(' disk sync: ' + info.rdb_last_bgsave_status);
break;
case 'mongo':
console.log(' version: ' + info.version);
console.log(' engine: ' + info.storageEngine);
break;
}
next();

@ -43,17 +43,17 @@ function installAll() {
const packageManager = require('nconf').get('package_manager');
if (supportedPackageManagerList.indexOf(packageManager) >= 0) {
switch (packageManager) {
case 'yarn':
command = 'yarn';
break;
case 'pnpm':
command = 'pnpm install';
break;
case 'cnpm':
command = 'cnpm install';
break;
default:
break;
case 'yarn':
command = 'yarn';
break;
case 'pnpm':
command = 'pnpm install';
break;
case 'cnpm':
command = 'cnpm install';
break;
default:
break;
}
}
} catch (e) {

@ -151,25 +151,25 @@ userController.exportUploads = function (req, res, next) {
archive.on('warning', function (err) {
switch (err.code) {
case 'ENOENT':
winston.warn('[user/export/uploads] File not found: ' + trimPath(err.path));
break;
case 'ENOENT':
winston.warn('[user/export/uploads] File not found: ' + trimPath(err.path));
break;
default:
winston.warn('[user/export/uploads] Unexpected warning: ' + err.message);
break;
default:
winston.warn('[user/export/uploads] Unexpected warning: ' + err.message);
break;
}
});
archive.on('error', function (err) {
switch (err.code) {
case 'EACCES':
winston.error('[user/export/uploads] File inaccessible: ' + trimPath(err.path));
break;
case 'EACCES':
winston.error('[user/export/uploads] File inaccessible: ' + trimPath(err.path));
break;
default:
winston.error('[user/export/uploads] Unable to construct archive: ' + err.message);
break;
default:
winston.error('[user/export/uploads] Unable to construct archive: ' + err.message);
break;
}
res.sendStatus(500);

@ -63,9 +63,9 @@ Flags.init = async function () {
perPage: function () { /* noop */ },
quick: function (sets, orSets, key, uid) {
switch (key) {
case 'mine':
sets.push('flags:byAssignee:' + uid);
break;
case 'mine':
sets.push('flags:byAssignee:' + uid);
break;
}
},
},

@ -31,18 +31,18 @@ module.exports = function (Groups) {
Groups.sort = function (strategy, groups) {
switch (strategy) {
case 'count':
groups.sort((a, b) => a.slug > b.slug)
.sort((a, b) => b.memberCount - a.memberCount);
break;
case 'count':
groups.sort((a, b) => a.slug > b.slug)
.sort((a, b) => b.memberCount - a.memberCount);
break;
case 'date':
groups.sort((a, b) => b.createtime - a.createtime);
break;
case 'date':
groups.sort((a, b) => b.createtime - a.createtime);
break;
case 'alpha': // intentional fall-through
default:
groups.sort((a, b) => (a.slug > b.slug ? 1 : -1));
case 'alpha': // intentional fall-through
default:
groups.sort((a, b) => (a.slug > b.slug ? 1 : -1));
}
return groups;

@ -87,44 +87,44 @@ async function getThemes(themePath) {
Themes.set = async (data) => {
switch (data.type) {
case 'local': {
const current = await Meta.configs.get('theme:id');
if (current !== data.id) {
let config = await fsReadfile(path.join(nconf.get('themes_path'), data.id, 'theme.json'), 'utf8');
config = JSON.parse(config);
await db.sortedSetRemove('plugins:active', current);
const numPlugins = await db.sortedSetCard('plugins:active');
await db.sortedSetAdd('plugins:active', numPlugins, data.id);
// Re-set the themes path (for when NodeBB is reloaded)
Themes.setPath(config);
case 'local': {
const current = await Meta.configs.get('theme:id');
if (current !== data.id) {
let config = await fsReadfile(path.join(nconf.get('themes_path'), data.id, 'theme.json'), 'utf8');
config = JSON.parse(config);
await db.sortedSetRemove('plugins:active', current);
const numPlugins = await db.sortedSetCard('plugins:active');
await db.sortedSetAdd('plugins:active', numPlugins, data.id);
// Re-set the themes path (for when NodeBB is reloaded)
Themes.setPath(config);
await Meta.configs.setMultiple({
'theme:type': data.type,
'theme:id': data.id,
'theme:staticDir': config.staticDir ? config.staticDir : '',
'theme:templates': config.templates ? config.templates : '',
'theme:src': '',
bootswatchSkin: '',
});
await events.log({
type: 'theme-set',
uid: parseInt(data.uid, 10) || 0,
ip: data.ip || '127.0.0.1',
text: data.id,
});
Meta.reloadRequired = true;
}
break;
}
case 'bootswatch':
await Meta.configs.setMultiple({
'theme:type': data.type,
'theme:id': data.id,
'theme:staticDir': config.staticDir ? config.staticDir : '',
'theme:templates': config.templates ? config.templates : '',
'theme:src': '',
bootswatchSkin: '',
});
await events.log({
type: 'theme-set',
uid: parseInt(data.uid, 10) || 0,
ip: data.ip || '127.0.0.1',
text: data.id,
'theme:src': data.src,
bootswatchSkin: data.id.toLowerCase(),
});
Meta.reloadRequired = true;
}
break;
}
case 'bootswatch':
await Meta.configs.setMultiple({
'theme:src': data.src,
bootswatchSkin: data.id.toLowerCase(),
});
break;
break;
}
};

@ -373,30 +373,30 @@ Notifications.merge = async function (notifications) {
}
switch (mergeId) {
case 'notifications:upvoted_your_post_in':
case 'notifications:user_started_following_you':
case 'notifications:user_posted_to':
case 'notifications:user_flagged_post_in':
case 'notifications:user_flagged_user':
var usernames = _.uniq(set.map(notifObj => notifObj && notifObj.user && notifObj.user.username));
var numUsers = usernames.length;
var title = utils.decodeHTMLEntities(notifications[modifyIndex].topicTitle || '');
var titleEscaped = title.replace(/%/g, '&#37;').replace(/,/g, '&#44;');
titleEscaped = titleEscaped ? (', ' + titleEscaped) : '';
if (numUsers === 2) {
notifications[modifyIndex].bodyShort = '[[' + mergeId + '_dual, ' + usernames.join(', ') + titleEscaped + ']]';
} else if (numUsers > 2) {
notifications[modifyIndex].bodyShort = '[[' + mergeId + '_multiple, ' + usernames[0] + ', ' + (numUsers - 1) + titleEscaped + ']]';
}
notifications[modifyIndex].path = set[set.length - 1].path;
break;
case 'new_register':
notifications[modifyIndex].bodyShort = '[[notifications:' + mergeId + '_multiple, ' + set.length + ']]';
break;
case 'notifications:upvoted_your_post_in':
case 'notifications:user_started_following_you':
case 'notifications:user_posted_to':
case 'notifications:user_flagged_post_in':
case 'notifications:user_flagged_user':
var usernames = _.uniq(set.map(notifObj => notifObj && notifObj.user && notifObj.user.username));
var numUsers = usernames.length;
var title = utils.decodeHTMLEntities(notifications[modifyIndex].topicTitle || '');
var titleEscaped = title.replace(/%/g, '&#37;').replace(/,/g, '&#44;');
titleEscaped = titleEscaped ? (', ' + titleEscaped) : '';
if (numUsers === 2) {
notifications[modifyIndex].bodyShort = '[[' + mergeId + '_dual, ' + usernames.join(', ') + titleEscaped + ']]';
} else if (numUsers > 2) {
notifications[modifyIndex].bodyShort = '[[' + mergeId + '_multiple, ' + usernames[0] + ', ' + (numUsers - 1) + titleEscaped + ']]';
}
notifications[modifyIndex].path = set[set.length - 1].path;
break;
case 'new_register':
notifications[modifyIndex].bodyShort = '[[notifications:' + mergeId + '_multiple, ' + set.length + ']]';
break;
}
// Filter out duplicates

@ -90,20 +90,20 @@ module.exports = function (Plugins) {
// clear old data before build
fields.forEach((field) => {
switch (field) {
case 'clientScripts':
case 'acpScripts':
case 'cssFiles':
case 'lessFiles':
case 'acpLessFiles':
Plugins[field].length = 0;
break;
case 'soundpack':
Plugins.soundpacks.length = 0;
break;
case 'languageData':
Plugins.languageData.languages = [];
Plugins.languageData.namespaces = [];
break;
case 'clientScripts':
case 'acpScripts':
case 'cssFiles':
case 'lessFiles':
case 'acpLessFiles':
Plugins[field].length = 0;
break;
case 'soundpack':
Plugins.soundpacks.length = 0;
break;
case 'languageData':
Plugins.languageData.languages = [];
Plugins.languageData.namespaces = [];
break;
// do nothing for modules and staticDirs
}
});

@ -15,55 +15,55 @@ Email.test = function (socket, data, callback) {
};
switch (data.template) {
case 'digest':
userDigest.execute({
interval: 'alltime',
subscribers: [socket.uid],
}, callback);
break;
case 'digest':
userDigest.execute({
interval: 'alltime',
subscribers: [socket.uid],
}, callback);
break;
case 'banned':
Object.assign(payload, {
username: 'test-user',
until: utils.toISOString(Date.now()),
reason: 'Test Reason',
});
emailer.send(data.template, socket.uid, payload, callback);
break;
case 'banned':
Object.assign(payload, {
username: 'test-user',
until: utils.toISOString(Date.now()),
reason: 'Test Reason',
});
emailer.send(data.template, socket.uid, payload, callback);
break;
case 'welcome':
userEmail.sendValidationEmail(socket.uid, {
force: 1,
}, callback);
break;
case 'welcome':
userEmail.sendValidationEmail(socket.uid, {
force: 1,
}, callback);
break;
case 'notification':
async.waterfall([
function (next) {
notifications.create({
type: 'test',
bodyShort: '[[email:notif.test.short]]',
bodyLong: '[[email:notif.test.long]]',
nid: 'uid:' + socket.uid + ':test',
path: '/',
from: socket.uid,
}, next);
},
function (notifObj, next) {
emailer.send('notification', socket.uid, {
path: notifObj.path,
subject: utils.stripHTMLTags(notifObj.subject || '[[notifications:new_notification]]'),
intro: utils.stripHTMLTags(notifObj.bodyShort),
body: notifObj.bodyLong || '',
notification: notifObj,
showUnsubscribe: true,
}, next);
},
], callback);
break;
case 'notification':
async.waterfall([
function (next) {
notifications.create({
type: 'test',
bodyShort: '[[email:notif.test.short]]',
bodyLong: '[[email:notif.test.long]]',
nid: 'uid:' + socket.uid + ':test',
path: '/',
from: socket.uid,
}, next);
},
function (notifObj, next) {
emailer.send('notification', socket.uid, {
path: notifObj.path,
subject: utils.stripHTMLTags(notifObj.subject || '[[notifications:new_notification]]'),
intro: utils.stripHTMLTags(notifObj.bodyShort),
body: notifObj.bodyLong || '',
notification: notifObj,
showUnsubscribe: true,
}, next);
},
], callback);
break;
default:
emailer.send(data.template, socket.uid, payload, callback);
break;
default:
emailer.send(data.template, socket.uid, payload, callback);
break;
}
};

@ -50,17 +50,17 @@ start.start = async function () {
}
} catch (err) {
switch (err.message) {
case 'dependencies-out-of-date':
winston.error('One or more of NodeBB\'s dependent packages are out-of-date. Please run the following command to update them:');
winston.error(' ./nodebb upgrade');
break;
case 'dependencies-missing':
winston.error('One or more of NodeBB\'s dependent packages are missing. Please run the following command to update them:');
winston.error(' ./nodebb upgrade');
break;
default:
winston.error(err.stack);
break;
case 'dependencies-out-of-date':
winston.error('One or more of NodeBB\'s dependent packages are out-of-date. Please run the following command to update them:');
winston.error(' ./nodebb upgrade');
break;
case 'dependencies-missing':
winston.error('One or more of NodeBB\'s dependent packages are missing. Please run the following command to update them:');
winston.error(' ./nodebb upgrade');
break;
default:
winston.error(err.stack);
break;
}
// Either way, bad stuff happened. Abort start.

Loading…
Cancel
Save