Skip to content
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

blocks の内容が取れていない #159

Open
thinca opened this issue Mar 19, 2021 · 1 comment
Open

blocks の内容が取れていない #159

thinca opened this issue Mar 19, 2021 · 1 comment

Comments

@thinca
Copy link
Member

thinca commented Mar 19, 2021

slack-go が用意している構造体が Slack API が返す構造とマッチしていないため、blocks の内容がほぼ丸ごと何も JSON として保存されていない。

最終的に正確にレンダリングするためには blocks の内容は必須

実際のレスポンス: (発言の内容は重要ではないので差し替えてあります)

{
  "client_msg_id": "45da996d-45af-4ea9-938e-31dc7ffc61f9",
  "type": "message",
  "text": "ほげ",
  "user": "U776661HA",
  "ts": "1594114388.335900",
  "team": "T03C4RC8V",
  "blocks": [
    {
      "type": "rich_text",
      "block_id": "0Rh",
      "elements": [
        {
          "type": "rich_text_section",
          "elements": [
            {
              "type": "text",
              "text": "ほげ"
            }
          ]
        }
      ]
    }
  ]
}

JSON として保存されたメッセージ

{
  "client_msg_id": "45da996d-45af-4ea9-938e-31dc7ffc61f9",
  "type": "message",
  "user": "U776661HA",
  "text": "ほげ",
  "ts": "1594114388.335900",
  "team": "T03C4RC8V",
  "replace_original": false,
  "delete_original": false,
  "blocks": [
    {
      "type": "rich_text",
      "block_id": "0Rh"
    }
  ],
  "source_team": "T03C4RC8V",
  "user_team": "T03C4RC8V"
}

elements 以下がゴソッとないです。構造体にもメンバーがないです。

@thinca
Copy link
Member Author

thinca commented Mar 19, 2021

雑な調査メモ

何やら1年半ほど前のもので、この辺りに変更が入ると言う内容の記事を見つけました。

https://api.slack.com/changelog/2019-09-what-they-see-is-what-you-get-and-more-and-less

blocks に関するリファレンスはおそらく以下のページなのですが、 type=rich_text なるものは載っていません… Slack 仕事しろ…。

https://api.slack.com/reference/block-kit/blocks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant