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

Variation in capitalization of "type" #226

Closed
svenssonaxel opened this issue Jun 28, 2023 · 8 comments · Fixed by #275
Closed

Variation in capitalization of "type" #226

svenssonaxel opened this issue Jun 28, 2023 · 8 comments · Fixed by #275
Labels
bug Something isn't working upstream Issue related to an upstream library

Comments

@svenssonaxel
Copy link

The block elements have a type field, but sometimes it's in lowercase, sometimes capitalized.

          {
            "type": "rich_text_section",
            "elements": [
              {
                "type": "text",
                "text": "Blabla\n"
              }
            ]
          },
          {
            "Type": "rich_text_preformatted",
            "Raw": "{\"type\":\"rich_text_preformatted\",\"elements\":[{\"type\":\"text\",\"text\":\"Blabla back to you\n\"}],\"border\":0}"
@rusq
Copy link
Owner

rusq commented Jun 29, 2023

Hey Axel, that's very interesting, it looks like the upstream may not have an appropriate struct tags. Is this just some rich text? How can I reproduce this?

@rusq
Copy link
Owner

rusq commented Jun 29, 2023

NVM, was able to reproduce

{"channel_id":"CHY5HUESG","name":"everyone","messages":[{"client_msg_id":"79675403-4659-4828-a8ac-af4f16bca2d6","type":"message","user":"UHSD97ZA5","text":"Hello\npreformatted?```\ntest","ts":"1688031487.552909","team":"THY5HTZ8U","replace_original":false,"delete_original":false,"metadata":{"event_type":"","event_payload":null},"blocks":[{"type":"rich_text","block_id":"Ixznh","elements":[{"type":"rich_text_section","elements":[{"type":"text","text":"Hello\n"}]},{"Type":"rich_text_preformatted","Raw":"{"Type":"rich_text_preformatted","Raw":"{\"type\":\"rich_text_preformatted\",\"elements\":[{\"type\":\"text\",\"text\":\"preformatted?\"}],\"border\":0}"}"},{"type":"rich_text_section","elements":[{"type":"text","text":"test"}]}]}]}]}

@rusq
Copy link
Owner

rusq commented Jun 29, 2023

Looks like it's not implemented in the upstream, that's why it just dumps the block into the "RAW" section. The corresponding RAW API output looks like the following (without any unmasrhalling)
image

@rusq
Copy link
Owner

rusq commented Jun 29, 2023

There's no implementation for the RichTextElement, and it falls back to this

type RichTextUnknown struct {
	Type RichTextElementType
	Raw  string
}

There's no tags on this struct, therefore you see it as is — as "Type" and "Raw".

Looking at the PR queue for slack lib, it doesn't look very promising: i.e. someone submitted the PR to add support Rich Text Lists (slack-go/slack#1155) in January and it's still unmerged, chances are high that this won't be resolved soon, so you might need to implement a temporary workaround.

I'll see into creating a PR to add support for preformatted blocks, but it would be outside of my control to tell you when it's going to be merged.

@rusq rusq added upstream Issue related to an upstream library bug Something isn't working labels Jun 29, 2023
@svenssonaxel
Copy link
Author

It's not a problem for me, my mmetl is already heavily extended and adding a workaround for this doesn't matter; just wanted to raise the issue. I've found three types that appear this way:

"Type": "rich_text_list",
"Type": "rich_text_preformatted",
"Type": "rich_text_quote",

@rusq
Copy link
Owner

rusq commented Jun 29, 2023

Cool, thanks for raising this, I wasn't aware.

Yes, there's a bunch of them, and "rich_text_list" in particular is this one: slack-go/slack#1155 waiting for the time to come for someone to merge it :)

@rusq
Copy link
Owner

rusq commented Feb 11, 2024

Submitted the PR to slack repo to add rich_text_quote and rich_text_preformatted slack-go/slack#1260, the rich_text_list was merged yesterday.

@rusq
Copy link
Owner

rusq commented Mar 9, 2024

Hey @svenssonaxel, good news, this change was merged upstream, and i just updated the master, will be available in next patch.

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

Successfully merging a pull request may close this issue.

2 participants