Using room users API.

This commit is contained in:
Niels Simenon 2022-11-26 17:53:27 +01:00
parent 50263b2b56
commit 174dfdedfa
1 changed files with 4 additions and 1 deletions

View File

@ -54,9 +54,12 @@ function onConnect(data, bot) {
bot.socket.transmit('joinRooms', { rooms: config.channels });
}
function onRooms({ rooms, users }, bot) {
async function onRooms({ rooms }, bot) {
logger.info(`Joined ${rooms.map((room) => room.name).join(', ')}`);
const usersRes = await bhttp.get(`${config.api}/room/${rooms.map((room) => room.id).join(',')}/users`);
const users = usersRes.body;
/* eslint-disable no-param-reassign */
bot.rooms = rooms.reduce((acc, room) => ({ ...acc, [room.id]: room }), {});
bot.users = { ...bot.users, ...users };