Extending chat message blocks

Hi all,

I would like to develop a plugin for displaying GitLab/GitHub activity notifications in Discourse Chat, or more broadly any kind of regular events.

For a richer output I would like to display activity as a card, and I saw that chat messages have a blocks JSON field that seems useful for this purpose. Unfortunately, right now the block types do not seem extensible without patching Chat internals: the schema, serializers, and frontend renderer all enumerate the supported block/element types.

Would it be possible to make blocks a plugin extension point, or should plugins treat it as internal implementation detail?

Concretely, would Discourse be open to either:

  1. a generic event/card block type in core, or
  2. a registerChatBlockType-style plugin API?

I can fall back to rendering Markdown and decorating cooked chat messages client-side, but structured blocks seem like the cleaner model if this direction is considered fair game.

It’ snot high on our roadmap atm, but can you describe what kind of API you think you would need?

Mostly I would like API that would allow a plugin to:

  1. Register a chat message block type name, owned by that plugin
  2. Optionally, provide a JSON schema validator for that block
  3. Register a renderer for that block

All of this can be patched in, but if there is an official API, the stability and safety would be better. My use case is forge activity notifications, but I imagine other applications would exist (RSS as an alternative to the RSS plugin, social media feeds, etc).