mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 08:47:43 +00:00
27 lines
685 B
TypeScript
27 lines
685 B
TypeScript
import {Link, Store} from '../store/model';
|
|
import {Print, logger} from '../logger';
|
|
import PushBullet from '@jef/pushbullet';
|
|
import {config} from '../config';
|
|
|
|
const pushbullet = config.notifications.pushbullet;
|
|
|
|
export function sendPushbulletNotification(link: Link, store: Store) {
|
|
if (pushbullet) {
|
|
logger.debug('↗ sending pushbullet message');
|
|
|
|
const pusher = new PushBullet(pushbullet);
|
|
|
|
pusher.note(
|
|
{},
|
|
Print.inStock(link, store),
|
|
link.cartUrl ? link.cartUrl : link.url,
|
|
(error: Error) => {
|
|
if (error) {
|
|
logger.error('✖ couldn\'t send pushbullet message', error);
|
|
} else {
|
|
logger.info('✔ pushbullet message sent');
|
|
}
|
|
});
|
|
}
|
|
}
|