slack-go / slack

Slack API in Go, originally by @nlopes; Maintainers needed, contact @parsley42
https://pkg.go.dev/github.com/slack-go/slack
BSD 2-Clause "Simplified" License
4.64k stars 1.13k forks source link

Adding "blocks" field to MessageEvent #1112

Closed hackthehackerman closed 1 year ago

hackthehackerman commented 1 year ago

This PR adds the blocks field as a top level field for the MessageEvent data model. This matches the actual data model in the raw JSON string. Below is a real event that slack sends via the Event API. I did not remove the existing blocks field under attachments in case I'm not aware of the cases when blocks indeed falls under attachments.

{
  "bot_id": "B04378FBE5R",
  "type": "message",
  "text": "Bug title",
  "user": "U042SQ2ME87",
  "ts": "1663713819.089279",
  "app_id": "A0DB5GQPN",
  "team": "T03KU7HEQGN",
  "bot_profile": {
    "id": "B04378FBE5R",
    "deleted": false,
    "name": "Instabug",
    "updated": 1663709778,
    "app_id": "A0DB5GQPN",
    "icons": {
      "image_36": "https://avatars.slack-edge.com/2019-09-09/741090569378_eef3e9d74f0b4a41a7ce_36.png",
      "image_48": "https://avatars.slack-edge.com/2019-09-09/741090569378_eef3e9d74f0b4a41a7ce_48.png",
      "image_72": "https://avatars.slack-edge.com/2019-09-09/741090569378_eef3e9d74f0b4a41a7ce_72.png"
    },
    "team_id": "T03KU7HEQGN"
  },
  "blocks": [
    {
      "type": "section",
      "block_id": "+VI",
      "text": {
        "type": "mrkdwn",
        "text": "[New bug from sample@email.com on Birdy Demo App - beta](https://insta.co/bugs/1caeee46-9c60-465a-ac0c-e74f2e2e7b86?utm_source=slack&utm_medium=integrations&utm_content=title) \n Bug title",
        "verbatim": false
      },
      "fields": [
        {
          "type": "mrkdwn",
          "text": "*Categories*: \n Bug \n UI issue",
          "verbatim": false
        },
        {
          "type": "mrkdwn",
          "text": "*App Version*: \n 1.0.0 (1.0)",
          "verbatim": false
        },
        {
          "type": "mrkdwn",
          "text": "*Device*: \n iPhone 6, iOS",
          "verbatim": false
        },
        {
          "type": "mrkdwn",
          "text": "*Location*: \n Schimmelmouth, Solomon Islands (en-US)",
          "verbatim": false
        }
      ]
    },
    {
      "type": "image",
      "block_id": "357",
      "image_url": "https://instabug-pro.s3.amazonaws.com/integrations/1122.png",
      "alt_text": "A screenshot attached by the user.",
      "title": {
        "type": "plain_text",
        "text": " ",
        "emoji": true
      },
      "image_width": 244,
      "image_height": 435,
      "image_bytes": 37522,
      "is_animated": true,
      "fallback": "244x435px image"
    }
  ]
}
hackthehackerman commented 1 year ago

@kanata2 PTAL :)

hackthehackerman commented 1 year ago

Closing this since there hasn't been any movements.