1import { env } from '$env/dynamic/private';
2
3export const pushNotification = (_content: string) => {
4 const content = encodeURIComponent(_content);
5 try {
6 // post to phone
7 fetch(
8 `https://api.day.app/${env.BARK_DEVICE_ID}/gaze.systems/${content}?icon=https://gaze.systems/icons/gaze_site.webp`
9 );
10 // post to discord
11 fetch(env.DISCORD_NOTIF_WEBHOOK || '', {
12 method: 'POST',
13 headers: {
14 'content-type': 'application/json'
15 },
16 body: JSON.stringify({
17 content: '<@853064602904166430>',
18 embeds: [
19 {
20 id: 677465216,
21 title: _content,
22 footer: {
23 text: 'notif from gaze.systems'
24 }
25 }
26 ]
27 })
28 });
29 } catch (err) {
30 console.log(`failed to push notification: ${err}`);
31 }
32};