优化Server酱Key相关的逻辑 (#2538)

* 优化sendkey的兼容

* 对title和desp encode
This commit is contained in:
Easy
2024-10-22 21:49:07 +08:00
committed by GitHub
parent 185fd2ff91
commit ecc55883f0
3 changed files with 17 additions and 9 deletions
+5 -3
View File
@@ -152,14 +152,16 @@ export default class NotificationService {
private async serverChan() {
const { serverChanKey } = this.params;
const url = serverChanKey.startsWith('sctp')
? `https://${serverChanKey}.push.ft07.com/send`
const matchResult = serverChanKey.match(/^sctp(\d+)t/i);
const url = matchResult && matchResult[1]
? `https://${matchResult[1]}.push.ft07.com/send/${serverChanKey}.send`
: `https://sctapi.ftqq.com/${serverChanKey}.send`;
try {
const res: any = await got
.post(url, {
...this.gotOption,
body: `title=${this.title}&desp=${this.content}`,
body: `title=${encodeURIComponent(this.title)}&desp=${encodeURIComponent(this.content)}`,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
})
.json();