Merge branch 'master' into develop
commit
672d7352bb
@ -1,11 +1,11 @@
|
||||
{
|
||||
"post-cache": "Кэш записи",
|
||||
"posts-in-cache": "Записей в кэше",
|
||||
"average-post-size": "Average Post Size",
|
||||
"length-to-max": "Length / Max",
|
||||
"average-post-size": "Средний размер записи",
|
||||
"length-to-max": "Длина / Максимальная",
|
||||
"percent-full": "%1% Full",
|
||||
"post-cache-size": "Post Cache Size",
|
||||
"post-cache-size": "Размер записи в кэше",
|
||||
"items-in-cache": "Items in Cache",
|
||||
"control-panel": "Control Panel",
|
||||
"update-settings": "Update Cache Settings"
|
||||
"control-panel": "Панель управления",
|
||||
"update-settings": "Обновить настройки кэша"
|
||||
}
|
@ -1,90 +1,94 @@
|
||||
"use strict";
|
||||
/* global app, define, socket, config */
|
||||
|
||||
define('sounds', ['buzz'], function (buzz) {
|
||||
define('sounds', function () {
|
||||
var Sounds = {};
|
||||
|
||||
var loadedSounds = {};
|
||||
var eventSoundMapping;
|
||||
var files;
|
||||
var fileMap;
|
||||
var soundMap;
|
||||
var cache = {};
|
||||
|
||||
socket.on('event:sounds.reloadMapping', function () {
|
||||
Sounds.reloadMapping();
|
||||
});
|
||||
|
||||
Sounds.reloadMapping = function () {
|
||||
socket.emit('modules.sounds.getMapping', function (err, mapping) {
|
||||
Sounds.loadMap = function loadMap(callback) {
|
||||
socket.emit('modules.sounds.getUserSoundMap', function (err, map) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
eventSoundMapping = mapping;
|
||||
soundMap = map;
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function loadData(callback) {
|
||||
socket.emit('modules.sounds.getData', function (err, data) {
|
||||
if (err) {
|
||||
return app.alertError('[sounds] Could not load sound mapping!');
|
||||
}
|
||||
eventSoundMapping = data.mapping;
|
||||
files = data.files;
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
function isSoundLoaded(fileName) {
|
||||
return loadedSounds[fileName];
|
||||
}
|
||||
|
||||
function loadFile(fileName, callback) {
|
||||
function createSound() {
|
||||
if (files && files[fileName]) {
|
||||
loadedSounds[fileName] = new buzz.sound(files[fileName]);
|
||||
var outstanding = 2;
|
||||
function after() {
|
||||
outstanding -= 1;
|
||||
if (outstanding === 0 && callback) {
|
||||
callback();
|
||||
}
|
||||
callback();
|
||||
}
|
||||
|
||||
if (isSoundLoaded(fileName)) {
|
||||
return callback();
|
||||
if (fileMap) {
|
||||
outstanding -= 1;
|
||||
} else {
|
||||
$.getJSON(config.relative_path + '/assets/sounds/fileMap.json', function (map) {
|
||||
fileMap = map;
|
||||
after();
|
||||
});
|
||||
}
|
||||
|
||||
if (!files || !files[fileName]) {
|
||||
return loadData(createSound);
|
||||
}
|
||||
createSound();
|
||||
Sounds.loadMap(after);
|
||||
}
|
||||
|
||||
Sounds.play = function (name) {
|
||||
function play() {
|
||||
Sounds.playFile(eventSoundMapping[name]);
|
||||
Sounds.playSound = function playSound(soundName) {
|
||||
if (!soundMap || !fileMap) {
|
||||
return loadData(after);
|
||||
}
|
||||
|
||||
if (!eventSoundMapping) {
|
||||
return loadData(play);
|
||||
function after() {
|
||||
if (!fileMap[soundName]) {
|
||||
return;
|
||||
}
|
||||
var audio = cache[soundName] = cache[soundName] || new Audio(config.relative_path + '/assets/sounds/' + fileMap[soundName]);
|
||||
audio.pause();
|
||||
audio.currentTime = 0;
|
||||
audio.play();
|
||||
}
|
||||
|
||||
play();
|
||||
after();
|
||||
};
|
||||
|
||||
Sounds.playFile = function (fileName) {
|
||||
if (!fileName) {
|
||||
return;
|
||||
}
|
||||
|
||||
function play() {
|
||||
if (loadedSounds[fileName]) {
|
||||
loadedSounds[fileName].play();
|
||||
} else {
|
||||
app.alertError('[sounds] Not found: ' + fileName);
|
||||
Sounds.play = function play(type, id) {
|
||||
function after() {
|
||||
if (!soundMap[type]) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (id) {
|
||||
var item = 'sounds.handled:' + id;
|
||||
if (sessionStorage.getItem(item)) {
|
||||
return;
|
||||
}
|
||||
sessionStorage.setItem(item, true);
|
||||
|
||||
setTimeout(function () {
|
||||
sessionStorage.removeItem(item);
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
Sounds.playSound(soundMap[type]);
|
||||
}
|
||||
|
||||
if (isSoundLoaded(fileName)) {
|
||||
play();
|
||||
} else {
|
||||
loadFile(fileName, play);
|
||||
if (!soundMap || !fileMap) {
|
||||
return loadData(after);
|
||||
}
|
||||
|
||||
after();
|
||||
};
|
||||
|
||||
socket.on('event:sounds.reloadMapping', function () {
|
||||
Sounds.loadMap();
|
||||
});
|
||||
|
||||
return Sounds;
|
||||
});
|
||||
|
@ -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],
|
||||
};
|
||||
});
|
||||
|
||||
res.render('admin/general/sounds', {
|
||||
sounds: sounds
|
||||
return {
|
||||
name: pack.name,
|
||||
sounds: sounds,
|
||||
};
|
||||
});
|
||||
|
||||
output[type + '-sound'] = soundpacks;
|
||||
});
|
||||
|
||||
res.render('admin/general/sounds', output);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -1,109 +1,121 @@
|
||||
<div class="registration panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
[[admin/manage/registration:queue]]
|
||||
</div>
|
||||
<!-- IF !users.length -->
|
||||
<p class="panel-body">
|
||||
[[admin/manage/registration:description, {config.relative_path}/admin/settings/user]]
|
||||
</p>
|
||||
<!-- ENDIF !users.length -->
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped users-list">
|
||||
<tr>
|
||||
<th>[[admin/manage/registration:list.name]]</th>
|
||||
<th>[[admin/manage/registration:list.email]]</th>
|
||||
<th class="hidden-xs">[[admin/manage/registration:list.ip]]</th>
|
||||
<th class="hidden-xs">[[admin/manage/registration:list.time]]</th>
|
||||
<!-- BEGIN customHeaders -->
|
||||
<th class="hidden-xs">{customHeaders.label}</th>
|
||||
<!-- END customHeaders -->
|
||||
<th></th>
|
||||
</tr>
|
||||
<!-- BEGIN users -->
|
||||
<tr data-username="{users.username}">
|
||||
<td>
|
||||
<!-- IF users.usernameSpam -->
|
||||
<i class="fa fa-times-circle text-danger" title="[[admin/manage/registration:list.username-spam, {users.spamData.username.frequency}, {users.spamData.username.appears}, {users.spamData.username.confidence}]]"></i>
|
||||
<!-- ELSE -->
|
||||
<i class="fa fa-check text-success"></i>
|
||||
<!-- ENDIF users.usernameSpam -->
|
||||
{users.username}
|
||||
</td>
|
||||
<td>
|
||||
<!-- IF users.emailSpam -->
|
||||
<i class="fa fa-times-circle text-danger" title="[[admin/manage/registration:list.email-spam, {users.spamData.email.frequency}, {users.spamData.email.appears}]]"></i>
|
||||
<!-- ELSE -->
|
||||
<i class="fa fa-check text-success"></i>
|
||||
<!-- ENDIF users.emailSpam -->
|
||||
{users.email}
|
||||
</td>
|
||||
<td class="hidden-xs">
|
||||
<!-- IF users.ipSpam -->
|
||||
<i class="fa fa-times-circle text-danger" title="[[admin/manage/registration:list.ip-spam, {users.spamData.ip.frequency}, {users.spamData.ip.appears}]]"></i>
|
||||
<!-- ELSE -->
|
||||
<i class="fa fa-check text-success"></i>
|
||||
<!-- ENDIF users.ipSpam -->
|
||||
{users.ip}
|
||||
<!-- BEGIN users.ipMatch -->
|
||||
<br>
|
||||
<!-- IF users.ipMatch.picture -->
|
||||
<img src="{users.ipMatch.picture}" class="user-img"/>
|
||||
<!-- ELSE -->
|
||||
<div class="user-img avatar avatar-sm" style="background-color: {users.ipMatch.icon:bgColor};">{users.ipMatch.icon:text}</div>
|
||||
<!-- ENDIF users.ipMatch.picture -->
|
||||
<a href="/uid/{users.ipMatch.uid}">{users.ipMatch.username}</a>
|
||||
<!-- END users.ipMatch -->
|
||||
</td>
|
||||
<td class="hidden-xs">
|
||||
<span class="timeago" title="{users.timestampISO}"></span>
|
||||
</td>
|
||||
|
||||
<!-- BEGIN users.customRows -->
|
||||
<td class="hidden-xs">{users.customRows.value}</td>
|
||||
<!-- END users.customRows -->
|
||||
|
||||
<td>
|
||||
<div class="btn-group pull-right">
|
||||
<button class="btn btn-success btn-xs" data-action="accept"><i class="fa fa-check"></i></button>
|
||||
<button class="btn btn-danger btn-xs" data-action="delete"><i class="fa fa-times"></i></button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- END users -->
|
||||
</table>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="registration panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
[[admin/manage/registration:queue]]
|
||||
</div>
|
||||
<!-- IF !users.length -->
|
||||
<p class="panel-body">
|
||||
[[admin/manage/registration:description, {config.relative_path}/admin/settings/user]]
|
||||
</p>
|
||||
<!-- ENDIF !users.length -->
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped users-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>[[admin/manage/registration:list.name]]</th>
|
||||
<th>[[admin/manage/registration:list.email]]</th>
|
||||
<th class="hidden-xs">[[admin/manage/registration:list.ip]]</th>
|
||||
<th class="hidden-xs">[[admin/manage/registration:list.time]]</th>
|
||||
<!-- BEGIN customHeaders -->
|
||||
<th class="hidden-xs">{customHeaders.label}</th>
|
||||
<!-- END customHeaders -->
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- BEGIN users -->
|
||||
<tr data-username="{users.username}">
|
||||
<td>
|
||||
<!-- IF users.usernameSpam -->
|
||||
<i class="fa fa-times-circle text-danger" title="[[admin/manage/registration:list.username-spam, {users.spamData.username.frequency}, {users.spamData.username.appears}, {users.spamData.username.confidence}]]"></i>
|
||||
<!-- ELSE -->
|
||||
<i class="fa fa-check text-success"></i>
|
||||
<!-- ENDIF users.usernameSpam -->
|
||||
{users.username}
|
||||
</td>
|
||||
<td>
|
||||
<!-- IF users.emailSpam -->
|
||||
<i class="fa fa-times-circle text-danger" title="[[admin/manage/registration:list.email-spam, {users.spamData.email.frequency}, {users.spamData.email.appears}]]"></i>
|
||||
<!-- ELSE -->
|
||||
<i class="fa fa-check text-success"></i>
|
||||
<!-- ENDIF users.emailSpam -->
|
||||
{users.email}
|
||||
</td>
|
||||
<td class="hidden-xs">
|
||||
<!-- IF users.ipSpam -->
|
||||
<i class="fa fa-times-circle text-danger" title="[[admin/manage/registration:list.ip-spam, {users.spamData.ip.frequency}, {users.spamData.ip.appears}]]"></i>
|
||||
<!-- ELSE -->
|
||||
<i class="fa fa-check text-success"></i>
|
||||
<!-- ENDIF users.ipSpam -->
|
||||
{users.ip}
|
||||
<!-- BEGIN users.ipMatch -->
|
||||
<br>
|
||||
<!-- IF users.ipMatch.picture -->
|
||||
<img src="{users.ipMatch.picture}" class="user-img"/>
|
||||
<!-- ELSE -->
|
||||
<div class="user-img avatar avatar-sm" style="background-color: {users.ipMatch.icon:bgColor};">{users.ipMatch.icon:text}</div>
|
||||
<!-- ENDIF users.ipMatch.picture -->
|
||||
<a href="/uid/{users.ipMatch.uid}">{users.ipMatch.username}</a>
|
||||
<!-- END users.ipMatch -->
|
||||
</td>
|
||||
<td class="hidden-xs">
|
||||
<span class="timeago" title="{users.timestampISO}"></span>
|
||||
</td>
|
||||
|
||||
<!-- IMPORT partials/paginator.tpl -->
|
||||
</div>
|
||||
<!-- BEGIN users.customRows -->
|
||||
<td class="hidden-xs">{users.customRows.value}</td>
|
||||
<!-- END users.customRows -->
|
||||
|
||||
<div class="invitations panel panel-success">
|
||||
<div class="panel-heading">
|
||||
[[admin/manage/registration:invitations]]
|
||||
</div>
|
||||
<p class="panel-body">
|
||||
[[admin/manage/registration:invitations.description]]
|
||||
</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped invites-list">
|
||||
<tr>
|
||||
<th>[[admin/manage/registration:invitations.inviter-username]]</th>
|
||||
<th>[[admin/manage/registration:invitations.invitee-email]]</th>
|
||||
<th>[[admin/manage/registration:invitations.invitee-username]]</th>
|
||||
</tr>
|
||||
<!-- BEGIN invites -->
|
||||
<!-- BEGIN invites.invitations -->
|
||||
<tr data-invitation-mail="{invites.invitations.email}"
|
||||
data-invited-by="{invites.username}">
|
||||
<td class ="invited-by"><!-- IF @first -->{invites.username}<!-- ENDIF @first --></td>
|
||||
<td>{invites.invitations.email}</td>
|
||||
<td>{invites.invitations.username}
|
||||
<div class="btn-group pull-right">
|
||||
<button class="btn btn-danger btn-xs" data-action="delete"><i class="fa fa-times"></i></button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- END invites.invitations -->
|
||||
<!-- END invites -->
|
||||
</table>
|
||||
<td>
|
||||
<div class="btn-group pull-right">
|
||||
<button class="btn btn-success btn-xs" data-action="accept"><i class="fa fa-check"></i></button>
|
||||
<button class="btn btn-danger btn-xs" data-action="delete"><i class="fa fa-times"></i></button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- END users -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- IMPORT partials/paginator.tpl -->
|
||||
</div>
|
||||
|
||||
<div class="invitations panel panel-success">
|
||||
<div class="panel-heading">
|
||||
[[admin/manage/registration:invitations]]
|
||||
</div>
|
||||
<p class="panel-body">
|
||||
[[admin/manage/registration:invitations.description]]
|
||||
</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped invites-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>[[admin/manage/registration:invitations.inviter-username]]</th>
|
||||
<th>[[admin/manage/registration:invitations.invitee-email]]</th>
|
||||
<th>[[admin/manage/registration:invitations.invitee-username]]</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- BEGIN invites -->
|
||||
<!-- BEGIN invites.invitations -->
|
||||
<tr data-invitation-mail="{invites.invitations.email}"
|
||||
data-invited-by="{invites.username}">
|
||||
<td class ="invited-by"><!-- IF @first -->{invites.username}<!-- ENDIF @first --></td>
|
||||
<td>{invites.invitations.email}</td>
|
||||
<td>{invites.invitations.username}
|
||||
<div class="btn-group pull-right">
|
||||
<button class="btn btn-danger btn-xs" data-action="delete"><i class="fa fa-times"></i></button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- END invites.invitations -->
|
||||
<!-- END invites -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,79 @@
|
||||
'use strict';
|
||||
/*global require, after, before*/
|
||||
|
||||
|
||||
var async = require('async');
|
||||
var assert = require('assert');
|
||||
|
||||
var db = require('./mocks/databasemock');
|
||||
var groups = require('../src/groups');
|
||||
var user = require('../src/user');
|
||||
var blacklist = require('../src/meta/blacklist');
|
||||
|
||||
describe('blacklist', function () {
|
||||
|
||||
var adminUid;
|
||||
|
||||
before(function (done) {
|
||||
groups.resetCache();
|
||||
user.create({username: 'admin'}, function (err, uid) {
|
||||
assert.ifError(err);
|
||||
adminUid = uid;
|
||||
groups.join('administrators', adminUid, done);
|
||||
});
|
||||
});
|
||||
|
||||
var socketBlacklist = require('../src/socket.io/blacklist');
|
||||
var rules = '1.1.1.1\n2.2.2.2\n::ffff:0:2.2.2.2\n127.0.0.1\n192.168.100.0/22';
|
||||
|
||||
it('should validate blacklist', function (done) {
|
||||
socketBlacklist.validate({uid: adminUid}, {
|
||||
rules: rules
|
||||
}, function (err, data) {
|
||||
assert.ifError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should error if not admin', function (done) {
|
||||
socketBlacklist.save({uid: 0}, rules, function (err) {
|
||||
assert.equal(err.message, '[[error:no-privileges]]');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should save blacklist', function (done) {
|
||||
socketBlacklist.save({uid: adminUid}, rules, function (err) {
|
||||
assert.ifError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should pass ip test against blacklist async', function (done) {
|
||||
blacklist.test('3.3.3.3', function (err) {
|
||||
assert.ifError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should pass ip test against blacklist sync', function (done) {
|
||||
assert(!blacklist.test('3.3.3.3'));
|
||||
done();
|
||||
});
|
||||
|
||||
it('should fail ip test against blacklist async', function (done) {
|
||||
blacklist.test('1.1.1.1', function (err) {
|
||||
assert.equal(err.message, '[[error:blacklisted-ip]]');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should fail ip test against blacklist sync', function (done) {
|
||||
assert(blacklist.test('1.1.1.1'));
|
||||
done();
|
||||
});
|
||||
|
||||
after(function (done) {
|
||||
db.emptydb(done);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue