mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-28 01:26:16 +01:00
closes #6369
This commit is contained in:
@@ -75,7 +75,7 @@
|
|||||||
"nodebb-plugin-spam-be-gone": "0.5.3",
|
"nodebb-plugin-spam-be-gone": "0.5.3",
|
||||||
"nodebb-rewards-essentials": "0.0.11",
|
"nodebb-rewards-essentials": "0.0.11",
|
||||||
"nodebb-theme-lavender": "5.0.4",
|
"nodebb-theme-lavender": "5.0.4",
|
||||||
"nodebb-theme-persona": "9.0.11",
|
"nodebb-theme-persona": "9.0.12",
|
||||||
"nodebb-theme-slick": "1.2.3",
|
"nodebb-theme-slick": "1.2.3",
|
||||||
"nodebb-theme-vanilla": "10.0.10",
|
"nodebb-theme-vanilla": "10.0.10",
|
||||||
"nodebb-widget-essentials": "4.0.4",
|
"nodebb-widget-essentials": "4.0.4",
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
"chat.leave-help": "Leaving this chat will remove you from future correspondence in this chat. If you are re-added in the future, you will not see any chat history from prior to your re-joining.",
|
"chat.leave-help": "Leaving this chat will remove you from future correspondence in this chat. If you are re-added in the future, you will not see any chat history from prior to your re-joining.",
|
||||||
"chat.in-room": "In this room",
|
"chat.in-room": "In this room",
|
||||||
"chat.kick": "Kick",
|
"chat.kick": "Kick",
|
||||||
|
"chat.show-ip": "Show IP",
|
||||||
|
|
||||||
"composer.compose": "Compose",
|
"composer.compose": "Compose",
|
||||||
"composer.show_preview": "Show Preview",
|
"composer.show_preview": "Show Preview",
|
||||||
|
|||||||
@@ -57,6 +57,20 @@ define('forum/chats', [
|
|||||||
Chats.addLeaveHandler(ajaxify.data.roomId, components.get('chat/controls').find('[data-action="leave"]'));
|
Chats.addLeaveHandler(ajaxify.data.roomId, components.get('chat/controls').find('[data-action="leave"]'));
|
||||||
Chats.addScrollHandler(ajaxify.data.roomId, ajaxify.data.uid, $('.chat-content'));
|
Chats.addScrollHandler(ajaxify.data.roomId, ajaxify.data.uid, $('.chat-content'));
|
||||||
Chats.addCharactersLeftHandler($('[component="chat/main-wrapper"]'));
|
Chats.addCharactersLeftHandler($('[component="chat/main-wrapper"]'));
|
||||||
|
Chats.addIPHandler($('[component="chat/main-wrapper"]'));
|
||||||
|
};
|
||||||
|
|
||||||
|
Chats.addIPHandler = function (container) {
|
||||||
|
container.on('click', '.chat-ip-button', function () {
|
||||||
|
var ipEl = $(this).parent();
|
||||||
|
var mid = ipEl.parents('[data-mid]').attr('data-mid');
|
||||||
|
socket.emit('modules.chats.getIP', mid, function (err, ip) {
|
||||||
|
if (err) {
|
||||||
|
return app.alertError(err);
|
||||||
|
}
|
||||||
|
ipEl.html(ip);
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Chats.addPopoutHandler = function () {
|
Chats.addPopoutHandler = function () {
|
||||||
|
|||||||
@@ -246,6 +246,7 @@ define('chat', [
|
|||||||
Chats.addScrollHandler(chatModal.attr('data-roomid'), data.uid, chatModal.find('.chat-content'));
|
Chats.addScrollHandler(chatModal.attr('data-roomid'), data.uid, chatModal.find('.chat-content'));
|
||||||
|
|
||||||
Chats.addCharactersLeftHandler(chatModal);
|
Chats.addCharactersLeftHandler(chatModal);
|
||||||
|
Chats.addIPHandler(chatModal);
|
||||||
|
|
||||||
taskbar.push('chat', chatModal.attr('data-uuid'), {
|
taskbar.push('chat', chatModal.attr('data-uuid'), {
|
||||||
title: data.roomName || (data.users.length ? data.users[0].username : ''),
|
title: data.roomName || (data.users.length ? data.users[0].username : ''),
|
||||||
|
|||||||
@@ -67,6 +67,9 @@ chatsController.get = function (req, res, callback) {
|
|||||||
roomId: req.params.roomid,
|
roomId: req.params.roomid,
|
||||||
isNew: false,
|
isNew: false,
|
||||||
}),
|
}),
|
||||||
|
isAdminOrGlobalMod: function (next) {
|
||||||
|
user.isAdminOrGlobalMod(req.uid, next);
|
||||||
|
},
|
||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
function (data) {
|
function (data) {
|
||||||
@@ -89,7 +92,7 @@ chatsController.get = function (req, res, callback) {
|
|||||||
room.maximumUsersInChatRoom = parseInt(meta.config.maximumUsersInChatRoom, 10) || 0;
|
room.maximumUsersInChatRoom = parseInt(meta.config.maximumUsersInChatRoom, 10) || 0;
|
||||||
room.maximumChatMessageLength = parseInt(meta.config.maximumChatMessageLength, 10) || 1000;
|
room.maximumChatMessageLength = parseInt(meta.config.maximumChatMessageLength, 10) || 1000;
|
||||||
room.showUserInput = !room.maximumUsersInChatRoom || room.maximumUsersInChatRoom > 2;
|
room.showUserInput = !room.maximumUsersInChatRoom || room.maximumUsersInChatRoom > 2;
|
||||||
|
room.isAdminOrGlobalMod = data.isAdminOrGlobalMod;
|
||||||
res.render('chats', room);
|
res.render('chats', room);
|
||||||
},
|
},
|
||||||
], callback);
|
], callback);
|
||||||
|
|||||||
@@ -59,11 +59,7 @@ Messaging.getMessages = function (params, callback) {
|
|||||||
|
|
||||||
// Filter out deleted messages unless you're the sender of said message
|
// Filter out deleted messages unless you're the sender of said message
|
||||||
messageData = messageData.filter(function (messageData) {
|
messageData = messageData.filter(function (messageData) {
|
||||||
if (messageData.deleted && parseInt(messageData.fromuid, 10) !== parseInt(params.uid, 10)) {
|
return (!messageData.deleted || parseInt(messageData.fromuid, 10) === parseInt(params.uid, 10));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
next(null, messageData);
|
next(null, messageData);
|
||||||
@@ -87,7 +83,6 @@ Messaging.parse = function (message, fromuid, uid, roomId, isNew, callback) {
|
|||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var messageData = {
|
var messageData = {
|
||||||
message: message,
|
message: message,
|
||||||
parsed: parsed,
|
parsed: parsed,
|
||||||
|
|||||||
@@ -8,20 +8,20 @@ var db = require('../database');
|
|||||||
var user = require('../user');
|
var user = require('../user');
|
||||||
|
|
||||||
module.exports = function (Messaging) {
|
module.exports = function (Messaging) {
|
||||||
Messaging.sendMessage = function (uid, roomId, content, timestamp, callback) {
|
Messaging.sendMessage = function (data, callback) {
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
Messaging.checkContent(content, next);
|
Messaging.checkContent(data.content, next);
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
Messaging.isUserInRoom(uid, roomId, next);
|
Messaging.isUserInRoom(data.uid, data.roomId, next);
|
||||||
},
|
},
|
||||||
function (inRoom, next) {
|
function (inRoom, next) {
|
||||||
if (!inRoom) {
|
if (!inRoom) {
|
||||||
return next(new Error('[[error:not-allowed]]'));
|
return next(new Error('[[error:not-allowed]]'));
|
||||||
}
|
}
|
||||||
|
|
||||||
Messaging.addMessage(uid, roomId, content, timestamp, next);
|
Messaging.addMessage(data, next);
|
||||||
},
|
},
|
||||||
], callback);
|
], callback);
|
||||||
};
|
};
|
||||||
@@ -39,14 +39,14 @@ module.exports = function (Messaging) {
|
|||||||
callback();
|
callback();
|
||||||
};
|
};
|
||||||
|
|
||||||
Messaging.addMessage = function (fromuid, roomId, content, timestamp, callback) {
|
Messaging.addMessage = function (data, callback) {
|
||||||
var mid;
|
var mid;
|
||||||
var message;
|
var message;
|
||||||
var isNewSet;
|
var isNewSet;
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
Messaging.checkContent(content, next);
|
Messaging.checkContent(data.content, next);
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
db.incrObjectField('global', 'nextMid', next);
|
db.incrObjectField('global', 'nextMid', next);
|
||||||
@@ -54,12 +54,15 @@ module.exports = function (Messaging) {
|
|||||||
function (_mid, next) {
|
function (_mid, next) {
|
||||||
mid = _mid;
|
mid = _mid;
|
||||||
message = {
|
message = {
|
||||||
content: String(content),
|
content: String(data.content),
|
||||||
timestamp: timestamp,
|
timestamp: data.timestamp,
|
||||||
fromuid: fromuid,
|
fromuid: data.uid,
|
||||||
roomId: roomId,
|
roomId: data.roomId,
|
||||||
deleted: 0,
|
deleted: 0,
|
||||||
};
|
};
|
||||||
|
if (data.ip) {
|
||||||
|
message.ip = data.ip;
|
||||||
|
}
|
||||||
|
|
||||||
plugins.fireHook('filter:messaging.save', message, next);
|
plugins.fireHook('filter:messaging.save', message, next);
|
||||||
},
|
},
|
||||||
@@ -67,27 +70,27 @@ module.exports = function (Messaging) {
|
|||||||
db.setObject('message:' + mid, message, next);
|
db.setObject('message:' + mid, message, next);
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
Messaging.isNewSet(fromuid, roomId, timestamp, next);
|
Messaging.isNewSet(data.uid, data.roomId, data.timestamp, next);
|
||||||
},
|
},
|
||||||
function (_isNewSet, next) {
|
function (_isNewSet, next) {
|
||||||
isNewSet = _isNewSet;
|
isNewSet = _isNewSet;
|
||||||
db.getSortedSetRange('chat:room:' + roomId + ':uids', 0, -1, next);
|
db.getSortedSetRange('chat:room:' + data.roomId + ':uids', 0, -1, next);
|
||||||
},
|
},
|
||||||
function (uids, next) {
|
function (uids, next) {
|
||||||
user.blocks.filterUids(fromuid, uids, next);
|
user.blocks.filterUids(data.uid, uids, next);
|
||||||
},
|
},
|
||||||
function (uids, next) {
|
function (uids, next) {
|
||||||
async.parallel([
|
async.parallel([
|
||||||
async.apply(Messaging.addRoomToUsers, roomId, uids, timestamp),
|
async.apply(Messaging.addRoomToUsers, data.roomId, uids, data.timestamp),
|
||||||
async.apply(Messaging.addMessageToUsers, roomId, uids, mid, timestamp),
|
async.apply(Messaging.addMessageToUsers, data.roomId, uids, mid, data.timestamp),
|
||||||
async.apply(Messaging.markUnread, uids, roomId),
|
async.apply(Messaging.markUnread, uids, data.roomId),
|
||||||
async.apply(Messaging.addUsersToRoom, fromuid, [fromuid], roomId),
|
async.apply(Messaging.addUsersToRoom, data.uid, [data.uid], data.roomId),
|
||||||
], next);
|
], next);
|
||||||
},
|
},
|
||||||
function (results, next) {
|
function (results, next) {
|
||||||
async.parallel({
|
async.parallel({
|
||||||
markRead: async.apply(Messaging.markRead, fromuid, roomId),
|
markRead: async.apply(Messaging.markRead, data.uid, data.roomId),
|
||||||
messages: async.apply(Messaging.getMessagesData, [mid], fromuid, roomId, true),
|
messages: async.apply(Messaging.getMessagesData, [mid], data.uid, data.roomId, true),
|
||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
function (results, next) {
|
function (results, next) {
|
||||||
@@ -97,7 +100,7 @@ module.exports = function (Messaging) {
|
|||||||
|
|
||||||
results.messages[0].newSet = isNewSet;
|
results.messages[0].newSet = isNewSet;
|
||||||
results.messages[0].mid = mid;
|
results.messages[0].mid = mid;
|
||||||
results.messages[0].roomId = roomId;
|
results.messages[0].roomId = data.roomId;
|
||||||
next(null, results.messages[0]);
|
next(null, results.messages[0]);
|
||||||
},
|
},
|
||||||
], callback);
|
], callback);
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ module.exports = function (Messaging) {
|
|||||||
messages = _messages.map(function (msg, idx) {
|
messages = _messages.map(function (msg, idx) {
|
||||||
if (msg) {
|
if (msg) {
|
||||||
msg.messageId = parseInt(mids[idx], 10);
|
msg.messageId = parseInt(mids[idx], 10);
|
||||||
|
msg.ip = undefined;
|
||||||
}
|
}
|
||||||
return msg;
|
return msg;
|
||||||
}).filter(Boolean);
|
}).filter(Boolean);
|
||||||
|
|||||||
@@ -118,7 +118,13 @@ SocketModules.chats.send = function (socket, data, callback) {
|
|||||||
Messaging.canMessageRoom(socket.uid, data.roomId, next);
|
Messaging.canMessageRoom(socket.uid, data.roomId, next);
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
Messaging.sendMessage(socket.uid, data.roomId, data.message, Date.now(), next);
|
Messaging.sendMessage({
|
||||||
|
uid: socket.uid,
|
||||||
|
roomId: data.roomId,
|
||||||
|
content: data.message,
|
||||||
|
timestamp: Date.now(),
|
||||||
|
ip: socket.ip,
|
||||||
|
}, next);
|
||||||
},
|
},
|
||||||
function (message, next) {
|
function (message, next) {
|
||||||
Messaging.notifyUsersInRoom(socket.uid, data.roomId, message);
|
Messaging.notifyUsersInRoom(socket.uid, data.roomId, message);
|
||||||
@@ -171,6 +177,9 @@ SocketModules.chats.loadRoom = function (socket, data, callback) {
|
|||||||
roomId: data.roomId,
|
roomId: data.roomId,
|
||||||
isNew: false,
|
isNew: false,
|
||||||
}),
|
}),
|
||||||
|
isAdminOrGlobalMod: function (next) {
|
||||||
|
user.isAdminOrGlobalMod(socket.uid, next);
|
||||||
|
},
|
||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
function (results, next) {
|
function (results, next) {
|
||||||
@@ -183,6 +192,7 @@ SocketModules.chats.loadRoom = function (socket, data, callback) {
|
|||||||
results.roomData.maximumUsersInChatRoom = parseInt(meta.config.maximumUsersInChatRoom, 10) || 0;
|
results.roomData.maximumUsersInChatRoom = parseInt(meta.config.maximumUsersInChatRoom, 10) || 0;
|
||||||
results.roomData.maximumChatMessageLength = parseInt(meta.config.maximumChatMessageLength, 10) || 1000;
|
results.roomData.maximumChatMessageLength = parseInt(meta.config.maximumChatMessageLength, 10) || 1000;
|
||||||
results.roomData.showUserInput = !results.roomData.maximumUsersInChatRoom || results.roomData.maximumUsersInChatRoom > 2;
|
results.roomData.showUserInput = !results.roomData.maximumUsersInChatRoom || results.roomData.maximumUsersInChatRoom > 2;
|
||||||
|
results.roomData.isAdminOrGlobalMod = results.isAdminOrGlobalMod;
|
||||||
next(null, results.roomData);
|
next(null, results.roomData);
|
||||||
},
|
},
|
||||||
], callback);
|
], callback);
|
||||||
@@ -438,6 +448,20 @@ SocketModules.chats.getMessages = function (socket, data, callback) {
|
|||||||
Messaging.getMessages(params, callback);
|
Messaging.getMessages(params, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SocketModules.chats.getIP = function (socket, mid, callback) {
|
||||||
|
async.waterfall([
|
||||||
|
function (next) {
|
||||||
|
user.isAdminOrGlobalMod(socket.uid, next);
|
||||||
|
},
|
||||||
|
function (allowed, next) {
|
||||||
|
if (!allowed) {
|
||||||
|
return next(new Error('[[error:no-privilege]]'));
|
||||||
|
}
|
||||||
|
Messaging.getMessageField(mid, 'ip', next);
|
||||||
|
},
|
||||||
|
], callback);
|
||||||
|
};
|
||||||
|
|
||||||
/* Sounds */
|
/* Sounds */
|
||||||
SocketModules.sounds.getUserSoundMap = function getUserSoundMap(socket, data, callback) {
|
SocketModules.sounds.getUserSoundMap = function getUserSoundMap(socket, data, callback) {
|
||||||
meta.sounds.getUserSoundMap(socket.uid, callback);
|
meta.sounds.getUserSoundMap(socket.uid, callback);
|
||||||
|
|||||||
Reference in New Issue
Block a user