docs-matrix-spec/locales/zh-Hans/push-gateway-api.md
2025-04-20 16:13:37 +08:00

57 lines
3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: "推送网关 API"
weight: 50
type: docs
---
{{< boxes/warning >}}
本页面的翻译未经核对,可能存在翻译质量不佳、错翻、漏翻等情况。您可以在 <a href="https://codeberg.org/wholetrans/docs-matrix-spec">Forgejo 存储库</a> 打开 Issue、提交 Pull Request 或<a href="mailto:errata@wholetrans.org">邮件联系</a>我们提出改进建议和参与翻译与核对。
{{< /boxes/warning >}}
客户端可能希望在主服务器接收到事件时获得推送通知。对此进行管理的是一个名为推送网关的独立实体。
## 概述
客户端的主服务器会将接收到的事件信息转发给推送网关。随后,推送网关会向推送通知提供商(如 APNS、GCM发送推送通知。
```
+--------------------+ +-------------------+
Matrix HTTP | | | |
Notification Protocol | 应用开发者 | | 设备供应商 |
| | | |
+-------------------+ | +----------------+ | | +---------------+ |
| | | | | | | | | |
| Matrix 主服务器 +-----> 推送网关 +------> 推送提供商 | |
| | | | | | | | | |
+-^-----------------+ | +----------------+ | | +----+----------+ |
| | | | | |
Matrix | | | | | |
客户端/服务器 API + | | | | |
| | +--------------------+ +-------------------+
| +--+-+ |
| | <-------------------------------------------+
+---+ |
| | 提供商推送协议
+----+
移动设备或客户端
```
## API 标准
### 不支持的端点
如果收到对不支持(或未知)端点的请求,则服务器必须以 404 `M_UNRECOGNIZED` 错误进行响应。
类似地405 `M_UNRECOGNIZED` 错误用于表示对已知端点使用了不被支持的方法。
## 主服务器行为
本节描述了“HTTP”推送器用于向推送网关发送事件通知的格式。如果端点返回 HTTP 错误码,主服务器应在合理的时间内采用指数退避机制进行重试。
在推送事件通知时,主服务器应在 `/notify` 请求中包含所有与事件相关的字段。当主服务器执行 `format``"event_id_only"` 的推送时,仅需填写 `event_id``room_id``counts``devices` 字段。
请注意,本端点的大多数数值和行为已由客户端-服务器 API 的 [推送模块](/client-server-api#push-notifications) 描述。
{{% http-api spec="push-gateway" api="push_notifier" %}}