# Webhook 在主题的第一个帖子 post\_edited 时触发两次

**URL:** https://meta.discourse.org/t/post-webhook-fires-two-times-on-post-edited-for-first-post-in-a-topic/162408
**Category:** Bug
**Created:** [2020年八月29日 10:06 UTC](https://meta.discourse.org/t/post-webhook-fires-two-times-on-post-edited-for-first-post-in-a-topic/162408 "2020-08-29T10:06:06Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Terrapop](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@Terrapop](https://meta.discourse.org/u/Terrapop)
#### Post date: [2020年八月29日 10:06 UTC](https://meta.discourse.org/t/post-webhook-fires-two-times-on-post-edited-for-first-post-in-a-topic/162408/1 "2020-08-29T10:06:07Z")

</div>

首先，它会触发一个事件，其负载（payload）中没有任何变更（即当前发布的内容），随后再触发第二个事件，其中包含变更内容。

这仅适用于主题中首帖的变更。

预期行为：仅触发一个事件，其负载中包含变更后的帖子内容。

或者这是预期行为？如果是这样，这对接收端点来说令人困惑：虽然信号表明有变更，但负载中却没有任何变更内容，导致无法判断这是一个虚假的变更事件还是其他情况（因为负载中未提供任何相关信息）。

在 post\_created 事件以及对主题中后续帖子的变更上，系统表现符合预期，仅触发一个事件。

有人能帮忙吗？处理首帖的 webhook 时，这个问题让我非常头疼。

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2020年八月31日 02:23 UTC](https://meta.discourse.org/t/post-webhook-fires-two-times-on-post-edited-for-first-post-in-a-topic/162408/2 "2020-08-31T02:23:37Z")

</div>

我不确定这是否是故意的，@vinothkannans 你知道吗？

---

<div class="post-metadata">

### Author: ![Terrapop](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@Terrapop](https://meta.discourse.org/u/Terrapop)
#### Post date: [2020年八月31日 07:23 UTC](https://meta.discourse.org/t/post-webhook-fires-two-times-on-post-edited-for-first-post-in-a-topic/162408/4 "2020-08-31T07:23:46Z")

</div>

这对接收端点来说至少令人困惑，因为它没有单一的使用场景。应该是一个事件，而不是两个。

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [2020年九月3日 21:22 UTC](https://meta.discourse.org/t/post-webhook-fires-two-times-on-post-edited-for-first-post-in-a-topic/162408/5 "2020-09-03T21:22:38Z")

</div>

我已在以下 PR 中修复了此问题。由于这改变了主题 Web 钩子的触发方式，在合并之前我必须再次确认该变更。

> <https://github.com/discourse/discourse/pull/10590>

---

<div class="post-metadata">

### Author: ![Terrapop](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@Terrapop](https://meta.discourse.org/u/Terrapop)
#### Post date: [2020年九月3日 21:26 UTC](https://meta.discourse.org/t/post-webhook-fires-two-times-on-post-edited-for-first-post-in-a-topic/162408/6 "2020-09-03T21:26:51Z")

</div>

太棒了，谢谢 @vinothkannans，我们的帖子 Webhook 端点会非常喜欢这个 👍🏻

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2020年九月7日 08:06 UTC](https://meta.discourse.org/t/post-webhook-fires-two-times-on-post-edited-for-first-post-in-a-topic/162408/7 "2020-09-07T08:06:07Z")

</div>


