qd-today / qd

QD [v20240210] —— HTTP请求定时任务自动执行框架 base on HAR Editor and Tornado Server
https://qd-today.github.io/qd/
MIT License
4.46k stars 577 forks source link

[Bug] 自定义推送不支持群晖chat webhook #314

Closed Appoip closed 2 years ago

Appoip commented 2 years ago

Verify steps

QianDao Version

20220901

Bug on OS

Linux

Bug on Platform

Docker/Linux 64位

To Reproduce

尝试试过 POST data 多种想法填写都无法收到推送 无论测试的时候提示设置成功还是失败都无法收到推送

Describe the Bug

根据官方的请求是 POST https://DS_IP/webapi/entry.cgi?api=SYNO.Chat.External&XXXXX Content-Type: application/x-www-form-urlencoded payload=%7B%22text%22%3A%22This%20is%20a%20test.%22%7D

通过application/x-www-form-urlencoded

curl -X POST \ --data-urlencode 'payload={"text": "This is a test"}' \ https://DS_IP/webapi/entry.cgi?api=SYNO.Chat.External&XXXXX

主要它有一个 “payload=” 不知如何去写

我用python requests

msg = 'Hello World' webhook_url = "https://DS_IP/webapi/entry.cgi?api=SYNO.Chat.External&XXXXX"

headers = {'Content-Type': 'application/x-www-form-urlencoded'} data = 'payload=' + json.dumps({'text': msg})

r = requests.post(webhook_url, data, headers=headers)

可以收到消息 可能涉及web源码 我就不知道怎么去改了

官方教程网址 https://kb.synology.com/da-dk/DSM/tutorial/How_to_configure_webhooks_and_slash_commands_in_Chat_Integration

QianDao config

No response

QianDao log

Expected behavior

希望可以支持群晖的chat推送

Screenshots

No response

a76yyyy commented 2 years ago

请更新源码后重试

Appoip commented 2 years ago

现在log已经可以发送 ,当发送{t}的时候有错误提示 'latin-1' codec can't encode characters in position 18-21: Body ('推送测试') is not valid Latin-1. Use body.encode('utf-8') if you want to send it encoded in UTF-8.

无法发送测试和保存

a76yyyy commented 2 years ago

现在log已经可以发送 ,当发送{t}的时候有错误提示 'latin-1' codec can't encode characters in position 18-21: Body ('推送测试') is not valid Latin-1. Use body.encode('utf-8') if you want to send it encoded in UTF-8.

无法发送测试和保存

请在后台查看完整的报错路径

Appoip commented 2 years ago

[E 220909 01:16:21 qiandao.Http.Funcs funcs:284] Sent to Cus_Pusher error: 'latin-1' codec can't encode characters in position 18-21: Body ('推送测试') is not valid Latin-1. Use body.encode('utf-8') if yo u want to send it encoded in UTF-8.
[I 220909 01:16:21 tornado.access web:2271] 200 POST /util/custom/1/pusher (172.17.0.1) 46.56ms
[E 220909 01:16:21 qiandao.Web.Handler user:610] UserID: 1 register or tes Cus_Pusher failed! Reason: 'latin-1' codec can't encode characters in position 18-21: Body ('推送测试') is not valid Latin-1. Use body.encode('utf-8') if you want to send it encoded in UTF-8.

a76yyyy commented 2 years ago

请更新源码后重试, 如果还有问题请 reopen 这个 issue