mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 17:16:14 +01:00
Remove sounds (#8617)
* feat: remove sounds * feat: remove more sounds * feat: disable sounds plugin * fix: openapi
This commit is contained in:
committed by
GitHub
parent
251ea79bd2
commit
5f10d67db5
@@ -7,7 +7,6 @@ node_modules/
|
|||||||
logs/
|
logs/
|
||||||
/public/templates
|
/public/templates
|
||||||
/public/uploads
|
/public/uploads
|
||||||
/public/sounds
|
|
||||||
/public/vendor
|
/public/vendor
|
||||||
/public/src/modules/string.js
|
/public/src/modules/string.js
|
||||||
.idea/
|
.idea/
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -28,7 +28,6 @@ pidfile
|
|||||||
# templates
|
# templates
|
||||||
/public/templates
|
/public/templates
|
||||||
|
|
||||||
/public/sounds
|
|
||||||
/public/uploads
|
/public/uploads
|
||||||
/test/uploads
|
/test/uploads
|
||||||
|
|
||||||
|
|||||||
@@ -393,75 +393,6 @@ paths:
|
|||||||
type: integer
|
type: integer
|
||||||
description: Whether the forum will attempt to guess language based on browser's `Accept-Language` header
|
description: Whether the forum will attempt to guess language based on browser's `Accept-Language` header
|
||||||
- $ref: components/schemas/CommonProps.yaml#/CommonProps
|
- $ref: components/schemas/CommonProps.yaml#/CommonProps
|
||||||
/api/admin/settings/sounds:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- admin
|
|
||||||
summary: Get sound settings
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
description: A JSON object containing available sounds and settings
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
allOf:
|
|
||||||
- type: object
|
|
||||||
properties:
|
|
||||||
notification-sound:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
sounds:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
value:
|
|
||||||
type: string
|
|
||||||
selected:
|
|
||||||
type: boolean
|
|
||||||
chat-incoming-sound:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
sounds:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
value:
|
|
||||||
type: string
|
|
||||||
selected:
|
|
||||||
type: boolean
|
|
||||||
chat-outgoing-sound:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
sounds:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
value:
|
|
||||||
type: string
|
|
||||||
selected:
|
|
||||||
type: boolean
|
|
||||||
- $ref: components/schemas/CommonProps.yaml#/CommonProps
|
|
||||||
/api/admin/settings/navigation:
|
/api/admin/settings/navigation:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@@ -2689,33 +2620,6 @@ paths:
|
|||||||
url:
|
url:
|
||||||
type: string
|
type: string
|
||||||
description: URL of the uploaded image for use client-side
|
description: URL of the uploaded image for use client-side
|
||||||
/api/admin/upload/sound:
|
|
||||||
post:
|
|
||||||
tags:
|
|
||||||
- admin
|
|
||||||
summary: Upload sound file
|
|
||||||
requestBody:
|
|
||||||
required: true
|
|
||||||
content:
|
|
||||||
multipart/form-data:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
files:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
format: binary
|
|
||||||
required:
|
|
||||||
- files
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
description: "Sound uploaded"
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
properties: {}
|
|
||||||
/api/admin/upload/file:
|
/api/admin/upload/file:
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
@@ -7437,12 +7341,6 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
scrollToMyPost:
|
scrollToMyPost:
|
||||||
type: boolean
|
type: boolean
|
||||||
notificationSound:
|
|
||||||
type: string
|
|
||||||
incomingChatSound:
|
|
||||||
type: string
|
|
||||||
outgoingChatSound:
|
|
||||||
type: string
|
|
||||||
notificationType_new-chat:
|
notificationType_new-chat:
|
||||||
type: string
|
type: string
|
||||||
notificationType_new-reply:
|
notificationType_new-reply:
|
||||||
@@ -7541,87 +7439,6 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
selected:
|
selected:
|
||||||
type: boolean
|
type: boolean
|
||||||
notification-sound:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
sounds:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
value:
|
|
||||||
type: string
|
|
||||||
selected:
|
|
||||||
type: boolean
|
|
||||||
notificationSound:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
selected:
|
|
||||||
type: boolean
|
|
||||||
chat-incoming-sound:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
sounds:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
value:
|
|
||||||
type: string
|
|
||||||
selected:
|
|
||||||
type: boolean
|
|
||||||
incomingChatSound:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
selected:
|
|
||||||
type: boolean
|
|
||||||
chat-outgoing-sound:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
sounds:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
value:
|
|
||||||
type: string
|
|
||||||
selected:
|
|
||||||
type: boolean
|
|
||||||
outgoingChatSound:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
selected:
|
|
||||||
type: boolean
|
|
||||||
customSettings:
|
customSettings:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
|
|||||||
@@ -121,12 +121,7 @@ define('admin/settings', ['uploader'], function (uploader) {
|
|||||||
showHelp: uploadBtn.attr('data-help') ? uploadBtn.attr('data-help') === 1 : undefined,
|
showHelp: uploadBtn.attr('data-help') ? uploadBtn.attr('data-help') === 1 : undefined,
|
||||||
accept: uploadBtn.attr('data-accept'),
|
accept: uploadBtn.attr('data-accept'),
|
||||||
}, function (image) {
|
}, function (image) {
|
||||||
// need to move these into template, ex data-callback
|
$('#' + uploadBtn.attr('data-target')).val(image);
|
||||||
if (ajaxify.currentPage === 'admin/settings/sounds') {
|
|
||||||
ajaxify.refresh();
|
|
||||||
} else {
|
|
||||||
$('#' + uploadBtn.attr('data-target')).val(image);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
|
|
||||||
define('admin/settings/sounds', ['sounds', 'settings', 'admin/settings'], function (Sounds, Settings, AdminSettings) {
|
|
||||||
var SoundsAdmin = {};
|
|
||||||
|
|
||||||
SoundsAdmin.init = function () {
|
|
||||||
// Sounds tab
|
|
||||||
$('.sounds').find('button[data-action="play"]').on('click', function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
var soundName = $(this).parent().parent().find('select')
|
|
||||||
.val();
|
|
||||||
Sounds.playSound(soundName);
|
|
||||||
});
|
|
||||||
|
|
||||||
AdminSettings.prepare();
|
|
||||||
};
|
|
||||||
|
|
||||||
return SoundsAdmin;
|
|
||||||
});
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('forum/account/settings', ['forum/account/header', 'components', 'sounds', 'translator'], function (header, components, sounds, translator) {
|
define('forum/account/settings', ['forum/account/header', 'components', 'translator'], function (header, components, translator) {
|
||||||
var AccountSettings = {};
|
var AccountSettings = {};
|
||||||
|
|
||||||
// If page skin is changed but not saved, switch the skin back
|
// If page skin is changed but not saved, switch the skin back
|
||||||
@@ -36,14 +36,6 @@ define('forum/account/settings', ['forum/account/header', 'components', 'sounds'
|
|||||||
|
|
||||||
$('[data-property="homePageRoute"]').on('change', toggleCustomRoute);
|
$('[data-property="homePageRoute"]').on('change', toggleCustomRoute);
|
||||||
|
|
||||||
$('.account').find('button[data-action="play"]').on('click', function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
var soundName = $(this).parent().parent().find('select')
|
|
||||||
.val();
|
|
||||||
sounds.playSound(soundName);
|
|
||||||
});
|
|
||||||
|
|
||||||
toggleCustomRoute();
|
toggleCustomRoute();
|
||||||
|
|
||||||
components.get('user/sessions').find('.timeago').timeago();
|
components.get('user/sessions').find('.timeago').timeago();
|
||||||
@@ -93,8 +85,6 @@ define('forum/account/settings', ['forum/account/header', 'components', 'sounds'
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sounds.loadMap();
|
|
||||||
|
|
||||||
if (languageChanged && parseInt(app.user.uid, 10) === parseInt(ajaxify.data.theirid, 10)) {
|
if (languageChanged && parseInt(app.user.uid, 10) === parseInt(ajaxify.data.theirid, 10)) {
|
||||||
translator.translate('[[language:dir]]', config.userLang, function (translated) {
|
translator.translate('[[language:dir]]', config.userLang, function (translated) {
|
||||||
var htmlEl = $('html');
|
var htmlEl = $('html');
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('forum/chats/messages', ['components', 'sounds', 'translator', 'benchpress'], function (components, sounds, translator, Benchpress) {
|
define('forum/chats/messages', ['components', 'translator', 'benchpress'], function (components, translator, Benchpress) {
|
||||||
var messages = {};
|
var messages = {};
|
||||||
|
|
||||||
messages.sendMessage = function (roomId, inputEl) {
|
messages.sendMessage = function (roomId, inputEl) {
|
||||||
@@ -41,8 +41,6 @@ define('forum/chats/messages', ['components', 'sounds', 'translator', 'benchpres
|
|||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
sounds.play('chat-outgoing');
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
socket.emit('modules.chats.edit', {
|
socket.emit('modules.chats.edit', {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('notifications', ['sounds', 'translator', 'components', 'navigator', 'benchpress'], function (sounds, translator, components, navigator, Benchpress) {
|
define('notifications', ['translator', 'components', 'navigator', 'benchpress'], function (translator, components, navigator, Benchpress) {
|
||||||
var Notifications = {};
|
var Notifications = {};
|
||||||
|
|
||||||
var unreadNotifs = {};
|
var unreadNotifs = {};
|
||||||
@@ -68,7 +68,6 @@ define('notifications', ['sounds', 'translator', 'components', 'navigator', 'ben
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!unreadNotifs[notifData.nid]) {
|
if (!unreadNotifs[notifData.nid]) {
|
||||||
sounds.play('notification', notifData.nid);
|
|
||||||
unreadNotifs[notifData.nid] = true;
|
unreadNotifs[notifData.nid] = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,95 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
|
|
||||||
define('sounds', ['storage'], function (storage) {
|
|
||||||
var Sounds = {};
|
|
||||||
|
|
||||||
var fileMap;
|
|
||||||
var soundMap;
|
|
||||||
var cache = {};
|
|
||||||
|
|
||||||
Sounds.loadMap = function loadMap(callback) {
|
|
||||||
socket.emit('modules.sounds.getUserSoundMap', function (err, map) {
|
|
||||||
if (err) {
|
|
||||||
return app.alertError(err.message);
|
|
||||||
}
|
|
||||||
soundMap = map;
|
|
||||||
if (callback) {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
function loadData(callback) {
|
|
||||||
var outstanding = 2;
|
|
||||||
function after() {
|
|
||||||
outstanding -= 1;
|
|
||||||
if (outstanding === 0 && callback) {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fileMap) {
|
|
||||||
outstanding -= 1;
|
|
||||||
} else {
|
|
||||||
$.getJSON(config.relative_path + '/assets/sounds/fileMap.json', function (map) {
|
|
||||||
fileMap = map;
|
|
||||||
after();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Sounds.loadMap(after);
|
|
||||||
}
|
|
||||||
|
|
||||||
Sounds.playSound = function playSound(soundName) {
|
|
||||||
if (!soundMap || !fileMap) {
|
|
||||||
return loadData(after);
|
|
||||||
}
|
|
||||||
|
|
||||||
function after() {
|
|
||||||
if (!fileMap[soundName]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var audio = cache[soundName] || new Audio(config.relative_path + '/assets/sounds/' + fileMap[soundName]);
|
|
||||||
cache[soundName] = audio;
|
|
||||||
audio.pause();
|
|
||||||
audio.currentTime = 0;
|
|
||||||
audio.play();
|
|
||||||
}
|
|
||||||
|
|
||||||
after();
|
|
||||||
};
|
|
||||||
|
|
||||||
Sounds.play = function play(type, id) {
|
|
||||||
function after() {
|
|
||||||
if (!soundMap[type]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (id) {
|
|
||||||
var item = 'sounds.handled:' + id;
|
|
||||||
if (storage.getItem(item)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
storage.setItem(item, true);
|
|
||||||
|
|
||||||
setTimeout(function () {
|
|
||||||
storage.removeItem(item);
|
|
||||||
}, 5000);
|
|
||||||
}
|
|
||||||
|
|
||||||
Sounds.playSound(soundMap[type]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!soundMap || !fileMap) {
|
|
||||||
return loadData(after);
|
|
||||||
}
|
|
||||||
|
|
||||||
after();
|
|
||||||
};
|
|
||||||
|
|
||||||
socket.on('event:sounds.reloadMapping', function () {
|
|
||||||
Sounds.loadMap();
|
|
||||||
});
|
|
||||||
|
|
||||||
return Sounds;
|
|
||||||
});
|
|
||||||
@@ -189,7 +189,7 @@ program
|
|||||||
});
|
});
|
||||||
program
|
program
|
||||||
.command('build [targets...]')
|
.command('build [targets...]')
|
||||||
.description('Compile static assets ' + '(JS, CSS, templates, languages, sounds)'.red)
|
.description('Compile static assets ' + '(JS, CSS, templates, languages)'.red)
|
||||||
.option('-s, --series', 'Run builds in series without extra processes')
|
.option('-s, --series', 'Run builds in series without extra processes')
|
||||||
.action(function (targets, options) {
|
.action(function (targets, options) {
|
||||||
require('./manage').build(targets.length ? targets : true, options);
|
require('./manage').build(targets.length ? targets : true, options);
|
||||||
|
|||||||
@@ -22,10 +22,9 @@ settingsController.get = async function (req, res, next) {
|
|||||||
if (!userData) {
|
if (!userData) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
const [settings, languagesData, soundsMapping] = await Promise.all([
|
const [settings, languagesData] = await Promise.all([
|
||||||
user.getSettings(userData.uid),
|
user.getSettings(userData.uid),
|
||||||
languages.list(),
|
languages.list(),
|
||||||
meta.sounds.getUserSoundMap(userData.uid),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
userData.settings = settings;
|
userData.settings = settings;
|
||||||
@@ -34,8 +33,6 @@ settingsController.get = async function (req, res, next) {
|
|||||||
userData.acpLanguages = _.cloneDeep(languagesData);
|
userData.acpLanguages = _.cloneDeep(languagesData);
|
||||||
}
|
}
|
||||||
|
|
||||||
addSoundSettings(userData, soundsMapping);
|
|
||||||
|
|
||||||
const data = await plugins.fireHook('filter:user.customSettings', {
|
const data = await plugins.fireHook('filter:user.customSettings', {
|
||||||
settings: settings,
|
settings: settings,
|
||||||
customSettings: [],
|
customSettings: [],
|
||||||
@@ -124,48 +121,6 @@ settingsController.get = async function (req, res, next) {
|
|||||||
res.render('account/settings', userData);
|
res.render('account/settings', userData);
|
||||||
};
|
};
|
||||||
|
|
||||||
function addSoundSettings(userData, soundsMapping) {
|
|
||||||
const types = [
|
|
||||||
'notification',
|
|
||||||
'chat-incoming',
|
|
||||||
'chat-outgoing',
|
|
||||||
];
|
|
||||||
const aliases = {
|
|
||||||
notification: 'notificationSound',
|
|
||||||
'chat-incoming': 'incomingChatSound',
|
|
||||||
'chat-outgoing': 'outgoingChatSound',
|
|
||||||
};
|
|
||||||
|
|
||||||
types.forEach(function (type) {
|
|
||||||
const soundpacks = plugins.soundpacks.map(function (pack) {
|
|
||||||
const sounds = Object.keys(pack.sounds).map(function (soundName) {
|
|
||||||
const value = pack.name + ' | ' + soundName;
|
|
||||||
return {
|
|
||||||
name: soundName,
|
|
||||||
value: value,
|
|
||||||
selected: value === soundsMapping[type],
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
name: pack.name,
|
|
||||||
sounds: sounds,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
userData[type + '-sound'] = soundpacks;
|
|
||||||
// fallback
|
|
||||||
userData[aliases[type]] = soundpacks.concat.apply([], soundpacks.map(function (pack) {
|
|
||||||
return pack.sounds.map(function (sound) {
|
|
||||||
return {
|
|
||||||
name: sound.value,
|
|
||||||
selected: sound.selected,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const unsubscribable = ['digest', 'notification'];
|
const unsubscribable = ['digest', 'notification'];
|
||||||
const jwtVerifyAsync = util.promisify(function (token, callback) {
|
const jwtVerifyAsync = util.promisify(function (token, callback) {
|
||||||
jwt.verify(token, nconf.get('secret'), (err, payload) => callback(err, payload));
|
jwt.verify(token, nconf.get('secret'), (err, payload) => callback(err, payload));
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ const emailer = require('../../emailer');
|
|||||||
const notifications = require('../../notifications');
|
const notifications = require('../../notifications');
|
||||||
const groups = require('../../groups');
|
const groups = require('../../groups');
|
||||||
const languages = require('../../languages');
|
const languages = require('../../languages');
|
||||||
const plugins = require('../../plugins');
|
|
||||||
const navigationAdmin = require('../../navigation/admin');
|
const navigationAdmin = require('../../navigation/admin');
|
||||||
const social = require('../../social');
|
const social = require('../../social');
|
||||||
|
|
||||||
@@ -61,38 +60,6 @@ settingsController.languages = async function (req, res) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
settingsController.sounds = async function (req, res) {
|
|
||||||
const types = [
|
|
||||||
'notification',
|
|
||||||
'chat-incoming',
|
|
||||||
'chat-outgoing',
|
|
||||||
];
|
|
||||||
const settings = await meta.configs.getFields(types) || {};
|
|
||||||
var output = {};
|
|
||||||
|
|
||||||
types.forEach(function (type) {
|
|
||||||
var soundpacks = plugins.soundpacks.map(function (pack) {
|
|
||||||
var sounds = Object.keys(pack.sounds).map(function (soundName) {
|
|
||||||
var value = pack.name + ' | ' + soundName;
|
|
||||||
return {
|
|
||||||
name: soundName,
|
|
||||||
value: value,
|
|
||||||
selected: value === settings[type],
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
name: pack.name,
|
|
||||||
sounds: sounds,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
output[type + '-sound'] = soundpacks;
|
|
||||||
});
|
|
||||||
|
|
||||||
res.render('admin/settings/sounds', output);
|
|
||||||
};
|
|
||||||
|
|
||||||
settingsController.navigation = async function (req, res) {
|
settingsController.navigation = async function (req, res) {
|
||||||
const [admin, allGroups] = await Promise.all([
|
const [admin, allGroups] = await Promise.all([
|
||||||
navigationAdmin.getAdmin(),
|
navigationAdmin.getAdmin(),
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const nconf = require('nconf');
|
const nconf = require('nconf');
|
||||||
const mime = require('mime');
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const meta = require('../../meta');
|
const meta = require('../../meta');
|
||||||
@@ -171,24 +170,6 @@ uploadsController.uploadLogo = async function (req, res, next) {
|
|||||||
await upload('site-logo', req, res, next);
|
await upload('site-logo', req, res, next);
|
||||||
};
|
};
|
||||||
|
|
||||||
uploadsController.uploadSound = async function (req, res, next) {
|
|
||||||
const uploadedFile = req.files.files[0];
|
|
||||||
|
|
||||||
const mimeType = mime.getType(uploadedFile.name);
|
|
||||||
if (!/^audio\//.test(mimeType)) {
|
|
||||||
return next(Error('[[error:invalid-data]]'));
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
await file.saveFileToLocal(uploadedFile.name, 'sounds', uploadedFile.path);
|
|
||||||
await meta.sounds.build();
|
|
||||||
res.json([{}]);
|
|
||||||
} catch (err) {
|
|
||||||
next(err);
|
|
||||||
} finally {
|
|
||||||
file.delete(uploadedFile.path);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
uploadsController.uploadFile = async function (req, res, next) {
|
uploadsController.uploadFile = async function (req, res, next) {
|
||||||
const uploadedFile = req.files.files[0];
|
const uploadedFile = req.files.files[0];
|
||||||
let params;
|
let params;
|
||||||
|
|||||||
@@ -323,7 +323,7 @@ async function buildCustomTemplates(config) {
|
|||||||
Benchpress.flush();
|
Benchpress.flush();
|
||||||
winston.verbose('[emailer] Built custom email templates');
|
winston.verbose('[emailer] Built custom email templates');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
winston.error('[emailer] Failed to build custom email templates', err.stack);
|
winston.error('[emailer] Failed to build custom email templates\n' + err.stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -420,7 +420,6 @@ async function enableDefaultPlugins() {
|
|||||||
'nodebb-plugin-mentions',
|
'nodebb-plugin-mentions',
|
||||||
'nodebb-widget-essentials',
|
'nodebb-widget-essentials',
|
||||||
'nodebb-rewards-essentials',
|
'nodebb-rewards-essentials',
|
||||||
'nodebb-plugin-soundpack-default',
|
|
||||||
'nodebb-plugin-emoji',
|
'nodebb-plugin-emoji',
|
||||||
'nodebb-plugin-emoji-android',
|
'nodebb-plugin-emoji-android',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -61,9 +61,6 @@ var targetHandlers = {
|
|||||||
languages: function (parallel, callback) {
|
languages: function (parallel, callback) {
|
||||||
meta.languages.build(callback);
|
meta.languages.build(callback);
|
||||||
},
|
},
|
||||||
sounds: function (parallel, callback) {
|
|
||||||
meta.sounds.build(callback);
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var aliases = {
|
var aliases = {
|
||||||
@@ -81,7 +78,6 @@ var aliases = {
|
|||||||
styles: ['css', 'less', 'style'],
|
styles: ['css', 'less', 'style'],
|
||||||
templates: ['tpl'],
|
templates: ['tpl'],
|
||||||
languages: ['lang', 'i18n'],
|
languages: ['lang', 'i18n'],
|
||||||
sounds: ['sound'],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.aliases = aliases;
|
exports.aliases = aliases;
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ Meta.configs = require('./configs');
|
|||||||
Meta.themes = require('./themes');
|
Meta.themes = require('./themes');
|
||||||
Meta.js = require('./js');
|
Meta.js = require('./js');
|
||||||
Meta.css = require('./css');
|
Meta.css = require('./css');
|
||||||
Meta.sounds = require('./sounds');
|
|
||||||
Meta.settings = require('./settings');
|
Meta.settings = require('./settings');
|
||||||
Meta.logs = require('./logs');
|
Meta.logs = require('./logs');
|
||||||
Meta.errors = require('./errors');
|
Meta.errors = require('./errors');
|
||||||
|
|||||||
@@ -1,101 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
const path = require('path');
|
|
||||||
const fs = require('fs');
|
|
||||||
const util = require('util');
|
|
||||||
|
|
||||||
let mkdirp = require('mkdirp');
|
|
||||||
mkdirp = mkdirp.hasOwnProperty('native') ? mkdirp : util.promisify(mkdirp);
|
|
||||||
|
|
||||||
const rimraf = require('rimraf');
|
|
||||||
const rimrafAsync = util.promisify(rimraf);
|
|
||||||
|
|
||||||
const file = require('../file');
|
|
||||||
const plugins = require('../plugins');
|
|
||||||
const user = require('../user');
|
|
||||||
const Meta = require('./index');
|
|
||||||
|
|
||||||
const soundsPath = path.join(__dirname, '../../build/public/sounds');
|
|
||||||
const uploadsPath = path.join(__dirname, '../../public/uploads/sounds');
|
|
||||||
|
|
||||||
const Sounds = module.exports;
|
|
||||||
|
|
||||||
Sounds.addUploads = async function addUploads() {
|
|
||||||
let files = [];
|
|
||||||
try {
|
|
||||||
files = await fs.promises.readdir(uploadsPath);
|
|
||||||
} catch (err) {
|
|
||||||
if (err.code !== 'ENOENT') {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
files = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
var uploadSounds = files.reduce(function (prev, fileName) {
|
|
||||||
var name = fileName.split('.');
|
|
||||||
if (!name.length || !name[0].length) {
|
|
||||||
return prev;
|
|
||||||
}
|
|
||||||
name = name[0];
|
|
||||||
name = name[0].toUpperCase() + name.slice(1);
|
|
||||||
|
|
||||||
prev[name] = fileName;
|
|
||||||
return prev;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
plugins.soundpacks = plugins.soundpacks.filter(pack => pack.name !== 'Uploads');
|
|
||||||
|
|
||||||
if (Object.keys(uploadSounds).length) {
|
|
||||||
plugins.soundpacks.push({
|
|
||||||
name: 'Uploads',
|
|
||||||
id: 'uploads',
|
|
||||||
dir: uploadsPath,
|
|
||||||
sounds: uploadSounds,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Sounds.build = async function build() {
|
|
||||||
await Sounds.addUploads();
|
|
||||||
|
|
||||||
var map = plugins.soundpacks.map(function (pack) {
|
|
||||||
return Object.keys(pack.sounds).reduce(function (prev, soundName) {
|
|
||||||
var soundPath = pack.sounds[soundName];
|
|
||||||
prev[pack.name + ' | ' + soundName] = pack.id + '/' + soundPath;
|
|
||||||
return prev;
|
|
||||||
}, {});
|
|
||||||
});
|
|
||||||
map.unshift({});
|
|
||||||
map = Object.assign.apply(null, map);
|
|
||||||
await rimrafAsync(soundsPath);
|
|
||||||
await mkdirp(soundsPath);
|
|
||||||
|
|
||||||
await fs.promises.writeFile(path.join(soundsPath, 'fileMap.json'), JSON.stringify(map));
|
|
||||||
|
|
||||||
await Promise.all(plugins.soundpacks.map(pack => file.linkDirs(pack.dir, path.join(soundsPath, pack.id), false)));
|
|
||||||
};
|
|
||||||
|
|
||||||
var keys = ['chat-incoming', 'chat-outgoing', 'notification'];
|
|
||||||
|
|
||||||
Sounds.getUserSoundMap = async function getUserSoundMap(uid) {
|
|
||||||
const [defaultMapping, userSettings] = await Promise.all([
|
|
||||||
Meta.configs.getFields(keys),
|
|
||||||
user.getSettings(uid),
|
|
||||||
]);
|
|
||||||
|
|
||||||
userSettings.notification = userSettings.notificationSound;
|
|
||||||
userSettings['chat-incoming'] = userSettings.incomingChatSound;
|
|
||||||
userSettings['chat-outgoing'] = userSettings.outgoingChatSound;
|
|
||||||
|
|
||||||
const soundMapping = {};
|
|
||||||
|
|
||||||
keys.forEach(function (key) {
|
|
||||||
if (userSettings[key] || userSettings[key] === '') {
|
|
||||||
soundMapping[key] = userSettings[key] || '';
|
|
||||||
} else {
|
|
||||||
soundMapping[key] = defaultMapping[key] || '';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return soundMapping;
|
|
||||||
};
|
|
||||||
@@ -216,35 +216,6 @@ Data.getModules = async function getModules(pluginData) {
|
|||||||
return modules;
|
return modules;
|
||||||
};
|
};
|
||||||
|
|
||||||
Data.getSoundpack = async function getSoundpack(pluginData) {
|
|
||||||
var spack = pluginData.soundpack;
|
|
||||||
if (!spack || !spack.dir || !spack.sounds) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var soundpack = {};
|
|
||||||
soundpack.name = spack.name || pluginData.name;
|
|
||||||
soundpack.id = pluginData.id;
|
|
||||||
soundpack.dir = path.join(pluginData.path, spack.dir);
|
|
||||||
soundpack.sounds = {};
|
|
||||||
|
|
||||||
async function processSoundPack(name) {
|
|
||||||
const soundFile = spack.sounds[name];
|
|
||||||
const exists = await file.exists(path.join(soundpack.dir, soundFile));
|
|
||||||
if (!exists) {
|
|
||||||
winston.warn('[plugins] Sound file not found: ' + soundFile);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
soundpack.sounds[name] = soundFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
await Promise.all(Object.keys(spack.sounds).map(key => processSoundPack(key)));
|
|
||||||
|
|
||||||
const len = Object.keys(soundpack.sounds).length;
|
|
||||||
winston.verbose('[plugins] Found ' + len + ' sound file(s) for plugin ' + pluginData.id);
|
|
||||||
return soundpack;
|
|
||||||
};
|
|
||||||
|
|
||||||
Data.getLanguageData = async function getLanguageData(pluginData) {
|
Data.getLanguageData = async function getLanguageData(pluginData) {
|
||||||
if (typeof pluginData.languages !== 'string') {
|
if (typeof pluginData.languages !== 'string') {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ Plugins.clientScripts = [];
|
|||||||
Plugins.acpScripts = [];
|
Plugins.acpScripts = [];
|
||||||
Plugins.libraryPaths = [];
|
Plugins.libraryPaths = [];
|
||||||
Plugins.versionWarning = [];
|
Plugins.versionWarning = [];
|
||||||
Plugins.soundpacks = [];
|
|
||||||
Plugins.languageData = {};
|
Plugins.languageData = {};
|
||||||
Plugins.loadedPlugins = [];
|
Plugins.loadedPlugins = [];
|
||||||
|
|
||||||
|
|||||||
@@ -37,9 +37,6 @@ module.exports = function (Plugins) {
|
|||||||
modules: function (next) {
|
modules: function (next) {
|
||||||
Plugins.data.getModules(pluginData, next);
|
Plugins.data.getModules(pluginData, next);
|
||||||
},
|
},
|
||||||
soundpack: function (next) {
|
|
||||||
Plugins.data.getSoundpack(pluginData, next);
|
|
||||||
},
|
|
||||||
languageData: function (next) {
|
languageData: function (next) {
|
||||||
Plugins.data.getLanguageData(pluginData, next);
|
Plugins.data.getLanguageData(pluginData, next);
|
||||||
},
|
},
|
||||||
@@ -63,9 +60,6 @@ module.exports = function (Plugins) {
|
|||||||
add(Plugins.clientScripts, results.clientScripts);
|
add(Plugins.clientScripts, results.clientScripts);
|
||||||
add(Plugins.acpScripts, results.acpScripts);
|
add(Plugins.acpScripts, results.acpScripts);
|
||||||
Object.assign(meta.js.scripts.modules, results.modules || {});
|
Object.assign(meta.js.scripts.modules, results.modules || {});
|
||||||
if (results.soundpack) {
|
|
||||||
Plugins.soundpacks.push(results.soundpack);
|
|
||||||
}
|
|
||||||
if (results.languageData) {
|
if (results.languageData) {
|
||||||
Plugins.languageData.languages = _.union(Plugins.languageData.languages, results.languageData.languages);
|
Plugins.languageData.languages = _.union(Plugins.languageData.languages, results.languageData.languages);
|
||||||
Plugins.languageData.namespaces = _.union(Plugins.languageData.namespaces, results.languageData.namespaces);
|
Plugins.languageData.namespaces = _.union(Plugins.languageData.namespaces, results.languageData.namespaces);
|
||||||
@@ -81,7 +75,6 @@ module.exports = function (Plugins) {
|
|||||||
'admin js bundle': ['acpScripts'],
|
'admin js bundle': ['acpScripts'],
|
||||||
'client side styles': ['cssFiles', 'lessFiles'],
|
'client side styles': ['cssFiles', 'lessFiles'],
|
||||||
'admin control panel styles': ['cssFiles', 'lessFiles', 'acpLessFiles'],
|
'admin control panel styles': ['cssFiles', 'lessFiles', 'acpLessFiles'],
|
||||||
sounds: ['soundpack'],
|
|
||||||
languages: ['languageData'],
|
languages: ['languageData'],
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -97,9 +90,6 @@ module.exports = function (Plugins) {
|
|||||||
case 'acpLessFiles':
|
case 'acpLessFiles':
|
||||||
Plugins[field].length = 0;
|
Plugins[field].length = 0;
|
||||||
break;
|
break;
|
||||||
case 'soundpack':
|
|
||||||
Plugins.soundpacks.length = 0;
|
|
||||||
break;
|
|
||||||
case 'languageData':
|
case 'languageData':
|
||||||
Plugins.languageData.languages = [];
|
Plugins.languageData.languages = [];
|
||||||
Plugins.languageData.namespaces = [];
|
Plugins.languageData.namespaces = [];
|
||||||
@@ -132,7 +122,7 @@ module.exports = function (Plugins) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
registerHooks(pluginData);
|
registerHooks(pluginData);
|
||||||
await registerPluginAssets(pluginData, ['soundpack']);
|
await registerPluginAssets(pluginData);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
winston.error(err.stack);
|
winston.error(err.stack);
|
||||||
winston.verbose('[plugins] Could not load plugin : ' + pluginData.id);
|
winston.verbose('[plugins] Could not load plugin : ' + pluginData.id);
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ module.exports = function (app, middleware, controllers) {
|
|||||||
helpers.setupAdminPageRoute(app, '/admin/settings/user', middleware, middlewares, controllers.admin.settings.user);
|
helpers.setupAdminPageRoute(app, '/admin/settings/user', middleware, middlewares, controllers.admin.settings.user);
|
||||||
helpers.setupAdminPageRoute(app, '/admin/settings/post', middleware, middlewares, controllers.admin.settings.post);
|
helpers.setupAdminPageRoute(app, '/admin/settings/post', middleware, middlewares, controllers.admin.settings.post);
|
||||||
helpers.setupAdminPageRoute(app, '/admin/settings/languages', middleware, middlewares, controllers.admin.settings.languages);
|
helpers.setupAdminPageRoute(app, '/admin/settings/languages', middleware, middlewares, controllers.admin.settings.languages);
|
||||||
helpers.setupAdminPageRoute(app, '/admin/settings/sounds', middleware, middlewares, controllers.admin.settings.sounds);
|
|
||||||
helpers.setupAdminPageRoute(app, '/admin/settings/navigation', middleware, middlewares, controllers.admin.settings.navigation);
|
helpers.setupAdminPageRoute(app, '/admin/settings/navigation', middleware, middlewares, controllers.admin.settings.navigation);
|
||||||
helpers.setupAdminPageRoute(app, '/admin/settings/homepage', middleware, middlewares, controllers.admin.settings.homepage);
|
helpers.setupAdminPageRoute(app, '/admin/settings/homepage', middleware, middlewares, controllers.admin.settings.homepage);
|
||||||
helpers.setupAdminPageRoute(app, '/admin/settings/social', middleware, middlewares, controllers.admin.settings.social);
|
helpers.setupAdminPageRoute(app, '/admin/settings/social', middleware, middlewares, controllers.admin.settings.social);
|
||||||
@@ -82,7 +81,6 @@ function apiRoutes(router, middleware, controllers) {
|
|||||||
router.post('/api/admin/uploadTouchIcon', middlewares, helpers.tryRoute(controllers.admin.uploads.uploadTouchIcon));
|
router.post('/api/admin/uploadTouchIcon', middlewares, helpers.tryRoute(controllers.admin.uploads.uploadTouchIcon));
|
||||||
router.post('/api/admin/uploadlogo', middlewares, helpers.tryRoute(controllers.admin.uploads.uploadLogo));
|
router.post('/api/admin/uploadlogo', middlewares, helpers.tryRoute(controllers.admin.uploads.uploadLogo));
|
||||||
router.post('/api/admin/uploadOgImage', middlewares, helpers.tryRoute(controllers.admin.uploads.uploadOgImage));
|
router.post('/api/admin/uploadOgImage', middlewares, helpers.tryRoute(controllers.admin.uploads.uploadOgImage));
|
||||||
router.post('/api/admin/upload/sound', middlewares, helpers.tryRoute(controllers.admin.uploads.uploadSound));
|
|
||||||
router.post('/api/admin/upload/file', middlewares, helpers.tryRoute(controllers.admin.uploads.uploadFile));
|
router.post('/api/admin/upload/file', middlewares, helpers.tryRoute(controllers.admin.uploads.uploadFile));
|
||||||
router.post('/api/admin/uploadDefaultAvatar', middlewares, helpers.tryRoute(controllers.admin.uploads.uploadDefaultAvatar));
|
router.post('/api/admin/uploadDefaultAvatar', middlewares, helpers.tryRoute(controllers.admin.uploads.uploadDefaultAvatar));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ const privileges = require('../privileges');
|
|||||||
const SocketModules = module.exports;
|
const SocketModules = module.exports;
|
||||||
|
|
||||||
SocketModules.chats = {};
|
SocketModules.chats = {};
|
||||||
SocketModules.sounds = {};
|
|
||||||
SocketModules.settings = {};
|
SocketModules.settings = {};
|
||||||
|
|
||||||
/* Chat */
|
/* Chat */
|
||||||
@@ -290,9 +289,4 @@ SocketModules.chats.getIP = async function (socket, mid) {
|
|||||||
return await Messaging.getMessageField(mid, 'ip');
|
return await Messaging.getMessageField(mid, 'ip');
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Sounds */
|
|
||||||
SocketModules.sounds.getUserSoundMap = async function getUserSoundMap(socket) {
|
|
||||||
return await meta.sounds.getUserSoundMap(socket.uid);
|
|
||||||
};
|
|
||||||
|
|
||||||
require('../promisify')(SocketModules);
|
require('../promisify')(SocketModules);
|
||||||
|
|||||||
11
src/upgrades/1.15.0/disable_sounds_plugin.js
Normal file
11
src/upgrades/1.15.0/disable_sounds_plugin.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const db = require('../../database');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'Disable nodebb-plugin-soundpack-default',
|
||||||
|
timestamp: Date.UTC(2020, 8, 6),
|
||||||
|
method: async function () {
|
||||||
|
await db.sortedSetRemove('plugins:active', 'nodebb-plugin-soundpack-default');
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -118,9 +118,6 @@ module.exports = function (User) {
|
|||||||
topicSearchEnabled: data.topicSearchEnabled,
|
topicSearchEnabled: data.topicSearchEnabled,
|
||||||
homePageRoute: ((data.homePageRoute === 'custom' ? data.homePageCustom : data.homePageRoute) || '').replace(/^\//, ''),
|
homePageRoute: ((data.homePageRoute === 'custom' ? data.homePageCustom : data.homePageRoute) || '').replace(/^\//, ''),
|
||||||
scrollToMyPost: data.scrollToMyPost,
|
scrollToMyPost: data.scrollToMyPost,
|
||||||
notificationSound: data.notificationSound,
|
|
||||||
incomingChatSound: data.incomingChatSound,
|
|
||||||
outgoingChatSound: data.outgoingChatSound,
|
|
||||||
upvoteNotifFreq: data.upvoteNotifFreq,
|
upvoteNotifFreq: data.upvoteNotifFreq,
|
||||||
bootswatchSkin: data.bootswatchSkin,
|
bootswatchSkin: data.bootswatchSkin,
|
||||||
categoryWatchState: data.categoryWatchState,
|
categoryWatchState: data.categoryWatchState,
|
||||||
|
|||||||
@@ -52,7 +52,6 @@
|
|||||||
<li><a href="{relative_path}/admin/settings/chat">[[admin/menu:settings/chat]]</a></li>
|
<li><a href="{relative_path}/admin/settings/chat">[[admin/menu:settings/chat]]</a></li>
|
||||||
<li><a href="{relative_path}/admin/settings/pagination">[[admin/menu:settings/pagination]]</a></li>
|
<li><a href="{relative_path}/admin/settings/pagination">[[admin/menu:settings/pagination]]</a></li>
|
||||||
<li><a href="{relative_path}/admin/settings/notifications">[[admin/menu:settings/notifications]]</a></li>
|
<li><a href="{relative_path}/admin/settings/notifications">[[admin/menu:settings/notifications]]</a></li>
|
||||||
<li><a href="{relative_path}/admin/settings/sounds">[[admin/menu:settings/sounds]]</a></li>
|
|
||||||
<li><a href="{relative_path}/admin/settings/social">[[admin/menu:settings/social]]</a></li>
|
<li><a href="{relative_path}/admin/settings/social">[[admin/menu:settings/social]]</a></li>
|
||||||
<li><a href="{relative_path}/admin/settings/cookies">[[admin/menu:settings/cookies]]</a></li>
|
<li><a href="{relative_path}/admin/settings/cookies">[[admin/menu:settings/cookies]]</a></li>
|
||||||
<li><a href="{relative_path}/admin/settings/web-crawler">[[admin/menu:settings/web-crawler]]</a></li>
|
<li><a href="{relative_path}/admin/settings/web-crawler">[[admin/menu:settings/web-crawler]]</a></li>
|
||||||
|
|||||||
@@ -1,97 +0,0 @@
|
|||||||
<div class="sounds settings row">
|
|
||||||
<div class="col-xs-12">
|
|
||||||
<form role="form">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-2 col-xs-12 settings-header">[[admin/settings/sounds:notifications]]</div>
|
|
||||||
<div class="col-sm-10 col-xs-12">
|
|
||||||
<label for="notification">[[admin/settings/sounds:notifications]]</label>
|
|
||||||
<div class="row">
|
|
||||||
<div class="form-group col-xs-9">
|
|
||||||
<select class="form-control" id="notification" data-field="notification">
|
|
||||||
<option value="">[[user:no-sound]]</option>
|
|
||||||
<!-- BEGIN notification-sound -->
|
|
||||||
<optgroup label="{notification-sound.name}">
|
|
||||||
<!-- BEGIN notification-sound.sounds -->
|
|
||||||
<option value="{notification-sound.sounds.value}" <!-- IF notification-sound.sounds.selected -->selected<!-- ENDIF notification-sound.sounds.selected -->>
|
|
||||||
{notification-sound.sounds.name}
|
|
||||||
</option>
|
|
||||||
<!-- END notification-sound.sounds -->
|
|
||||||
</optgroup>
|
|
||||||
<!-- END notification-sound -->
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="btn-group col-xs-3">
|
|
||||||
<button type="button" class="form-control btn btn-sm btn-default" data-action="play"><span class="hidden-xs">[[admin/settings/sounds:play-sound]] </span><i class="fa fa-play"></i></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-2 col-xs-12 settings-header">[[admin/settings/sounds:chat-messages]]</div>
|
|
||||||
<div class="col-sm-10 col-xs-12">
|
|
||||||
<label for="chat-incoming">[[admin/settings/sounds:incoming-message]]</label>
|
|
||||||
<div class="row">
|
|
||||||
<div class="form-group col-xs-9">
|
|
||||||
<select class="form-control" id="chat-incoming" data-field="chat-incoming">
|
|
||||||
<option value="">[[user:no-sound]]</option>
|
|
||||||
<!-- BEGIN chat-incoming-sound -->
|
|
||||||
<optgroup label="{chat-incoming-sound.name}">
|
|
||||||
<!-- BEGIN chat-incoming-sound.sounds -->
|
|
||||||
<option value="{chat-incoming-sound.sounds.value}" <!-- IF chat-incoming-sound.sounds.selected -->selected<!-- ENDIF chat-incoming-sound.sounds.selected -->>
|
|
||||||
{chat-incoming-sound.sounds.name}
|
|
||||||
</option>
|
|
||||||
<!-- END chat-incoming-sound.sounds -->
|
|
||||||
</optgroup>
|
|
||||||
<!-- END chat-incoming-sound -->
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="btn-group col-xs-3">
|
|
||||||
<button type="button" class="form-control btn btn-sm btn-default" data-action="play"><span class="hidden-xs">[[admin/settings/sounds:play-sound]] </span><i class="fa fa-play"></i></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<label for="chat-outgoing">[[admin/settings/sounds:outgoing-message]]</label>
|
|
||||||
<div class="row">
|
|
||||||
<div class="form-group col-xs-9">
|
|
||||||
<select class="form-control" id="chat-outgoing" data-field="chat-outgoing">
|
|
||||||
<option value="">[[user:no-sound]]</option>
|
|
||||||
<!-- BEGIN chat-outgoing-sound -->
|
|
||||||
<optgroup label="{chat-outgoing-sound.name}">
|
|
||||||
<!-- BEGIN chat-outgoing-sound.sounds -->
|
|
||||||
<option value="{chat-outgoing-sound.sounds.value}" <!-- IF chat-outgoing-sound.sounds.selected -->selected<!-- ENDIF chat-outgoing-sound.sounds.selected -->>
|
|
||||||
{chat-outgoing-sound.sounds.name}
|
|
||||||
</option>
|
|
||||||
<!-- END chat-outgoing-sound.sounds -->
|
|
||||||
</optgroup>
|
|
||||||
<!-- END chat-outgoing-sound -->
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="btn-group col-xs-3">
|
|
||||||
<button type="button" class="form-control btn btn-sm btn-default" data-action="play"><span class="hidden-xs">[[admin/settings/sounds:play-sound]] </span><i class="fa fa-play"></i></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group">
|
|
||||||
<span class="input-group-btn">
|
|
||||||
<input
|
|
||||||
data-action="upload"
|
|
||||||
data-title="Upload Sound"
|
|
||||||
data-route="{config.relative_path}/api/admin/upload/sound"
|
|
||||||
data-accept="audio/*"
|
|
||||||
type="button"
|
|
||||||
class="btn btn-primary"
|
|
||||||
value="[[admin/settings/sounds:upload-new-sound]]"
|
|
||||||
></input>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button id="save" class="floating-button mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--colored">
|
|
||||||
<i class="material-icons">save</i>
|
|
||||||
</button>
|
|
||||||
@@ -103,7 +103,6 @@ async function initializeNodeBB() {
|
|||||||
middleware: middleware,
|
middleware: middleware,
|
||||||
});
|
});
|
||||||
await routes(app, middleware);
|
await routes(app, middleware);
|
||||||
await meta.sounds.addUploads();
|
|
||||||
await meta.blacklist.load();
|
await meta.blacklist.load();
|
||||||
await flags.init();
|
await flags.init();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,20 +220,4 @@ describe('Build', function (done) {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should build sounds', function (done) {
|
|
||||||
build.build(['sounds'], function (err) {
|
|
||||||
assert.ifError(err);
|
|
||||||
|
|
||||||
var mapFile = path.join(__dirname, '../build/public/sounds/fileMap.json');
|
|
||||||
assert(file.existsSync(mapFile));
|
|
||||||
var fileMap = JSON.parse(fs.readFileSync(mapFile));
|
|
||||||
assert.strictEqual(fileMap['Default | Deedle-dum'], 'nodebb-plugin-soundpack-default/notification.mp3');
|
|
||||||
|
|
||||||
var deebleDumFile = path.join(__dirname, '../build/public/sounds/nodebb-plugin-soundpack-default/notification.mp3');
|
|
||||||
assert(file.existsSync(deebleDumFile));
|
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -496,15 +496,6 @@ describe('Admin Controllers', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should load /admin/settings/sounds', function (done) {
|
|
||||||
request(nconf.get('url') + '/api/admin/settings/sounds', { jar: jar, json: true }, function (err, res, body) {
|
|
||||||
assert.ifError(err);
|
|
||||||
assert.equal(res.statusCode, 200);
|
|
||||||
assert(body);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should load /admin/manage/categories', function (done) {
|
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.ifError(err);
|
||||||
|
|||||||
15
test/meta.js
15
test/meta.js
@@ -463,21 +463,6 @@ describe('meta', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe('sounds', function () {
|
|
||||||
var socketModules = require('../src/socket.io/modules');
|
|
||||||
|
|
||||||
it('should getUserMap', function (done) {
|
|
||||||
socketModules.sounds.getUserSoundMap({ uid: 1 }, null, function (err, data) {
|
|
||||||
assert.ifError(err);
|
|
||||||
assert(data.hasOwnProperty('chat-incoming'));
|
|
||||||
assert(data.hasOwnProperty('chat-outgoing'));
|
|
||||||
assert(data.hasOwnProperty('notification'));
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('debugFork', function () {
|
describe('debugFork', function () {
|
||||||
var oldArgv;
|
var oldArgv;
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|||||||
@@ -193,7 +193,6 @@ async function setupMockDefaults() {
|
|||||||
'test/uploads/category',
|
'test/uploads/category',
|
||||||
'test/uploads/files',
|
'test/uploads/files',
|
||||||
'test/uploads/system',
|
'test/uploads/system',
|
||||||
'test/uploads/sounds',
|
|
||||||
'test/uploads/profile',
|
'test/uploads/profile',
|
||||||
];
|
];
|
||||||
for (const folder of folders) {
|
for (const folder of folders) {
|
||||||
@@ -229,7 +228,6 @@ async function enableDefaultPlugins() {
|
|||||||
const testPlugins = Array.isArray(nconf.get('test_plugins')) ? nconf.get('test_plugins') : [];
|
const testPlugins = Array.isArray(nconf.get('test_plugins')) ? nconf.get('test_plugins') : [];
|
||||||
const defaultEnabled = [
|
const defaultEnabled = [
|
||||||
'nodebb-plugin-dbsearch',
|
'nodebb-plugin-dbsearch',
|
||||||
'nodebb-plugin-soundpack-default',
|
|
||||||
'nodebb-widget-essentials',
|
'nodebb-widget-essentials',
|
||||||
].concat(testPlugins);
|
].concat(testPlugins);
|
||||||
|
|
||||||
|
|||||||
@@ -497,7 +497,7 @@ describe('socket.io', function () {
|
|||||||
var data = [
|
var data = [
|
||||||
{ name: 'nodebb-theme-persona', order: 0 },
|
{ name: 'nodebb-theme-persona', order: 0 },
|
||||||
{ name: 'nodebb-plugin-dbsearch', order: 1 },
|
{ name: 'nodebb-plugin-dbsearch', order: 1 },
|
||||||
{ name: 'nodebb-plugin-soundpack-default', order: 2 },
|
{ name: 'nodebb-plugin-markdown', order: 2 },
|
||||||
{ ignoreme: 'wrong data' },
|
{ ignoreme: 'wrong data' },
|
||||||
];
|
];
|
||||||
socketAdmin.plugins.orderActivePlugins({ uid: adminUid }, data, function (err) {
|
socketAdmin.plugins.orderActivePlugins({ uid: adminUid }, data, function (err) {
|
||||||
|
|||||||
@@ -347,25 +347,6 @@ describe('Upload Controllers', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should fail to upload invalid sound file', function (done) {
|
|
||||||
helpers.uploadFile(nconf.get('url') + '/api/admin/upload/sound', path.join(__dirname, '../test/files/test.png'), { }, jar, csrf_token, function (err, res, body) {
|
|
||||||
assert.ifError(err);
|
|
||||||
assert.equal(res.statusCode, 500);
|
|
||||||
assert.equal(body.error, '[[error:invalid-data]]');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should upload sound file', function (done) {
|
|
||||||
helpers.uploadFile(nconf.get('url') + '/api/admin/upload/sound', path.join(__dirname, '../test/files/test.wav'), { }, jar, csrf_token, function (err, res, body) {
|
|
||||||
assert.ifError(err);
|
|
||||||
assert.equal(res.statusCode, 200);
|
|
||||||
assert(body);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should upload default avatar', function (done) {
|
it('should upload default avatar', function (done) {
|
||||||
helpers.uploadFile(nconf.get('url') + '/api/admin/uploadDefaultAvatar', path.join(__dirname, '../test/files/test.png'), { }, jar, csrf_token, function (err, res, body) {
|
helpers.uploadFile(nconf.get('url') + '/api/admin/uploadDefaultAvatar', path.join(__dirname, '../test/files/test.png'), { }, jar, csrf_token, function (err, res, body) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
|
|||||||
@@ -1641,9 +1641,6 @@ describe('User', function () {
|
|||||||
restrictChat: 0,
|
restrictChat: 0,
|
||||||
followTopicsOnCreate: 1,
|
followTopicsOnCreate: 1,
|
||||||
followTopicsOnReply: 1,
|
followTopicsOnReply: 1,
|
||||||
notificationSound: '',
|
|
||||||
incomingChatSound: '',
|
|
||||||
outgoingChatSound: '',
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
socketUser.saveSettings({ uid: testUid }, data, function (err) {
|
socketUser.saveSettings({ uid: testUid }, data, function (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user