mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-28 09:36:16 +01:00
only allow users in the room to get raw message content
This commit is contained in:
@@ -64,7 +64,7 @@ define('forum/chats', ['components', 'string', 'sounds', 'forum/infinitescroll',
|
|||||||
.on('click', '[data-action="edit"]', function() {
|
.on('click', '[data-action="edit"]', function() {
|
||||||
var messageId = $(this).parents('[data-mid]').attr('data-mid');
|
var messageId = $(this).parents('[data-mid]').attr('data-mid');
|
||||||
var inputEl = components.get('chat/input');
|
var inputEl = components.get('chat/input');
|
||||||
Chats.prepEdit(inputEl, messageId);
|
Chats.prepEdit(inputEl, messageId, ajaxify.data.roomId);
|
||||||
})
|
})
|
||||||
.on('click', '[data-action="delete"]', function() {
|
.on('click', '[data-action="delete"]', function() {
|
||||||
var messageId = $(this).parents('[data-mid]').attr('data-mid');
|
var messageId = $(this).parents('[data-mid]').attr('data-mid');
|
||||||
@@ -106,13 +106,13 @@ define('forum/chats', ['components', 'string', 'sounds', 'forum/infinitescroll',
|
|||||||
var lastMid = message.attr('data-mid');
|
var lastMid = message.attr('data-mid');
|
||||||
var inputEl = components.get('chat/input');
|
var inputEl = components.get('chat/input');
|
||||||
|
|
||||||
Chats.prepEdit(inputEl, lastMid);
|
Chats.prepEdit(inputEl, lastMid, ajaxify.data.roomId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Chats.prepEdit = function(inputEl, messageId) {
|
Chats.prepEdit = function(inputEl, messageId, roomId) {
|
||||||
socket.emit('modules.chats.getRaw', { mid: messageId }, function(err, raw) {
|
socket.emit('modules.chats.getRaw', { mid: messageId, roomId: roomId }, function(err, raw) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return app.alertError(err.message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra
|
|||||||
.on('click', '[data-action="edit"]', function() {
|
.on('click', '[data-action="edit"]', function() {
|
||||||
var messageId = $(this).parents('[data-mid]').attr('data-mid');
|
var messageId = $(this).parents('[data-mid]').attr('data-mid');
|
||||||
var inputEl = chatModal.find('[component="chat/input"]');
|
var inputEl = chatModal.find('[component="chat/input"]');
|
||||||
Chats.prepEdit(inputEl, messageId);
|
Chats.prepEdit(inputEl, messageId, data.roomId);
|
||||||
})
|
})
|
||||||
.on('click', '[data-action="delete"]', function() {
|
.on('click', '[data-action="delete"]', function() {
|
||||||
var messageId = $(this).parents('[data-mid]').attr('data-mid');
|
var messageId = $(this).parents('[data-mid]').attr('data-mid');
|
||||||
|
|||||||
@@ -31,11 +31,20 @@ SocketModules.chats.get = function(socket, data, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
SocketModules.chats.getRaw = function(socket, data, callback) {
|
SocketModules.chats.getRaw = function(socket, data, callback) {
|
||||||
if(!data || !data.hasOwnProperty('mid')) {
|
if (!data || !data.hasOwnProperty('mid')) {
|
||||||
return callback(new Error('[[error:invalid-data]]'));
|
return callback(new Error('[[error:invalid-data]]'));
|
||||||
}
|
}
|
||||||
|
async.waterfall([
|
||||||
Messaging.getMessageField(data.mid, 'content', callback);
|
function (next) {
|
||||||
|
Messaging.isUserInRoom(socket.uid, data.roomId, next);
|
||||||
|
},
|
||||||
|
function (inRoom, next) {
|
||||||
|
if (!inRoom) {
|
||||||
|
return next(new Error('[[error:not-allowed]]'));
|
||||||
|
}
|
||||||
|
Messaging.getMessageField(data.mid, 'content', next);
|
||||||
|
}
|
||||||
|
], callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
SocketModules.chats.newRoom = function(socket, data, callback) {
|
SocketModules.chats.newRoom = function(socket, data, callback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user