From 73e8c2ae886d1206f5c4f623d07e62767bac0237 Mon Sep 17 00:00:00 2001 From: Garret Picchioni Date: Sat, 6 Mar 2021 22:35:34 -0800 Subject: [PATCH] feat(notifications): specify device for pushover notification --- docs/reference/notification.md | 18 ++++++++++-------- dotenv-example | 5 +++-- src/config.ts | 1 + src/notification/pushover.ts | 2 ++ 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/docs/reference/notification.md b/docs/reference/notification.md index 503d070bbc..b2350ee0c2 100644 --- a/docs/reference/notification.md +++ b/docs/reference/notification.md @@ -132,14 +132,16 @@ Generate token at [pushbullet.com/#settings/account](https://pushbullet.com/#set ## Pushover Generate token at [pushover.net/apps/build](https://pushover.net/apps/build). - -| Environment variable | Description | -|:---:|---| -| `PUSHOVER_EXPIRE` | How many seconds your notification will continue to be retried for (every `PUSHOVER_RETRY` seconds) | -| `PUSHOVER_RETRY` | How often (in seconds) the Pushover servers will send the same notification to the user | -| `PUSHOVER_PRIORITY` | Message priority | -| `PUSHOVER_TOKEN` | API token | -| `PUSHOVER_USER` | Username | +API Documentation: [pushover.net/api](https://pushover.net/api) + +| Environment variable | Description | Required +|:---:|---|---| +| `PUSHOVER_USER` | User key | true | +| `PUSHOVER_TOKEN` | Application API token | true | +| `PUSHOVER_PRIORITY` | Message priority | false | +| `PUSHOVER_DEVICE` | Devices to send notificaiton to. Blank will send to all registered devices. | false | +| `PUSHOVER_RETRY` | How often (in seconds) the Pushover servers will send the same notification to the user | false | +| `PUSHOVER_EXPIRE` | How many seconds your notification will continue to be retried for (every `PUSHOVER_RETRY` seconds) | false | ???+ note `PUSHOVER_EXPIRE` and `PUSHOVER_RETRY` are only used when `PUSHOVER_PRIORITY="2"` diff --git a/dotenv-example b/dotenv-example index fd0471462c..196a4549d6 100644 --- a/dotenv-example +++ b/dotenv-example @@ -85,11 +85,12 @@ PROXY_ADDRESS= PROXY_PROTOCOL= PROXY_PORT= PUSHBULLET= -PUSHOVER_EXPIRE= -PUSHOVER_RETRY= PUSHOVER_TOKEN= PUSHOVER_USER= PUSHOVER_PRIORITY= +PUSHOVER_DEVICE= +PUSHOVER_RETRY= +PUSHOVER_EXPIRE= RESTART_TIME= SCREENSHOT= SHOW_ONLY_BRANDS= diff --git a/src/config.ts b/src/config.ts index ed9b131ad3..a49cf7c65e 100644 --- a/src/config.ts +++ b/src/config.ts @@ -296,6 +296,7 @@ const notifications = { retry: envOrNumber(process.env.PUSHOVER_RETRY), token: envOrString(process.env.PUSHOVER_TOKEN), username: envOrString(process.env.PUSHOVER_USER), + device: envOrString(process.env.PUSHOVER_DEVICE), }, redis: { url: envOrString(process.env.REDIS_URL), diff --git a/src/notification/pushover.ts b/src/notification/pushover.ts index 467bcbfd92..431ac2e119 100644 --- a/src/notification/pushover.ts +++ b/src/notification/pushover.ts @@ -20,6 +20,7 @@ export function sendPushoverNotification(link: Link, store: Store) { message: link.cartUrl ? link.cartUrl : link.url, priority: pushover.priority, title: Print.inStock(link, store), + device: pushover.device, ...(link.screenshot && {file: `./${link.screenshot}`}), } : { @@ -28,6 +29,7 @@ export function sendPushoverNotification(link: Link, store: Store) { priority: pushover.priority, retry: pushover.retry, title: Print.inStock(link, store), + device: pushover.device, ...(link.screenshot && {file: `./${link.screenshot}`}), };