feat: implement pwa push notifications
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import prisma from "@/lib/prisma"
|
||||
import { revalidatePath } from "next/cache"
|
||||
import { headers } from "next/headers"
|
||||
import { sendNotification } from "@/lib/notifications"
|
||||
import { sendPlanNotification } from "@/lib/notifications"
|
||||
import { getDictionary } from "@/get-dictionary"
|
||||
|
||||
export async function updatePlan(
|
||||
@@ -34,14 +34,15 @@ export async function updatePlan(
|
||||
}
|
||||
})
|
||||
|
||||
if (data.instructions && plan.webhookUrl && plan.notifyAll) {
|
||||
if (data.instructions && plan.notifyAll) {
|
||||
const host = (await headers()).get("host")
|
||||
const protocol = host?.includes("localhost") ? "http" : "https"
|
||||
const planUrl = `${protocol}://${host}/${lang}/dashboard/${planId}`
|
||||
|
||||
await sendNotification(
|
||||
plan.webhookUrl,
|
||||
dict.notifications.instructionsUpdated.replace("{url}", planUrl)
|
||||
await sendPlanNotification(
|
||||
planId,
|
||||
dict.notifications.instructionsUpdated.replace("{url}", planUrl),
|
||||
plan.webhookUrl
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user