mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-09 15:35:47 +01:00
chat fixes
update bootstrap tags input dont allow adding self to chat room
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
"chat.user_has_messaged_you": "%1 has messaged you.",
|
||||
"chat.see_all": "See all chats",
|
||||
"chat.no-messages": "Please select a recipient to view chat message history",
|
||||
"chat.no-users-in-room": "No users in this room",
|
||||
"chat.recent-chats": "Recent Chats",
|
||||
"chat.contacts": "Contacts",
|
||||
"chat.message-history": "Message History",
|
||||
@@ -17,6 +18,7 @@
|
||||
"chat.three_months": "3 Months",
|
||||
"chat.delete_message_confirm": "Are you sure you wish to delete this message?",
|
||||
"chat.roomname": "Chat Room %1",
|
||||
"chat.add-users-to-room": "Add users to room",
|
||||
|
||||
"composer.compose": "Compose",
|
||||
"composer.show_preview": "Show Preview",
|
||||
|
||||
@@ -219,29 +219,41 @@ define('forum/chats', ['components', 'string', 'sounds', 'forum/infinitescroll',
|
||||
});
|
||||
}
|
||||
|
||||
tagEl.on('beforeItemAdd', function(event) {
|
||||
event.cancel = event.item === app.user.username;
|
||||
});
|
||||
|
||||
tagEl.on('itemAdded', function(event) {
|
||||
if (event.item === app.user.username) {
|
||||
return;
|
||||
}
|
||||
socket.emit('modules.chats.addUserToRoom', {roomId: data.roomId, username: event.item}, function(err) {
|
||||
if (err && err.message === '[[error:no-user]]') {
|
||||
tagEl.tagsinput('remove', event.item);
|
||||
if (err) {
|
||||
app.alertError(err.message);
|
||||
tagEl.tagsinput('remove', event.item, {nouser: true});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
tagEl.on('beforeItemRemove', function(event) {
|
||||
event.cancel = !data.isOwner || data.users.length < 2;
|
||||
if (event.options && event.options.nouser) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.cancel = !data.isOwner || tagEl.tagsinput('items').length < 2;
|
||||
if (!data.owner) {
|
||||
return app.alertError('[[error:not-allowed]]');
|
||||
}
|
||||
|
||||
if (data.users.length < 2) {
|
||||
if (tagEl.tagsinput('items').length < 2) {
|
||||
return app.alertError('[[error:cant-remove-last-user]]');
|
||||
}
|
||||
});
|
||||
|
||||
tagEl.on('itemRemoved', function(event) {
|
||||
if (event.options && event.options.nouser) {
|
||||
return;
|
||||
}
|
||||
socket.emit('modules.chats.removeUserFromRoom', {roomId: data.roomId, username: event.item}, function(err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -142,6 +142,9 @@ SocketModules.chats.addUserToRoom = function(socket, data, callback) {
|
||||
if (!uid) {
|
||||
return next(new Error('[[error:no-user]]'));
|
||||
}
|
||||
if (socket.uid === parseInt(uid, 10)) {
|
||||
return next(new Error('[[error:cant-add-self-to-chat-room]]'));
|
||||
}
|
||||
Messaging.addUsersToRoom(socket.uid, [uid], data.roomId, next);
|
||||
}
|
||||
], callback);
|
||||
|
||||
Reference in New Issue
Block a user