rusq / slackdump

Save or export your private and public Slack messages, threads, files, and users locally without admin privileges.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Variation in capitalization of "type"

svenssonaxel opened this issue · comments

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}"
commented

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?

commented

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"}]}]}]}]}

commented

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

commented

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.

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",
commented

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 :)

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.

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