RocketChat / Rocket.Chat.Apps-engine

The Rocket.Chat Apps engine and definitions.

Home Page:https://rocketchat.github.io/Rocket.Chat.Apps-engine/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[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 method getDirectByUsernames([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

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