mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 06:27:38 +00:00
@@ -241,7 +241,9 @@ const notifications = {
|
||||
playSound: envOrString(process.env.PLAY_SOUND),
|
||||
pushbullet: envOrString(process.env.PUSHBULLET),
|
||||
pushover: {
|
||||
expire: envOrNumber(process.env.PUSHOVER_EXPIRE),
|
||||
priority: envOrNumber(process.env.PUSHOVER_PRIORITY),
|
||||
retry: envOrNumber(process.env.PUSHOVER_RETRY),
|
||||
token: envOrString(process.env.PUSHOVER_TOKEN),
|
||||
username: envOrString(process.env.PUSHOVER_USER)
|
||||
},
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+7
-5
@@ -37,15 +37,17 @@ declare module 'pushover-notifications' {
|
||||
}
|
||||
|
||||
export interface PushoverMessage {
|
||||
message: string;
|
||||
file?: string | {name: string; data: string};
|
||||
device?: string;
|
||||
expire?: number;
|
||||
file?: string | {name: string; data: string};
|
||||
message: string;
|
||||
priority?: number;
|
||||
retry?: number;
|
||||
sound?: Sound;
|
||||
timestamp?: number;
|
||||
title?: string;
|
||||
url?: string;
|
||||
url_title?: string;
|
||||
priority?: number;
|
||||
sound?: Sound;
|
||||
timestamp?: number;
|
||||
}
|
||||
|
||||
export class Pushover {
|
||||
|
||||
Reference in New Issue
Block a user