web-api: Blocks in client.conversations.history are different to blocks that use in message posting

Open
#1,903 8 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
node.js, typescript
Domain
api

Research direction

The issue names client.conversations.history, chat.postMessage, and chat.update as the entry points. Read their TypeScript block types first and confirm whether returned blocks are valid inputs; done requires a decided, tested resolution for the incompatibility.

Written by the indexing model from the issue text.

Description

area:typescript auto-triage-skip discussion enhancement pkg:web-api
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:

    const result = await client.conversations.history({
      channel: FROM_CHANNEL,
      latest: TARGET_TS,
      inclusive: true,
      limit: 1,
    });
    if (result.messages !== undefined) {
      const message = result.messages[0];
      if (message) {
      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],
      });
    }

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 [ ])
  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion
Requirements (place an x in each of the [ ])
  • [ x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [x ] I've read and agree to the Code of Conduct.
  • [x ] I've searched for any related issues and avoided creating a duplicate issue.

Dominant language
TypeScript
Stars
3.4k
Forks
693
Avg merge
1d 1h
Merged PRs (30d)
67

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from slackapi/node-slack-sdk

All issues in slackapi/node-slack-sdk

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.