mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-07 14:27:05 +02:00
feat: PUT /api/v3/chats/:roomId
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
const validator = require('validator');
|
||||
|
||||
const user = require('../user');
|
||||
const meta = require('../meta');
|
||||
const messaging = require('../messaging');
|
||||
const plugins = require('../plugins');
|
||||
|
||||
// const websockets = require('../socket.io');
|
||||
// const socketHelpers = require('../socket.io/helpers');
|
||||
const socketHelpers = require('../socket.io/helpers');
|
||||
|
||||
const chatsAPI = module.exports;
|
||||
|
||||
@@ -59,3 +61,14 @@ chatsAPI.post = async (caller, data) => {
|
||||
|
||||
return message;
|
||||
};
|
||||
|
||||
chatsAPI.rename = async (caller, data) => {
|
||||
await messaging.renameRoom(caller.uid, data.roomId, data.name);
|
||||
const uids = await messaging.getUidsInRoom(data.roomId, 0, -1);
|
||||
const eventData = { roomId: data.roomId, newName: validator.escape(String(data.name)) };
|
||||
|
||||
socketHelpers.emitToUids('event:chats.roomRename', eventData, uids);
|
||||
return messaging.loadRoom(caller.uid, {
|
||||
roomId: data.roomId,
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user