Open
Conversation
- 完整实现飞书自定义机器人推送逻辑,支持 `text` / `post` 两种消息格式。 - 实现飞书签名校验:使用 `timestamp + "\n" + secret` 作为 HMAC-SHA256 的 key、空串作为消息体,结果做 Base64 编码,保证与官方文档一致。 - 增强获取时间戳逻辑:优先从多个线上服务 `Date` 头获取时间,带缓存与越界校验,以降低“时间戳不在1小时内”的报错概率。 - 保留并复用钉钉、企业微信、Bark、ntfy、Telegram、邮件等既有推送能力。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 标题(Title)
请提供这个Pull Request中提议的更改的简洁描述:
app/messages/notification_service.py:新增飞书推送、签名校验与时间戳获取增强。🔍 描述(Description)
请描述这个PR做了什么/为什么这些更改是必要的:
send_to_feishu,支持text与post两种消息格式;post模式下按行拆分内容,自动构建飞书富文本结构。timestamp + "\n" + secret作为 HMAC-SHA256 的 key、空串""作为消息体;sign字段,保证与飞书官方文档及社区示例一致,修复19021 sign match fail错误。_get_feishu_timestamp:https://open.feishu.cn/、https://www.feishu.cn/、https://www.cloudflare.com/)的Date响应头获取时间,增加 5 分钟缓存;这些更改是必要的,因为:
19021错误,无法在群里收到消息;📝 类型(Type of Change)
这个PR引入了哪种类型的更改?(请勾选所有适用的选项)
🏗️ 测试(Testing)
请描述您已经进行的测试:
python -m compileall app main.py,确认notification_service.py与其他模块均能成功编译,无语法错误。python main.py启动应用;19021 sign match fail or timestamp is not within one hour from current time,并能在飞书群中收到消息(或至少接口返回StatusCode == 0 / code == 0)。如果适用,请提供测试更改的说明:
secret;text或post),保存配置。📋 检查清单(Checklist)
在您创建这个PR之前,请确保以下所有框都被勾选,方法是在每个框中放置一个
x:注意: 这个PR在所有复选框被勾选之前不会被合并。
感谢您的贡献!