slackapi / java-slack-sdk

Slack Developer Kit (including Bolt for Java) for any JVM language
https://slack.dev/java-slack-sdk/
MIT License
571 stars 212 forks source link

No event class for `channel_convert_to_public` #1348

Open mgroth0 opened 1 month ago

mgroth0 commented 1 month ago

I could not deserialize an event I got from a webhook with this type because there is no class for it. I am using gson deserializing which involves statically registering a class for each event type with EventsApiPayloadParser.

zimeg commented 1 month ago

Hi @mgroth0! 👋 I'm looking into this now, but I can confirm that the channel_convert_to_public event is from a message subtype with a payload that resembles:

{
  subtype: 'channel_convert_to_public',
  user: 'U02APLEMRPS',
  text: 'made this channel *public*. Any member in this workspace can see and join it.',
  type: 'message',
  ts: '1723680078.026719',
  channel: 'C07GX2G5F1T',
  event_ts: '1723680078.026719',
  channel_type: 'channel'
}

While this isn't documented at the moment and until we have formal SDK support for it, is it possible to deserialize this using the message subtype as a workaround?

mgroth0 commented 1 month ago

Hey @zimeg Thanks for looking into this!

So if I understand correctly, you would suggest as a workaround to using gson.fromJson(jsonString,MessageEvent::class.java). That sounds reasonable!

Unfortunately I don't have a quick way to test if this works (and this event is pretty rare in my organization so I don't know when I'll see it again). So I can't confirm whether or not it works, but I do appreciate the workaround!

You wouldn't happen to know if there is a way with Slack webhooks to generate fake events of every type for testing purposes would you? The best way I could think of would be to create my own "test organization/workspace", install my app there, then manually do stuff in the slack app to generate a bunch of events. Basically, not programatic at all (therefore I won't be doing that). It would be nice if there was some testing framework that could just send fake events (with the same format as real events) automatically.

zimeg commented 1 month ago

@mgroth0 no problem! I haven't tested this myself, but a bit more typing might be needed to satisfy the complete channel_convert_to_public patterns I think. I'd recommend referencing the parsing for MessageChannelArchiveEvent using the above values for now:

I'm not sure when SDK support might be added either, but I'm searching for more info on the actual event! 📚

You wouldn't happen to know if there is a way with Slack webhooks to generate fake events of every type for testing purposes would you?

This is a wishlist item of mine haha 🎁 👀 Right now no, but our developer program offers sandboxed workspaces just for testing! It's not quite programatic but is still so super useful for testing edges 🙏

seratch commented 3 weeks ago

Since this message subtype pattern is not yet available in our public document here, I've removed the "bug" label from this issue. With that being said, once we add this pattern to the document, we should support the event payload out of the box!