[BUG] getDirectByUsernames and Creation of Direct Room returning general channel instead expected direct room by usernames
Nabhag8848 opened this issue · comments
What happened?
-
I'm trying to send the helperMessage on Installation of Apps in Direct room with members (appbot and installer) ie:
notion.bot
but i have observed when i'm trying to get the Direct room by methodgetDirectByUsernames([appBotUsername,installerUsername])
if this direct room doesn't exist its returning general channel and the expected behaviour should be undefined if the direct room with the appBot and installer doesn't exist. -
So i can create one but there is a catch when i'm trying to create the direct room its returning roomId of
General Channel
this is not the expected behaviour.
Code Snippet:
// try to get the room with usernames
// case where we may not a room already
// admin may have deleted the room
let room: IRoom | undefined = await read
.getRoomReader()
.getDirectByUsernames([appbotUserName, InstallerUsername]);
// room exist but returning general channel instead not the expected behaviour
if (room) {
return room;
}
// will create direct room with the expected users but caution when creating the direct room
// its not creating the expected direct room
const newRoom = modify
.getCreator()
.startRoom()
.setType(RoomType.DIRECT_MESSAGE)
.setCreator(creator)
.setMembersToBeAddedByUsernames(usernames);
const roomId = await modify.getCreator().finish(newRoom);
RC Version
v6.2.2
What browsers are you seeing the problem on?
- Firefox
- Chrome
Gqve this a little test and it's working as expected?
https://gsoc2023.rocket.chat/channel/general?msg=HHZJhpg4ddx6B9Eca
https://gist.github.com/debdutdeb/a3c9f715ee3778acb6654cc79bb76a00
Thanks, closing issue, i just found out, app i was deploying had no "room.write" permission in app.json that was causing for some reason roomId to be always GENERAL