mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-24 23:19:39 -05:00
Don't try sending web push notifs if env vars not set
This commit is contained in:
parent
dd9fa3ec02
commit
b71b606913
|
|
@ -7,7 +7,7 @@ import { logger } from "../../../utils/logger";
|
|||
import * as NotificationRepository from "../NotificationRepository.server";
|
||||
import type { Notification } from "../notifications-types";
|
||||
import { notificationLink } from "../notifications-utils";
|
||||
import webPush from "./webPush.server";
|
||||
import webPush, { webPushEnabled } from "./webPush.server";
|
||||
|
||||
/**
|
||||
* Create notifications both in the database and send push notifications to users (if enabled).
|
||||
|
|
@ -102,6 +102,8 @@ async function sendPushNotification({
|
|||
notification: Notification;
|
||||
t: TFunction<["common"], undefined>;
|
||||
}) {
|
||||
if (!webPushEnabled) return;
|
||||
|
||||
try {
|
||||
await webPush.sendNotification(
|
||||
subscription,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import webPush from "web-push";
|
||||
import { logger } from "~/utils/logger";
|
||||
|
||||
export let webPushEnabled = false;
|
||||
|
||||
if (
|
||||
process.env.VAPID_EMAIL &&
|
||||
process.env.VITE_VAPID_PUBLIC_KEY &&
|
||||
|
|
@ -11,6 +13,7 @@ if (
|
|||
process.env.VITE_VAPID_PUBLIC_KEY,
|
||||
process.env.VAPID_PRIVATE_KEY,
|
||||
);
|
||||
webPushEnabled = true;
|
||||
} else {
|
||||
logger.info("VAPID env vars not set, push notifications will not work");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user