# Whisper帖子使用的Webhook

**URL:** https://meta.discourse.org/t/webhook-for-whisper-posts/331529
**Category:** Support
**Tags:** webhooks
**Created:** [2024年十月18日 13:18 UTC](https://meta.discourse.org/t/webhook-for-whisper-posts/331529 "2024-10-18T13:18:19Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![renem](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/renem/32/117354_2.png) [@renem](https://meta.discourse.org/u/renem)
#### Post date: [2024年十月18日 13:18 UTC](https://meta.discourse.org/t/webhook-for-whisper-posts/331529/1 "2024-10-18T13:18:19Z")

</div>

是否有一个 webhook 可以在有人创建 Whisper 帖子时触发？我猜没有，但以防万一，我还是问一下。

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [2024年十月18日 17:11 UTC](https://meta.discourse.org/t/webhook-for-whisper-posts/331529/2 "2024-10-18T17:11:59Z")

</div>

我不认为可以配置一个 webhook，使其仅在创建耳语帖子时触发，但你可以创建一个帖子事件 webhook，然后在接收 webhook 的代码中过滤耳语帖子。

耳语帖子的 payload 将会把 `post_type` 字段设置为 `4`。例如：

```json
{
  "post": {
    "id": 740,
    "name": null,
    "username": "scossar",
    "avatar_template": "/letter_avatar_proxy/v4/letter/s/b77776/{size}.png",
    "created_at": "2024-10-18T17:00:36.065Z",
    "cooked": "<p>testing whispers and webhooks</p>",
    "post_number": 5,
    "post_type": 4,
    ...

```

`post_type` 字段的可能值为：

```ruby
[2] pry(main)=> Post.types
=> {:regular=>1,
 :moderator_action=>2,
 :small_action=>3,
 :whisper=>4}

```

---

<div class="post-metadata">

### Author: ![renem](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/renem/32/117354_2.png) [@renem](https://meta.discourse.org/u/renem)
#### Post date: [2024年十月21日 08:34 UTC](https://meta.discourse.org/t/webhook-for-whisper-posts/331529/3 "2024-10-21T08:34:08Z")

</div>

非常感谢 @simon

这比我想象的要简单。我没有意识到/看到 4 是 whisper 的代码。

Rene

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2024年十一月20日 08:34 UTC](https://meta.discourse.org/t/webhook-for-whisper-posts/331529/4 "2024-11-20T08:34:44Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
