优化:`Telegram`发送通道仅`POST`请求时转义原始短信内容中的`<``>``&``"`字符(正则替换不影响) #210
This commit is contained in:
parent
b407e11530
commit
33cbc841b3
|
@ -32,6 +32,11 @@ class TelegramUtils private constructor() {
|
||||||
rule: Rule?,
|
rule: Rule?,
|
||||||
logId: Long?,
|
logId: Long?,
|
||||||
) {
|
) {
|
||||||
|
if (setting.method == null || setting.method == "POST") {
|
||||||
|
msgInfo.content = htmlEncode(msgInfo.content)
|
||||||
|
msgInfo.simInfo = htmlEncode(msgInfo.simInfo)
|
||||||
|
}
|
||||||
|
|
||||||
val content: String = if (rule != null) {
|
val content: String = if (rule != null) {
|
||||||
msgInfo.getContentForSend(rule.smsTemplate, rule.regexReplace)
|
msgInfo.getContentForSend(rule.smsTemplate, rule.regexReplace)
|
||||||
} else {
|
} else {
|
||||||
|
@ -52,7 +57,7 @@ class TelegramUtils private constructor() {
|
||||||
} else {
|
} else {
|
||||||
val bodyMap: MutableMap<String, Any> = mutableMapOf()
|
val bodyMap: MutableMap<String, Any> = mutableMapOf()
|
||||||
bodyMap["chat_id"] = setting.chatId
|
bodyMap["chat_id"] = setting.chatId
|
||||||
bodyMap["text"] = htmlEncode(content)
|
bodyMap["text"] = content
|
||||||
bodyMap["parse_mode"] = "HTML"
|
bodyMap["parse_mode"] = "HTML"
|
||||||
bodyMap["disable_web_page_preview"] = "true"
|
bodyMap["disable_web_page_preview"] = "true"
|
||||||
val requestMsg: String = Gson().toJson(bodyMap)
|
val requestMsg: String = Gson().toJson(bodyMap)
|
||||||
|
@ -100,7 +105,7 @@ class TelegramUtils private constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
request.keepJson(true)
|
request.keepJson(true)
|
||||||
.ignoreHttpsCert()
|
//.ignoreHttpsCert()
|
||||||
.timeOut((SettingUtils.requestTimeout * 1000).toLong()) //超时时间10s
|
.timeOut((SettingUtils.requestTimeout * 1000).toLong()) //超时时间10s
|
||||||
.cacheMode(CacheMode.NO_CACHE)
|
.cacheMode(CacheMode.NO_CACHE)
|
||||||
.retryCount(SettingUtils.requestRetryTimes) //超时重试的次数
|
.retryCount(SettingUtils.requestRetryTimes) //超时重试的次数
|
||||||
|
|
Loading…
Reference in New Issue