# 扩展聊天消息块

**URL:** https://meta.discourse.org/t/extending-chat-message-blocks/405006
**Category:** Development
**Tags:** chat, plugin-api
**Created:** [2026年六月10日 19:46 UTC](https://meta.discourse.org/t/extending-chat-message-blocks/405006 "2026-06-10T19:46:48Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![Anton\_Akhmerov](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/anton_akhmerov/32/169548_2.png) [@Anton\_Akhmerov](https://meta.discourse.org/u/Anton_Akhmerov)
#### Post date: [2026年六月10日 19:46 UTC](https://meta.discourse.org/t/extending-chat-message-blocks/405006/1 "2026-06-10T19:46:48Z")

</div>

大家好，

我想开发一个插件，用于在 Discourse Chat 中显示 GitLab/GitHub 的活动通知，或者更广泛地说，任何类型的常规事件。

为了获得更丰富的输出效果，我希望将活动显示为卡片。我注意到聊天消息有一个 `blocks` JSON 字段，看起来非常适合此用途。不幸的是，目前块类型似乎无法在不修补 Chat 内部代码的情况下进行扩展：模式定义、序列化器和前端渲染器都列出了支持的块/元素类型。

是否有可能将 `blocks` 作为插件扩展点？还是说插件应将其视为内部实现细节？

具体来说，Discourse 是否愿意接受以下任一方案：

1. 在核心代码中添加一个通用的事件/卡片块类型，或者
2. 提供一个类似 `registerChatBlockType` 的插件 API？

如果这条路径被认为可行，我可以退而求其次，通过渲染 Markdown 并在客户端装饰已处理的聊天消息来实现。但如果采用结构化块，这似乎是更优雅的模型。

---

_[View the full topic](https://meta.discourse.org/t/extending-chat-message-blocks/405006)._
