fix: KöPi Pushover ohne Emergency-Priority (weder Cron noch Testbutton)
This commit is contained in:
@@ -279,23 +279,22 @@ function formatOfferMessage(offers) {
|
||||
|
||||
async function sendKoepiPushover(offers) {
|
||||
const recipients = db.prepare(`
|
||||
SELECT user_key, app_token, retry, expire FROM pushover_settings
|
||||
SELECT user_key, app_token FROM pushover_settings
|
||||
WHERE user_key IS NOT NULL AND app_token IS NOT NULL
|
||||
`).all();
|
||||
const message = formatOfferMessage(offers);
|
||||
for (const r of recipients) {
|
||||
try {
|
||||
const params = {
|
||||
await fetch('https://api.pushover.net/1/messages.json', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
body: new URLSearchParams({
|
||||
token: r.app_token,
|
||||
user: r.user_key,
|
||||
title: '🍺 KöPi Angebote',
|
||||
message,
|
||||
};
|
||||
if (r.retry && r.expire) { params.priority = 2; params.retry = r.retry; params.expire = r.expire; }
|
||||
await fetch('https://api.pushover.net/1/messages.json', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
body: new URLSearchParams(params),
|
||||
priority: 0,
|
||||
}),
|
||||
});
|
||||
} catch (e) { console.error('KöPi Pushover Fehler:', e.message); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user