mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: option in ACP to configure notification/email delay for chats
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
"max-length": "Maximum length of chat messages",
|
"max-length": "Maximum length of chat messages",
|
||||||
"max-room-size": "Maximum number of users in chat rooms",
|
"max-room-size": "Maximum number of users in chat rooms",
|
||||||
"delay": "Time between chat messages in milliseconds",
|
"delay": "Time between chat messages in milliseconds",
|
||||||
|
"notification-delay": "Notification delay for chat messages",
|
||||||
"restrictions.seconds-edit-after": "Number of seconds a chat message will remain editable. (0 disabled)",
|
"restrictions.seconds-edit-after": "Number of seconds a chat message will remain editable. (0 disabled)",
|
||||||
"restrictions.seconds-delete-after": "Number of seconds a chat message will remain deletable. (0 disabled)"
|
"restrictions.seconds-delete-after": "Number of seconds a chat message will remain deletable. (0 disabled)"
|
||||||
}
|
}
|
||||||
@@ -4,12 +4,11 @@ var user = require('../user');
|
|||||||
var notifications = require('../notifications');
|
var notifications = require('../notifications');
|
||||||
var sockets = require('../socket.io');
|
var sockets = require('../socket.io');
|
||||||
var plugins = require('../plugins');
|
var plugins = require('../plugins');
|
||||||
|
var meta = require('../meta');
|
||||||
|
|
||||||
module.exports = function (Messaging) {
|
module.exports = function (Messaging) {
|
||||||
Messaging.notifyQueue = {}; // Only used to notify a user of a new chat message, see Messaging.notifyUser
|
Messaging.notifyQueue = {}; // Only used to notify a user of a new chat message, see Messaging.notifyUser
|
||||||
|
|
||||||
Messaging.notificationSendDelay = 1000 * 60;
|
|
||||||
|
|
||||||
Messaging.notifyUsersInRoom = async (fromUid, roomId, messageObj) => {
|
Messaging.notifyUsersInRoom = async (fromUid, roomId, messageObj) => {
|
||||||
let uids = await Messaging.getUidsInRoom(roomId, 0, -1);
|
let uids = await Messaging.getUidsInRoom(roomId, 0, -1);
|
||||||
uids = await user.blocks.filterUids(fromUid, uids);
|
uids = await user.blocks.filterUids(fromUid, uids);
|
||||||
@@ -48,7 +47,7 @@ module.exports = function (Messaging) {
|
|||||||
|
|
||||||
queueObj.timeout = setTimeout(function () {
|
queueObj.timeout = setTimeout(function () {
|
||||||
sendNotifications(fromUid, uids, roomId, queueObj.message);
|
sendNotifications(fromUid, uids, roomId, queueObj.message);
|
||||||
}, Messaging.notificationSendDelay);
|
}, (parseFloat(meta.config.notificationSendDelay) || 60) * 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
async function sendNotifications(fromuid, uids, roomId, messageObj) {
|
async function sendNotifications(fromuid, uids, roomId, messageObj) {
|
||||||
|
|||||||
@@ -48,6 +48,11 @@
|
|||||||
<label>[[admin/settings/chat:delay]]</label>
|
<label>[[admin/settings/chat:delay]]</label>
|
||||||
<input type="text" class="form-control" value="200" data-field="chatMessageDelay">
|
<input type="text" class="form-control" value="200" data-field="chatMessageDelay">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>[[admin/settings/chat:notification-delay]]</label>
|
||||||
|
<input type="text" class="form-control" value="60" data-field="notificationSendDelay">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -361,7 +361,7 @@ describe('Messaging Library', function () {
|
|||||||
it('should return invalid-data error', function (done) {
|
it('should return invalid-data error', function (done) {
|
||||||
socketModules.chats.getRaw({ uid: fooUid }, null, function (err) {
|
socketModules.chats.getRaw({ uid: fooUid }, null, function (err) {
|
||||||
assert.equal(err.message, '[[error:invalid-data]]');
|
assert.equal(err.message, '[[error:invalid-data]]');
|
||||||
socketModules.chats.getRaw({ uid: fooUid }, { }, function (err) {
|
socketModules.chats.getRaw({ uid: fooUid }, {}, function (err) {
|
||||||
assert.equal(err.message, '[[error:invalid-data]]');
|
assert.equal(err.message, '[[error:invalid-data]]');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@@ -394,7 +394,7 @@ describe('Messaging Library', function () {
|
|||||||
|
|
||||||
|
|
||||||
it('should notify offline users of message', function (done) {
|
it('should notify offline users of message', function (done) {
|
||||||
Messaging.notificationSendDelay = 100;
|
meta.config.notificationSendDelay = 0.1;
|
||||||
|
|
||||||
db.sortedSetAdd('users:online', Date.now() - ((meta.config.onlineCutoff * 60000) + 50000), herpUid, function (err) {
|
db.sortedSetAdd('users:online', Date.now() - ((meta.config.onlineCutoff * 60000) + 50000), herpUid, function (err) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
|
|||||||
Reference in New Issue
Block a user