(text, desp)
| 202 | } |
| 203 | |
| 204 | function gotifyNotify(text, desp) { |
| 205 | return new Promise((resolve) => { |
| 206 | const { GOTIFY_URL, GOTIFY_TOKEN, GOTIFY_PRIORITY } = push_config; |
| 207 | if (GOTIFY_URL && GOTIFY_TOKEN) { |
| 208 | const options = { |
| 209 | url: `${GOTIFY_URL}/message?token=${GOTIFY_TOKEN}`, |
| 210 | body: `title=${encodeURIComponent(text)}&message=${encodeURIComponent( |
| 211 | desp, |
| 212 | )}&priority=${GOTIFY_PRIORITY}`, |
| 213 | headers: { |
| 214 | 'Content-Type': 'application/x-www-form-urlencoded', |
| 215 | }, |
| 216 | }; |
| 217 | $.post(options, (err, resp, data) => { |
| 218 | try { |
| 219 | if (err) { |
| 220 | console.log('Gotify 发送通知调用API失败😞\n', err); |
| 221 | } else { |
| 222 | if (data.id) { |
| 223 | console.log('Gotify 发送通知消息成功🎉\n'); |
| 224 | } else { |
| 225 | console.log(`Gotify 发送通知调用API失败😞 ${data.message}\n`); |
| 226 | } |
| 227 | } |
| 228 | } catch (e) { |
| 229 | $.logErr(e, resp); |
| 230 | } finally { |
| 231 | resolve(); |
| 232 | } |
| 233 | }); |
| 234 | } else { |
| 235 | resolve(); |
| 236 | } |
| 237 | }); |
| 238 | } |
| 239 | |
| 240 | function gobotNotify(text, desp) { |
| 241 | return new Promise((resolve) => { |
no test coverage detected