Merge branch 'master' into develop

This commit is contained in:
Julian Lam
2017-02-23 12:32:03 -05:00
51 changed files with 1297 additions and 771 deletions

View File

@@ -1,24 +1,46 @@
'use strict';
var meta = require('../../meta');
var plugins = require('../../plugins');
var db = require('../../database');
var soundsController = {};
soundsController.get = function (req, res, next) {
meta.sounds.getFiles(function (err, sounds) {
db.getObject('settings:sounds', function (err, settings) {
if (err) {
return next(err);
}
settings = settings || {};
sounds = Object.keys(sounds).map(function (name) {
return {
name: name
};
var types = [
'notification',
'chat-incoming',
'chat-outgoing',
];
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/general/sounds', {
sounds: sounds
});
res.render('admin/general/sounds', output);
});
};

View File

@@ -5,6 +5,8 @@ var path = require('path');
var async = require('async');
var nconf = require('nconf');
var winston = require('winston');
var meta = require('../../meta');
var file = require('../../file');
var image = require('../../image');
var plugins = require('../../plugins');
@@ -105,12 +107,7 @@ uploadsController.uploadSound = function (req, res, next) {
return next(err);
}
var soundsPath = path.join(__dirname, '../../../build/public/sounds'),
filePath = path.join(nconf.get('upload_path'), 'sounds', uploadedFile.name);
file.link(filePath, path.join(soundsPath, path.basename(filePath)));
fs.unlink(uploadedFile.path, function (err) {
meta.sounds.build(function (err) {
if (err) {
return next(err);
}