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-room-size": "Maximum number of users in chat rooms",
|
||||
"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-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 sockets = require('../socket.io');
|
||||
var plugins = require('../plugins');
|
||||
var meta = require('../meta');
|
||||
|
||||
module.exports = function (Messaging) {
|
||||
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) => {
|
||||
let uids = await Messaging.getUidsInRoom(roomId, 0, -1);
|
||||
uids = await user.blocks.filterUids(fromUid, uids);
|
||||
@@ -48,7 +47,7 @@ module.exports = function (Messaging) {
|
||||
|
||||
queueObj.timeout = setTimeout(function () {
|
||||
sendNotifications(fromUid, uids, roomId, queueObj.message);
|
||||
}, Messaging.notificationSendDelay);
|
||||
}, (parseFloat(meta.config.notificationSendDelay) || 60) * 1000);
|
||||
};
|
||||
|
||||
async function sendNotifications(fromuid, uids, roomId, messageObj) {
|
||||
|
||||
@@ -48,6 +48,11 @@
|
||||
<label>[[admin/settings/chat:delay]]</label>
|
||||
<input type="text" class="form-control" value="200" data-field="chatMessageDelay">
|
||||
</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>
|
||||
|
||||
|
||||
@@ -394,7 +394,7 @@ describe('Messaging Library', function () {
|
||||
|
||||
|
||||
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) {
|
||||
assert.ifError(err);
|
||||
|
||||
Reference in New Issue
Block a user