# 聊天回复缺少摘录

**URL:** <https://meta.discourse.org/t/chat-replies-missing-excerpt/305991>\
**Category:** Bug\
**Tags:** chat\
**Created:** [2024年四月29日 19:12 UTC](https://meta.discourse.org/t/chat-replies-missing-excerpt/305991 "2024-04-29T19:12:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dsims](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dsims/32/485916_2.png) [@dsims](https://meta.discourse.org/u/dsims)\
**Post date:** [2024年四月29日 19:12 UTC](https://meta.discourse.org/t/chat-replies-missing-excerpt/305991/1 "2024-04-29T19:12:08Z")

</div>

我最近重建了自托管的 discourse，发现所有聊天回复都丢失了摘录文本。回复头像仍然可见，href ID 也正确，点击可以跳转到正确的帖子。

发布新回复时，发布后会显示摘录，但如果关闭聊天，它会像其他回复一样消失。

### 3.3.0.beta2-dev ([f7a1272fa4](https://github.com/discourse/discourse/commits/f7a1272fa48f2d3dd36668757b1b4e07013a3f0d))

（据我所知，我没有任何相关的插件或修改会干扰）

 ![Screenshot 2024-04-29 at 3.08.31 PM](https://global.discourse-cdn.com/meta/original/4X/d/9/4/d945015c700fae28f0010ab4b13ecffdbc37d128.png)  
 ![Screenshot 2024-04-29 at 3.09.24 PM](https://global.discourse-cdn.com/meta/original/4X/9/9/c/99cde92ea03fb86d0c896879c33fb437eb39296d.png)

```plaintext
         {
            "id": 1892,
            "message": "testing reply",
            "cooked": "\u003cp\u003etesting reply\u003c/p\u003e",
            "created_at": "2024-04-29T19:02:11Z",
            "excerpt": "testing reply",
            "chat_channel_id": 2,
            "streaming": false,
            "user": {...},
            "mentioned_users": [],
            "available_flags": [],
            "chat_webhook_event": null,
            "in_reply_to": {
                "id": 1880,
                "cooked": "\u003cp\u003earn teh powahz\u003c/p\u003e",
                "excerpt": null,
                "user": {...},
                "chat_webhook_event": null
            },
            "uploads": []
        },

```

---

<div class="post-metadata">

**Author:** ![dsims](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dsims/32/485916_2.png) [@dsims](https://meta.discourse.org/u/dsims)\
**Post date:** [2024年四月29日 21:11 UTC](https://meta.discourse.org/t/chat-replies-missing-excerpt/305991/2 "2024-04-29T21:11:37Z")

</div>

我的开发实例是 3.3.0.beta2-dev ([a564274ba2](https://github.com/discourse/discourse/commits/a564274ba277a834b8a3ab4c28b2c1022fd9521e))，比您提供的版本早一周，并且没有这个问题。所以我的猜测是它与这个 [https://github.com/discourse/discourse/pull/26712](https://github.com/discourse/discourse/pull/26712) 或这个 [FIX: build chat message excerpt for thread preview by dbattersby · Pull Request #26765 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/26765) 有关。

---

<div class="post-metadata">

**Author:** ![dsims](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dsims/32/485916_2.png) [@dsims](https://meta.discourse.org/u/dsims)\
**Post date:** [2024年四月30日 12:58 UTC](https://meta.discourse.org/t/chat-replies-missing-excerpt/305991/4 "2024-04-30T12:58:29Z")

</div>

在我的大约 1000 条聊天消息的案例中，只需更新所有消息以添加摘要即可：

`Chat::Message.where(excerpt: nil).each{|m| m.update(excerpt: m.build_excerpt) };0`

但代码修复是在 `plugins/chat/app/serializers/chat/in_reply_to_serializer.rb` 中添加一个后备：

```plaintext
def excerpt
  object.excerpt || object.build_excerpt
end

```

---

<div class="post-metadata">

**Author:** ![davidb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/davidb/32/554671_2.png) [@davidb](https://meta.discourse.org/u/davidb)\
**Post date:** [2024年五月1日 04:35 UTC](https://meta.discourse.org/t/chat-replies-missing-excerpt/305991/5 "2024-05-01T04:35:55Z")

</div>

感谢您的报告。我已经能够重现此问题，我将对此进行调查并尽快分享修复方案。

---

<div class="post-metadata">

**Author:** ![davidb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/davidb/32/554671_2.png) [@davidb](https://meta.discourse.org/u/davidb)\
**Post date:** [2024年五月1日 14:50 UTC](https://meta.discourse.org/t/chat-replies-missing-excerpt/305991/6 "2024-05-01T14:50:42Z")

</div>

此提交应能解决此问题：

> <https://github.com/discourse/discourse/commit/c1f6ec5f62a8406cdb1284637b3681d14e93b4e3>

---

<div class="post-metadata">

**Author:** ![davidb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/davidb/32/554671_2.png) [@davidb](https://meta.discourse.org/u/davidb)\
**Post date:** [2024年五月4日 14:51 UTC](https://meta.discourse.org/t/chat-replies-missing-excerpt/305991/7 "2024-05-04T14:51:20Z")

</div>

此主题已在 3 天后自动关闭。不再允许回复。
