Add Docker support and notification URL enhancement

This commit is contained in:
2026-01-12 20:59:03 +01:00
parent 3121ef223d
commit 68d0584917
5 changed files with 79 additions and 4 deletions

View File

@@ -2,6 +2,7 @@
import prisma from "@/lib/prisma"
import { revalidatePath } from "next/cache"
import { headers } from "next/headers"
import { sendNotification } from "@/lib/notifications"
export async function createBooking(planId: string, date: Date, name: string, type: "SITTER" | "OWNER_HOME" = "SITTER") {
@@ -31,10 +32,14 @@ export async function createBooking(planId: string, date: Date, name: string, ty
})
if (plan?.webhookUrl && plan.notifyAll) {
const host = (await headers()).get("host")
const protocol = host?.includes("localhost") ? "http" : "https"
const planUrl = `${protocol}://${host}/dashboard/${planId}`
const dateStr = date.toLocaleDateString()
const message = type === "OWNER_HOME"
? `🏠 OWNER HOME: Marked for ${dateStr}.`
: `✅ NEW BOOKING: ${name} is sitting on ${dateStr}.`
? `🏠 OWNER HOME: Marked for ${dateStr}.\nPlan: ${planUrl}`
: `✅ NEW BOOKING: ${name} is sitting on ${dateStr}.\nPlan: ${planUrl}`
await sendNotification(plan.webhookUrl, message)
}
@@ -54,8 +59,12 @@ export async function deleteBooking(bookingId: number, planId: string) {
})
if (booking.plan.webhookUrl) {
const host = (await headers()).get("host")
const protocol = host?.includes("localhost") ? "http" : "https"
const planUrl = `${protocol}://${host}/dashboard/${planId}`
const dateStr = booking.date.toLocaleDateString()
await sendNotification(booking.plan.webhookUrl, `🚨 CANCELLATION: ${booking.sitterName} removed their booking for ${dateStr}.`)
await sendNotification(booking.plan.webhookUrl, `🚨 CANCELLATION: ${booking.sitterName} removed their booking for ${dateStr}.\nPlan: ${planUrl}`)
}
revalidatePath(`/dashboard/${planId}`)

View File

@@ -2,6 +2,7 @@
import prisma from "@/lib/prisma"
import { revalidatePath } from "next/cache"
import { headers } from "next/headers"
import { sendNotification } from "@/lib/notifications"
export async function updatePlan(planId: string, data: { instructions?: string; webhookUrl?: string; notifyAll?: boolean }) {
@@ -15,7 +16,10 @@ export async function updatePlan(planId: string, data: { instructions?: string;
})
if (data.instructions && plan.webhookUrl && plan.notifyAll) {
await sendNotification(plan.webhookUrl, `📝 UPDATED: Cat instructions have been modified.`)
const host = (await headers()).get("host")
const protocol = host?.includes("localhost") ? "http" : "https"
const planUrl = `${protocol}://${host}/dashboard/${planId}`
await sendNotification(plan.webhookUrl, `📝 UPDATED: Cat instructions have been modified.\nPlan: ${planUrl}`)
}
revalidatePath(`/dashboard/${planId}`)