fix(pushover): add expire and retry

Fixes #983
This commit is contained in:
Jef LeCompte
2020-12-08 14:20:15 -05:00
parent d56bcddb05
commit 0072dda90b
5 changed files with 48 additions and 27 deletions
+19 -9
View File
@@ -4,20 +4,30 @@ import Push, {PushoverMessage} from 'pushover-notifications';
import {config} from '../config';
const pushover = config.notifications.pushover;
const push = new Push({
token: pushover.token,
user: pushover.username
});
export function sendPushoverNotification(link: Link, store: Store) {
if (pushover.token && pushover.username) {
logger.debug('↗ sending pushover message');
const message: PushoverMessage = {
message: link.cartUrl ? link.cartUrl : link.url,
priority: pushover.priority,
title: Print.inStock(link, store)
};
const push = new Push({
token: pushover.token,
user: pushover.username
});
const message: PushoverMessage =
pushover.priority < 2
? {
message: link.cartUrl ? link.cartUrl : link.url,
priority: pushover.priority,
title: Print.inStock(link, store)
}
: {
expire: pushover.expire,
message: link.cartUrl ? link.cartUrl : link.url,
priority: pushover.priority,
retry: pushover.retry,
title: Print.inStock(link, store)
};
push.send(message, (error: Error) => {
if (error) {