Commit Graph

7 Commits

Author SHA1 Message Date
ryan 14504af950 feat(通知): SafeW 只发正文并注入推送时间
去掉渠道标题前缀,模板可用 pushedAt 显示本地推送时间。
2026-08-16 01:18:27 +08:00
ryan a9b6234208 feat(通知模板): 支持 case 取值映射与事件名匹配渲染
Motivation:
让通知模板能够将 action、event 等原始枚举值映射为可读中文文案,并支持按事件名后缀匹配;同时简化 SafeW 消息发送格式,避免 Markdown 转义引入的显示问题。

Changes:

* 新增 `case` 模板函数,按值匹配 key/文案并支持末尾奇数参数作为默认值
* `case` 匹配兼容事件名后缀(如 trade.close 匹配 .close)
* `line` 前缀自动去除末尾冒号,避免重复冒号
* 模板渲染前自动注入 event 字段,便于模板按事件名取值
* SafeW 消息改为纯文本发送,移除 MarkdownV2 转义
2026-08-16 00:45:27 +08:00
ryan 0210b70bda perf(日志): 空轮询时不输出 Info 日志以减少噪音
Motivation:
轮询安全网关更新时,绝大多数周期没有新消息,持续输出 Info 日志会产生大量噪音并带来不必要的开销。仅在确有更新时才记录日志,便于聚焦真实事件。

Changes:

* 仅在存在更新时输出 getUpdates 日志
* 仅在拉取到群聊数据时输出 poll 日志
2026-08-15 18:19:41 +08:00
ryan a07963e150 feat: enhance Safew chat handling and testing
- Updated `GroupsFromUpdates` function to return the number of updates processed, improving the polling mechanism.
- Added a new test `TestGroupsFromUpdatesCallbackAndJoinRequest` to validate handling of callback queries and join requests.
- Introduced `safewAllowedUpdates` to specify allowed update types in the polling request, enhancing chat management.
- Implemented `ensureWebhookCleared` method to manage webhook state before polling, improving reliability.
2026-08-15 01:56:12 +08:00
ryan e369f398d8 feat: enhance Safew error handling and polling mechanism
- Added error_msg field to safewAPIResponse for better error descriptions.
- Updated safewErrorDescription function to include error_msg in the output.
- Introduced a new test to verify that error messages are included in Safew error descriptions.
- Improved the polling mechanism in the Watcher to handle conflicts and ensure no overlapping polls occur.
2026-08-15 01:07:01 +08:00
ryan bd8a9ff96d feat: 增加 SafeW 已监控群列表接口
通过 getUpdates 将群写入 Redis,供创建/编辑渠道时选择 chat_id,避免前端重复传递 token。
2026-08-15 00:40:40 +08:00
ryan 0d0cd0c510 feat: 新增 SafeW 出站通知渠道
通过 Bot API sendMessage 投递渲染后的通知,MarkdownV2 自动转义标题与正文。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-14 00:58:44 +08:00