-
Notifications
You must be signed in to change notification settings - Fork 662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
web-api: Blocks in client.conversations.history are different to blocks that use in message posting #1903
Comments
Hi @funtaps thanks for writing in 💯 I'm sure others may have bumped in this issue I've compared the payload of conversation.history blocks with the payload of chat.update blocks and they seem to be semantically equivalent. Conversation.history response example show that messages may not have a Could you try adding a check for blocks as follows if (message && message.blocks) {
await client.chat.postMessage({
channel: TO_CHANNEL,
text: message.text,
blocks: message.blocks,
});
await client.chat.update({
channel: FROM_CHANNEL,
ts: TARGET_TS,
blocks: [{type: 'divider'}, ...message.blocks],
}); Would you be able to you provide the JSON of the |
I do not know, if there are some messages that will fail. I'm using TS, and I get errors not in runtime but at compile time. This is type of Block that is returned by converstion.history
And this is the type of Block that is ok to be arguments in postMessage or updateMessage
I do not know, is it possible for conversation.history to return messages with blocks, but to some of this blocks to have no type. But typings suggest that that is the case. |
I see, thank you for clearing things up 🥇 The |
It should not be optional, when you use it as arguments: it is great to see error message, if I am trying to post a message with blocks without type. In summary my question is are ConversationsHistoryResponse typings correct, or they are too abstract, and in fact we can be sure, of some truths, that are not described by this types https://github.com/slackapi/node-slack-sdk/blob/main/packages/web-api/src/response/ConversationsHistoryResponse.ts#L152 ? |
No, every single block must have its
The Web API response types are auto-generated, and as of today, all the properties are optional due to technical limitation of the underlying tools and source data (the source data is much harder to solve). For this reason, some of the properties such as top-level Let me share a bit more context behind this. A few years, the response types did not exist. All the web api responses were just @WilliamBergamin marked this issue as a bug, but unfortunately I don't anticipate our team can improve web api response properties in the short term (more specifically, even within a few years). So, if @funtaps does not have any follow up questions on this topic, let us close this issue. |
Right now there is no good way to use conversations.history messages to copy or update - that is kinda sad. |
👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized. |
I am going to take a look at working on this issue |
Description
If I want to copy message from one channel to another, or if I want to edit something in message, when I use TS and bolt js, I can't do it.
For example:
In both cases, I've got error with blocks field. ConversationsHistoryResponse Block have many differences to normal Block type. For example field
type
declared to be string|undefined in first, and string in second.Are those types correspond to reality?
If so, maybe we can create some converter, that will check blocks from conversations.history and fix them, so they will be OK to use as KnownBlocks?
What type of issue is this? (place an
x
in one of the[ ]
)Requirements (place an
x
in each of the[ ]
)The text was updated successfully, but these errors were encountered: