Skip to content

Commit

Permalink
chore(notification): add better logging, remove debug
Browse files Browse the repository at this point in the history
Ref: #2536, #2541
  • Loading branch information
jef committed May 17, 2021
1 parent 8f2de5d commit d12639e
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/messaging/gotify.ts
Expand Up @@ -9,17 +9,24 @@ const {gotify} = config.notifications;
export function sendGotifyNotification(link: Link, store: Store) {
if (!gotify.token || !gotify.url) return;

logger.info(JSON.stringify(gotify));

(async () => {
const params = new URLSearchParams();
params.append('title', Print.inStock(link, store));
params.append('message', Print.productInStock(link));
const response = await fetch(`${gotify.url}/message?token=${gotify.token}`, {
method: 'POST',
body: params,
});
const response = await fetch(
`${gotify.url}/message?token=${gotify.token}`,
{
method: 'POST',
body: params,
}
);

const json = await response.json()

logger.info(JSON.stringify(await response.json()));
if (json.error) {
logger.error("✖ could not send gotify message", json.error);
} else {
logger.info('✔ gotify message sent');
}
})();
}

0 comments on commit d12639e

Please sign in to comment.