# 即使为空，群组收件箱和存档也可见

**URL:** https://meta.discourse.org/t/group-inboxes-and-archives-are-visible-even-when-empty/331482
**Category:** Bug
**Tags:** groups, personal-messages
**Created:** [2024 年10 月 18 日 06:57 UTC](https://meta.discourse.org/t/group-inboxes-and-archives-are-visible-even-when-empty/331482 "2024-10-18T06:57:38Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![alehandrof](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alehandrof/32/119526_2.png) [@alehandrof](https://meta.discourse.org/u/alehandrof)
#### Post date: [2024 年10 月 18 日 06:57 UTC](https://meta.discourse.org/t/group-inboxes-and-archives-are-visible-even-when-empty/331482/1 "2024-10-18T06:57:39Z")

</div>

大家好，

我们的网站上有许多旧群组，它们的收件箱或存档中没有任何消息，但它们仍然显示在侧边栏和 /my/messages 页面上。

我找到了这个旧帖子，但它没有提供适合我的解决方案：[Messaging: Group inboxes and archives show even after all messages deleted](https://meta.discourse.org/t/messaging-group-inboxes-and-archives-show-even-after-all-messages-deleted/48467)

还有其他建议吗？

---

<div class="post-metadata">

### Author: ![Heliosurge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/heliosurge/32/571810_2.png) [@Heliosurge](https://meta.discourse.org/u/Heliosurge)
#### Post date: [2024 年10 月 19 日 07:48 UTC](https://meta.discourse.org/t/group-inboxes-and-archives-are-visible-even-when-empty/331482/2 "2024-10-19T07:48:27Z")

</div>

这些旧群组……我想知道您是否可以编辑群组并将“谁可以给此群组发送消息？”更改为“无人”？

或者这些旧群组是否仍然需要群组邮箱？

---

<div class="post-metadata">

### Author: ![alehandrof](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alehandrof/32/119526_2.png) [@alehandrof](https://meta.discourse.org/u/alehandrof)
#### Post date: [2025 年3 月 10 日 21:22 UTC](https://meta.discourse.org/t/group-inboxes-and-archives-are-visible-even-when-empty/331482/3 "2025-03-10T21:22:03Z")

</div>

对不起没有早点回复，但所有群组的“谁可以给这个群发消息”都设置为“无人”。

我还能检查其他什么吗？

---

<div class="post-metadata">

### Author: ![Heliosurge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/heliosurge/32/571810_2.png) [@Heliosurge](https://meta.discourse.org/u/Heliosurge)
#### Post date: [2025 年3 月 11 日 11:55 UTC](https://meta.discourse.org/t/group-inboxes-and-archives-are-visible-even-when-empty/331482/4 "2025-03-11T11:55:57Z")

</div>

这确实听起来像是个 bug。如果设置为 nobody，那么该群组邮箱按理说不应该可见。

我想到的一个变通方案是，使用 `#customization:theme-component` 将群组作为类添加进去，然后针对每个群组类，在设置为 nobody 的群组邮箱上应用 `display: none`。之所以建议使用群组类，是因为我想如果用 CSS 来隐藏它们，可能会一并隐藏了管理员群组的邮箱。

> [@当前用户的组的CSS类](https://meta.discourse.org/t/css-classes-for-current-users-groups/226068):
>
> ||| -|-|-| discourse2 | 摘要 | 为当前用户所属群组添加 CSS 类 将用户所属的群组添加为 \<body\> 标签上的 CSS 类。 | eyeglasses | 预览 | [在 theme-creator.discourse.org 上预览](https://discourse.theme-creator.io/theme/Johani/user-groups-css-classes) | hammer_and_wrench | 代码库链接 | \u003chttps://github.com/discourse/discourse-groups-css-classes-in-body\u003e open_book |首次使用 Discourse 主题？ | [Discourse 主题使用入门指南](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966)\n\n[wrap=theme-install-button repoUrl="[https://github.com/discourse/discourse-groups-css-classes-in-body\](https://github.com/discourse/discourse-groups-css-classes-in-body%5C)" repoName="Discourse 为当前用户所属群组添加 CSS 类"]\n安装此主题组件\n[/wrap]\n\n\n之前：\n\n[image]\n\n之后：\n\n[…

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [2025 年4 月 12 日 14:54 UTC](https://meta.discourse.org/t/group-inboxes-and-archives-are-visible-even-when-empty/331482/5 "2025-04-12T14:54:58Z")

</div>

那些旧群组以前有消息吗？我的个人网站上有一个群组，里面只有一条消息，收件箱会显示在侧边栏。我刚刚删除了消息，群组收件箱仍然显示着。

已删除的消息不再显示在收件箱中，即使对我这个管理员来说也是如此。我能够通过浏览器历史记录浏览回它，并看到它仍然作为已删除消息存在。我尝试删除该群组，但它不允许我这样做。我取消了删除，然后删除了该群组。然后为了保险起见，我删除了消息。

收件箱仍然显示着——所以我怀疑该群组收件箱中仍然存在其他已删除的消息。

所以是的，我认为这里存在一个 bug——如果群组收件箱中唯一的消息已被删除，那么群组收件箱不应显示在侧边栏中。

目前唯一的解决方法是删除群组并重新创建它。

使用数据浏览器获取群组收件箱中任何已删除消息的帖子 ID 来证实我的理论，并查看这些帖子，这将很有趣。

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [2025 年4 月 12 日 15:29 UTC](https://meta.discourse.org/t/group-inboxes-and-archives-are-visible-even-when-empty/331482/6 "2025-04-12T15:29:56Z")

</div>

> [@tobiaseigen](#):
>
> 我刚刚删除了消息，群组收件箱仍然显示。

你之后触发了数据库一致性作业吗？我认为一旦它运行完毕，收件箱就不再显示了。

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [2025 年4 月 12 日 15:54 UTC](https://meta.discourse.org/t/group-inboxes-and-archives-are-visible-even-when-empty/331482/7 "2025-04-12T15:54:22Z")

</div>

好主意！对我来说奏效了。

编辑：帖子中的[链接](https://meta.discourse.org/t/messaging-group-inboxes-and-archives-show-even-after-all-messages-deleted/48467)主题对我很有帮助。不知道你那边是怎么回事 @alehandrof.. 问题最终消失了吗？

---

<div class="post-metadata">

### Author: ![alehandrof](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alehandrof/32/119526_2.png) [@alehandrof](https://meta.discourse.org/u/alehandrof)
#### Post date: [2025 年4 月 14 日 08:53 UTC](https://meta.discourse.org/t/group-inboxes-and-archives-are-visible-even-when-empty/331482/8 "2025-04-14T08:53:05Z")

</div>

我运行了数据库一致性作业，但收件箱仍然存在。如果这有什么区别的话，我是一个管理员用户。但它们应该消失，因为它们是空的——`latest`、`new`、`unread`、`archive` 都没有任何消息。

我卡住了 ☹

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [2025 年4 月 14 日 09:34 UTC](https://meta.discourse.org/t/group-inboxes-and-archives-are-visible-even-when-empty/331482/9 "2025-04-14T09:34:08Z")

</div>

此数据浏览器查询是否返回任何主题？

```sql
-- [params]
-- group_id :inboxgroup

SELECT tg.topic_id, t.id AS topic_exists, t.deleted_at
FROM topic_allowed_groups tg
LEFT JOIN topics t ON t.id = tg.topic_id
WHERE tg.group_id = :inboxgroup
  AND (
    t.deleted_at IS NULL
    OR t.id IS NULL
  )

```

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [2025 年4 月 14 日 13:34 UTC](https://meta.discourse.org/t/group-inboxes-and-archives-are-visible-even-when-empty/331482/10 "2025-04-14T13:34:44Z")

</div>

在我的情况并非如此。👍

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [2025 年4 月 14 日 14:07 UTC](https://meta.discourse.org/t/group-inboxes-and-archives-are-visible-even-when-empty/331482/11 "2025-04-14T14:07:18Z")

</div>

只有当收件箱显示时，才应显示主题。

我已经找到了实现这一目标的方法，即使收件箱是空的：  
在发送到该群组的消息被 **设为公开主题** 之后。

所以：

1. 创建一个新群组
2. 至少允许管理员向群组发送消息
3. 添加成员到群组以检查收件箱是否显示
4. 向群组发送消息
5. 在管理员扳手菜单中使用“设为公开主题”选项
6. 收件箱是空的，但即使在数据库一致性作业运行后，收件箱也不会消失

在这种情况下，上面的数据探索器查询会返回该主题。
