Using room users API.
This commit is contained in:
parent
50263b2b56
commit
174dfdedfa
|
@ -54,9 +54,12 @@ function onConnect(data, bot) {
|
||||||
bot.socket.transmit('joinRooms', { rooms: config.channels });
|
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(', ')}`);
|
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 */
|
/* eslint-disable no-param-reassign */
|
||||||
bot.rooms = rooms.reduce((acc, room) => ({ ...acc, [room.id]: room }), {});
|
bot.rooms = rooms.reduce((acc, room) => ({ ...acc, [room.id]: room }), {});
|
||||||
bot.users = { ...bot.users, ...users };
|
bot.users = { ...bot.users, ...users };
|
||||||
|
|
Loading…
Reference in New Issue