Bark通知内容太长就报错
JoveYu opened this issue · 2 comments
JoveYu commented
Bark目前调用的是get接口,内容一长就会报错HTTP431,希望修改成调用Bark新版的post接口,不受通知内容长度影响,大概接口是这样的
function BarkNotify(text, desp, params = {}) {
return new Promise((resolve) => {
if (BARK_PUSH) {
const options = {
url: `${BARK_PUSH}`,
json: {
title: text,
body: desp,
group: `${BARK_GROUP}`,
icon: `${BARK_ICON}`,
sound: `${BARK_SOUND}`,
},
headers: {
'Content-Type': 'application/json; charset=utf-8',
},
timeout,
};
$.post(options, (err, resp, data) => {
try {
if (err) {
console.log('Bark APP发送通知调用API失败!!\n');
console.log(err);
} else {
data = JSON.parse(data);
if (data.code === 200) {
console.log('Bark APP发送通知消息成功🎉\n');
} else {
console.log(`${data.message}\n`);
}
}
} catch (e) {
$.logErr(e, resp);
} finally {
resolve();
}
});
} else {
resolve();
}
});
}
ccwav commented
好的,因为我没有ip,所以直接用了你的代码
JoveYu commented