Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用webhook和custom通道发送消息时如果内容中包含\n会推送失败的问题 #111

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

fghwett
Copy link

@fghwett fghwett commented Aug 28, 2023

strings.Replace()会将contentdescription中的\n给替换成代码的换行符,导致在webhook的json解析时报错,同时普通通道的传递给第三方接口的json也会出现问题,导致消息发送失败。

我是使用webhook和gotify进行配置发送消息,使用webhook接口时,会提示“Webhook 构建规则解析失败”,使用后台推送消息时,会提示400错误。经过问题排查,锁定在了json模板的替换上,经过代码修改,本地测试后修复了问题。

由于在教程中的github我还没有接入体验过,所以我不确定这个问题原先是否就已经存在。

错误实现

添加一个webhook接口,提取规则和构建规则保持默认。

# 提取规则
{
  "title": "attr1",
  "description": "attr2.sub_attr",
  "content": "attr3",
  "url": "attr4"
}
# 构建规则
{
  "title": "$title",
  "description": "描述信息:$description",
  "content": "内容:$content",
  "url": "https://example.com/$title"
}

使用postman进行接口调试,当请求体包含\n是,会提示推送失败。

# 请求内容
{
  "attr1": "这是一个测试标题",
  "attr2": {
    "sub_attr": "这是描述内容"
  },
  "attr3": "## 这是内容\n\n具体的内容是**这样**的",
  "attr4": "https://example.com"
}
# 请求结果
{
  "message": "Webhook 构建规则解析失败",
  "success": false
}

@songquanpeng
Copy link
Owner

周末处理哈

@fghwett
Copy link
Author

fghwett commented Aug 29, 2023

好的 我先自己打包镜像用了

@xuzhonglin
Copy link

带有 \t 也会解析失败

@fghwett
Copy link
Author

fghwett commented Sep 25, 2023

带有 \t 也会解析失败

改完之后\t不会导致推送失败 访问链接页面的markdown是可以正常被解析的,但是查看内容的样式还有问题(前端的我没改)

@songquanpeng
Copy link
Owner

久等了,我尽量国庆期间处理完毕

@fghwett
Copy link
Author

fghwett commented Oct 12, 2023

#107 添加修改

@fghwett
Copy link
Author

fghwett commented Oct 12, 2023

#110 \n引起的问题

@uiosun
Copy link

uiosun commented Oct 24, 2023

@songquanpeng 请问,这个项目是否还在维护?

@zj1123581321

This comment was marked as resolved.

@zj1123581321
Copy link

短期看不到作者大大合并 pr 的可能性,打包了一个修复好的镜像方便各位使用
zj1123581321/message-pusher general | Docker Hub: https://hub.docker.com/repository/docker/zj1123581321/message-pusher/general

@onlyistranger
Copy link

短期看不到作者大大合并 pr 的可能性,打包了一个修复好的镜像方便各位使用 zj1123581321/message-pusher general | Docker Hub: https://hub.docker.com/repository/docker/zj1123581321/message-pusher/general短期看不到作者大大合并 pr 的可能性,打包了一个修复好的镜像方便各位使用 ZJ1123581321/消息推送器通用 |Docker Hub:https://hub.docker.com/repository/docker/zj1123581321/message-pusher/general

能否提供一个arm版的docker镜像?多谢。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants