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

Links are not parsed / handled correctly #40

Open
damienalexandre opened this issue Mar 30, 2023 · 3 comments
Open

Links are not parsed / handled correctly #40

damienalexandre opened this issue Mar 30, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@damienalexandre
Copy link
Member

damienalexandre commented Mar 30, 2023

Slack links don't have a "markdown like" format:

image

@damienalexandre damienalexandre added the bug Something isn't working label Mar 30, 2023
@lyrixx
Copy link
Member

lyrixx commented Mar 30, 2023

FTR, I use a "MD => HTML" transformation. And slack messages are not in MD 😬
I don't know if a "slack format => HTML" transformer exist in PHP. I don't want to re-implement one!

@damienalexandre
Copy link
Member Author

In theory you should have a "blocks" property on the message that's doing the actual parsing:

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

Then we need to translate this to HTML.

@lyrixx
Copy link
Member

lyrixx commented Mar 30, 2023

Thanks 👍🏼

Example of an API response:

array:12 [
  "iid" => "1df235db-374b-4871-911f-aeb0e9a499d9"
  "team" => "T0FLD8LEM"
  "score" => 0
  "channel" => array:12 [
    "id" => "C0FLD8LSV"
    "is_channel" => true
    "is_group" => false
    "is_im" => false
    "name" => "general"
    "is_shared" => false
    "is_org_shared" => false
    "is_ext_shared" => false
    "is_private" => false
    "is_mpim" => false
    "pending_shared" => []
    "is_pending_ext_shared" => false
  ]
  "type" => "message"
  "user" => "U0FLDV6UW"
  "username" => "lyrixx"
  "ts" => "1680169830.781739"
  "attachments" => array:1 [
    0 => array:12 [
      "image_url" => "https://github.githubassets.com/images/modules/open_graph/github-logo.png"
      "image_width" => 1200
      "image_height" => 1200
      "image_bytes" => 7038
      "from_url" => "https://github.com/notifications?query=is%3Aunread"
      "service_icon" => "https://a.slack-edge.com/80588/img/unfurl_icons/github.png"
      "id" => 1
      "original_url" => "https://github.com/notifications?query=is%3Aunread"
      "fallback" => "GitHub"
      "text" => "GitHub is where people build software. More than 100 million people use GitHub to discover, fork, and contribute to over 330 million projects."
      "title" => "GitHub"
      "title_link" => "https://github.com/notifications?query=is%3Aunread"
    ]
  ]
  "blocks" => array:1 [
    0 => array:3 [
      "type" => "rich_text"
      "block_id" => "Ccn"
      "elements" => array:3 [
        0 => array:2 [
          "type" => "rich_text_section"
          "elements" => array:3 [
            0 => array:2 [
              "type" => "text"
              "text" => "Un message  "
            ]
            1 => array:3 [
              "type" => "link"
              "url" => "https://github.com/notifications?query=is%3Aunread"
              "text" => "un lien"
            ]
            2 => array:2 [
              "type" => "text"
              "text" => " un autre message\n"
            ]
          ]
        ]
        1 => array:3 [
          "type" => "rich_text_preformatted"
          "elements" => array:1 [
            0 => array:2 [
              "type" => "text"
              "text" => "du code"
            ]
          ]
          "border" => 0
        ]
        2 => array:2 [
          "type" => "rich_text_section"
          "elements" => array:2 [
            0 => array:2 [
              "type" => "text"
              "text" => "encore du text "
            ]
            1 => array:3 [
              "type" => "link"
              "url" => "https://example.com"
              "text" => "un autre lien"
            ]
          ]
        ]
      ]
    ]
  ]
  "text" => """
    Un message  <https://github.com/notifications?query=is%3Aunread|un lien> un autre message\n
    ```du code```\n
    encore du text <https://example.com|un autre lien>
    """
  "permalink" => "https://lyrixx.slack.com/archives/C0FLD8LSV/p1680169830781739"
]

Now, I need a lib that is able to transform all theses block in HTML 👍🏼 I'll be much cleaner than my hack 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants