mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-18 03:31:03 +01:00
feat: #11881, limit room names
This commit is contained in:
@@ -103,17 +103,10 @@ chatsAPI.update = async (caller, data) => {
|
||||
}
|
||||
|
||||
if (data.hasOwnProperty('name')) {
|
||||
if (!data.name) {
|
||||
if (!data.name && data.name !== '') {
|
||||
throw new Error('[[error:invalid-data]]');
|
||||
}
|
||||
await messaging.renameRoom(caller.uid, data.roomId, data.name);
|
||||
const ioRoom = require('../socket.io').in(`chat_room_${data.roomId}`);
|
||||
if (ioRoom) {
|
||||
ioRoom.emit('event:chats.roomRename', {
|
||||
roomId: data.roomId,
|
||||
newName: validator.escape(String(data.name)),
|
||||
});
|
||||
}
|
||||
}
|
||||
const [roomData, isAdmin] = await Promise.all([
|
||||
messaging.getRoomData(data.roomId),
|
||||
@@ -130,9 +123,20 @@ chatsAPI.update = async (caller, data) => {
|
||||
if (data.hasOwnProperty('notificationSetting') && isAdmin) {
|
||||
await db.setObjectField(`chat:room:${data.roomId}`, 'notificationSetting', data.notificationSetting);
|
||||
}
|
||||
return messaging.loadRoom(caller.uid, {
|
||||
const loadedRoom = await messaging.loadRoom(caller.uid, {
|
||||
roomId: data.roomId,
|
||||
});
|
||||
if (data.hasOwnProperty('name')) {
|
||||
const ioRoom = require('../socket.io').in(`chat_room_${data.roomId}`);
|
||||
if (ioRoom) {
|
||||
ioRoom.emit('event:chats.roomRename', {
|
||||
roomId: data.roomId,
|
||||
newName: validator.escape(String(data.name)),
|
||||
chatWithMessage: loadedRoom.chatWithMessage,
|
||||
});
|
||||
}
|
||||
}
|
||||
return loadedRoom;
|
||||
};
|
||||
|
||||
chatsAPI.rename = async (caller, data) => {
|
||||
|
||||
Reference in New Issue
Block a user