Pusher webhook 如何工作? HTTP POST 请求是从客户端发送的还是从 Pusher 服务器发送的?

How does Pusher webhook work? Is HTTP POST request sended from client or Pusher server?

来自 Pusher 文档

A webhook is sent as a HTTP POST request to the url which you specify.

问题是 - 第一个 POST 请求是从客户端还是 Pusher 服务器发送的?

我想在网站添加新产品时立即通知用户。所以我需要 运行 脚本来检查应该通知哪些用户并向他们发送通知电子邮件。由于可能会有很多用户对产品感兴趣,因此脚本可能会花费很多时间。所以我必须异步进行。否则想要添加产品的用户将不得不等待很长时间才能看到成功消息。

一种方法是使用成功消息触发 ajax 对服务器的调用。但是存在用户离开页面(从而关闭连接)并且我不知道是否所有电子邮件都已发送的危险。

我要找的是网络工作者。然而,由于我已经使用 Pusher 进行实时聊天和通知,我认为我可以使用 Pusher-s webhook 来达到这个目的。

我想发送 "product-added" 事件,该事件在数据中包含产品 ID 而不是成功消息。在事件中,我会使用 JS 显示来自浏览器的成功消息,并使用 Pusher-s webhook 来通知其他人。

Your server should respond to the POST request with a 2XX status code to indicate that the webhook has been successfully received. If a non 2XX status code is returned, Pusher will retry sending the webhook, with exponential backoff, for 5 minutes. This ensures that temporary failure should not affect your ability to receive all webhooks.

我认为,如果 HTTP POST 请求首先从客户端浏览器发送,并且客户端在脚本结束前关闭连接,我可以发送一些电子邮件两次。如果 Pusher 从他们的服务器发送所有(包括第一个)HTTP POST 请求,我没有问题。

Pusher 的 webhooks 是从 Pusher 的服务器发送的。客户端断开连接不会影响它们 - 如果事件到达 Pusher,它们将发送 webhook POST.