# 通过查看操作重新生成通知

**URL:** https://meta.discourse.org/t/notifications-being-regenerated-by-looking-through-actions/156709
**Category:** Support
**Created:** [2020年七月3日 16:37 UTC](https://meta.discourse.org/t/notifications-being-regenerated-by-looking-through-actions/156709 "2020-07-03T16:37:47Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [2020年七月3日 16:37 UTC](https://meta.discourse.org/t/notifications-being-regenerated-by-looking-through-actions/156709/1 "2020-07-03T16:37:47Z")

</div>

好的，这是一个关于旧版本的奇怪案例，但我希望有人能提供一些线索，或者可能有类似的经验。

我们有一个论坛（由于依赖自定义插件，版本停留在 2.4.5），用户抱怨收到重复的通知。有时，通知会在事件发生几天后重新生成，而且此时用户已经（在 Discourse 界面中，而非 App 或浏览器中）多次查看并点击过这些通知。

某主题的帖子记录：

```
 post_number | created_at         
-------------+----------------------------
           1 | 2020-06-22 17:06:42.531868
           2 | 2020-06-23 00:11:07.159579
           3 | 2020-06-24 00:35:06.000641
           4 | 2020-06-25 00:17:16.998622
           5 | 2020-06-29 00:00:39.712988
           6 | 2020-06-29 01:03:20.137653
           7 | 2020-06-29 01:32:45.604947

```

该用户针对该主题的通知记录：

```
   id | notification_type | user_id | created_at | topic_id | post_number 
---------+-------------------+---------+----------------------------+----------+-------------
 1125345 | 5 | 956 | 2020-06-24 21:45:21.521173 | 39247 | 3
 1133280 | 5 | 956 | 2020-06-29 01:27:32.242212 | 39247 | 6
 1140349 | 2 | 956 | 2020-07-02 21:11:44.843782 | 39247 | 7

```

如您所见，针对第 7 楼的回复通知是在回复发出 3.5 天之后才生成的。

当我们搜索访问日志以查明 21:11:44 发生了什么时，发现该用户正好在这一秒浏览其“个人资料 - 活动 - 回复”页面（`/user_actions.json?username=redacted&filter=5&offset=240`）。

这几乎像是_浏览这些回复导致了通知的重新生成_。

相关的插件是 onesignal 和 push-notifications。

有人有任何想法吗？

编辑：一天后，第 7 楼的通知再次被重新生成：

```
   id | notification_type | user_id | created_at | topic_id | post_number 
---------+-------------------+---------+----------------------------+----------+-------------
 1125345 | 5 | 956 | 2020-06-24 21:45:21.521173 | 39247 | 3
 1133280 | 5 | 956 | 2020-06-29 01:27:32.242212 | 39247 | 6
 1141684 | 2 | 956 | 2020-07-04 02:23:12.188685 | 39247 | 7

```

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2020年七月3日 19:29 UTC](https://meta.discourse.org/t/notifications-being-regenerated-by-looking-through-actions/156709/2 "2020-07-03T19:29:28Z")

</div>

这听起来有点眼熟，像是我们之前修复过的一个 bug？很难说。

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [2020年七月4日 21:50 UTC](https://meta.discourse.org/t/notifications-being-regenerated-by-looking-through-actions/156709/3 "2020-07-04T21:50:46Z")

</div>

嗯，相关的插件是 onesignal、push-notifications 和 **follow** 。

@outofthebox 我认为这与以下问题有关：

> [@Recurrent Notifications from User Post due to Follow User plugin](https://meta.discourse.org/t/recurrent-notifications-from-user-post-due-to-follow-user-plugin/156073):
>
> Hi Guys, One quick doubt, since I recovered my site from a backup, any time this one specific user replies to a topic, it generates constant “Edit” notifications to the user that created the Topic or that was being replied to. Tried to investigate and seems like there is something weird in Sidekiq, on the “Retries” section some jobs just keep piling there and never seem to succeed. After removing them, the notifications stop (until the person posts on another topic and then a new one is genera…

创建该帖子（用户 #15356）并导致反复向接收通知的用户（用户 #956）发送通知的用户情况如下：

- 正在关注接收通知的用户
- 被一个不存在的用户（用户 #16229）关注

:

```
 select user_id, name, value from user_custom_fields where user_id=15356;
 user_id | name | value          
---------+--------------+------------------------
   15356 | followers | 16229 --> 该用户不存在
   15356 | following | 56,0
   15356 | following | 956,0 --> 接收通知的用户

```

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2020年七月4日 22:59 UTC](https://meta.discourse.org/t/notifications-being-regenerated-by-looking-through-actions/156709/4 "2020-07-04T22:59:06Z")

</div>

所以这又是 Follow 插件的另一个 bug 吗？

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [2020年七月5日 07:47 UTC](https://meta.discourse.org/t/notifications-being-regenerated-by-looking-through-actions/156709/5 "2020-07-05T07:47:30Z")

</div>

我还不确定，看起来有点不同，但另一方面，也有很多共同之处。
