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

setData in message ignores id

gelinger777 opened this issue · comments

Hi There ,
in webhook of an app I have following



const message = await modify.getCreator().startMessage();


const sender = await read.getUserReader().getById("rocket.cat");

const room = await read.getRoomReader().getById('GENERAL');



const userNameAlias = await read.getEnvironmentReader().getSettings().getValueById('quicksms_sender_name');






if(!room){

    throw new Error('No room ');

}
message.setSender(sender)
.setUsernameAlias(userNameAlias)
.setRoom(room)


// .setThreadId("z5tjJB6ZBmLj79Jqv")
.setGroupable(false)
.setText(`GITHUB webhook recieved`+JSON.stringify(payload));


modify.getCreator().finish(message);
return this.success();

}


When I want to add .setData()

it says

setData(message: IMessage): IMessageBuilder
the message data to set

Provides a convient way to set the data for the message. Note: Providing an "id" field here will be ignored.

So how I can create a message where I preliminarily provide the ID of the message ?? Because I want to group incoming webhooks message with setThreadId, so when thread with specifiq unique ID does not exist I want to create it on my own. Is that possible?

@d-gubert I know you should be quite buisy, but could you give a bit insight on how to achieve this?

Indeed this use case has not been accounted for in the design phase for that component. My suggestion would be 1) to make use of the customFields on the message object to store some metadata or 2) use the Persistence objects to store the metadata associated with the message you want to be your thread

@d-gubert we used Persistence already. Closing for now. But would be good on next iterations allow custom IDs. Even if we used customFields, it would be hard to find the message by value . As I remember it was only possible to search for a message by ID.