RocketChat / Rocket.Chat.Apps-engine

The Rocket.Chat Apps engine and definitions.
https://rocketchat.github.io/Rocket.Chat.Apps-engine/
MIT License
116 stars 118 forks source link

Open Direct Message through code inside app #335

Open amit1rana opened 4 years ago

amit1rana commented 4 years ago

My app simulates Direct Message between multiple users. From the general channel, I launch my app using the slash command, which opens a pop-up to select the users and it creates a room (type=Direct_message) which shows in the sidebar. All good till here.

But, I want (via code) to open this Direct Message created (also when I recreate a new Direct message with same users, it should open the Direct Message previously created) Is it possibile via code?

//app export class DirectMessageApp extends App implements IUIKitInteractionHandler {

//code for room creation

public async executeViewSubmitHandler(context: UIKitViewSubmitInteractionContext, read: IRead, http: IHttp, persistence: IPersistence, modify: IModify) {
    ...
     const data = context.getInteractionData();
     const usernames: Array<string> = ['user1','user2'];
     const supportDirectMessage = await modify.getCreator().startRoom()
                                            .setType(RoomType.DIRECT_MESSAGE)
                                            .setCreator(data.user)
                                            .setMembersToBeAddedByUsernames(usernames);
     const directId = await modify.getCreator().finish(supportDirectMessage);

     //MISSING CODE TO OPEN THE DIRECT MESSAGE CREATED

     return {
            success: true,
     };
}

This funtionality is present in Rocket.Chat, so I wanted to know if its feasibile via code (or I need to integrate some funtionality at Front-end like Webhook etc.) to make it open the Direct Message. Version of Rocket.Chat Server: 3.8.0-develop

d-gubert commented 4 years ago

You mean make users navigate to a specific room (DM in this case)? It's currently not possible. But the DM should be first thing on the side bar right after being created