mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat(notifications): implement notifications for gotify
This commit is contained in:
parent
1f8a476264
commit
e25d0c0c68
@ -28,7 +28,13 @@ import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
|||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { AlertTriangle, Mail, PenBoxIcon, PlusIcon, MessageCircleMore } from "lucide-react";
|
import {
|
||||||
|
AlertTriangle,
|
||||||
|
Mail,
|
||||||
|
MessageCircleMore,
|
||||||
|
PenBoxIcon,
|
||||||
|
PlusIcon,
|
||||||
|
} from "lucide-react";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useFieldArray, useForm } from "react-hook-form";
|
import { useFieldArray, useForm } from "react-hook-form";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
@ -239,6 +245,20 @@ export const HandleNotifications = ({ notificationId }: Props) => {
|
|||||||
name: notification.name,
|
name: notification.name,
|
||||||
dockerCleanup: notification.dockerCleanup,
|
dockerCleanup: notification.dockerCleanup,
|
||||||
});
|
});
|
||||||
|
} else if (notification.notificationType === "gotify") {
|
||||||
|
form.reset({
|
||||||
|
appBuildError: notification.appBuildError,
|
||||||
|
appDeploy: notification.appDeploy,
|
||||||
|
dokployRestart: notification.dokployRestart,
|
||||||
|
databaseBackup: notification.databaseBackup,
|
||||||
|
type: notification.notificationType,
|
||||||
|
appToken: notification.gotify?.appToken,
|
||||||
|
decoration: notification.gotify?.decoration || undefined,
|
||||||
|
priority: notification.gotify?.priority,
|
||||||
|
serverUrl: notification.gotify?.serverUrl,
|
||||||
|
name: notification.name,
|
||||||
|
dockerCleanup: notification.dockerCleanup,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
form.reset();
|
form.reset();
|
||||||
|
@ -13,7 +13,7 @@ import {
|
|||||||
CardTitle,
|
CardTitle,
|
||||||
} from "@/components/ui/card";
|
} from "@/components/ui/card";
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
import { Bell, Loader2, Mail, Trash2 } from "lucide-react";
|
import { Bell, Loader2, Mail, MessageCircleMore, Trash2 } from "lucide-react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { HandleNotifications } from "./handle-notifications";
|
import { HandleNotifications } from "./handle-notifications";
|
||||||
|
|
||||||
@ -83,6 +83,11 @@ export const ShowNotifications = () => {
|
|||||||
<Mail className="size-6 text-muted-foreground" />
|
<Mail className="size-6 text-muted-foreground" />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{notification.notificationType === "gotify" && (
|
||||||
|
<div className="flex items-center justify-center rounded-lg ">
|
||||||
|
<MessageCircleMore className="size-6 text-muted-foreground" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{notification.name}
|
{notification.name}
|
||||||
</span>
|
</span>
|
||||||
|
@ -1,861 +0,0 @@
|
|||||||
import {
|
|
||||||
DiscordIcon,
|
|
||||||
SlackIcon,
|
|
||||||
TelegramIcon,
|
|
||||||
} from "@/components/icons/notification-icons";
|
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import {
|
|
||||||
Dialog,
|
|
||||||
DialogContent,
|
|
||||||
DialogDescription,
|
|
||||||
DialogFooter,
|
|
||||||
DialogHeader,
|
|
||||||
DialogTitle,
|
|
||||||
DialogTrigger,
|
|
||||||
} from "@/components/ui/dialog";
|
|
||||||
import {
|
|
||||||
Form,
|
|
||||||
FormControl,
|
|
||||||
FormDescription,
|
|
||||||
FormField,
|
|
||||||
FormItem,
|
|
||||||
FormLabel,
|
|
||||||
FormMessage,
|
|
||||||
} from "@/components/ui/form";
|
|
||||||
import { Input } from "@/components/ui/input";
|
|
||||||
import { Switch } from "@/components/ui/switch";
|
|
||||||
import { api } from "@/utils/api";
|
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
|
||||||
import { Mail, Pen } from "lucide-react";
|
|
||||||
import { useEffect, useState } from "react";
|
|
||||||
import { useFieldArray, useForm } from "react-hook-form";
|
|
||||||
import { toast } from "sonner";
|
|
||||||
import {
|
|
||||||
type NotificationSchema,
|
|
||||||
notificationSchema,
|
|
||||||
} from "./add-notification";
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
notificationId: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const UpdateNotification = ({ notificationId }: Props) => {
|
|
||||||
const utils = api.useUtils();
|
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
|
||||||
const { data, refetch } = api.notification.one.useQuery(
|
|
||||||
{
|
|
||||||
notificationId,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
enabled: !!notificationId,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
const { mutateAsync: testSlackConnection, isLoading: isLoadingSlack } =
|
|
||||||
api.notification.testSlackConnection.useMutation();
|
|
||||||
|
|
||||||
const { mutateAsync: testTelegramConnection, isLoading: isLoadingTelegram } =
|
|
||||||
api.notification.testTelegramConnection.useMutation();
|
|
||||||
const { mutateAsync: testDiscordConnection, isLoading: isLoadingDiscord } =
|
|
||||||
api.notification.testDiscordConnection.useMutation();
|
|
||||||
const { mutateAsync: testEmailConnection, isLoading: isLoadingEmail } =
|
|
||||||
api.notification.testEmailConnection.useMutation();
|
|
||||||
const { mutateAsync: testGotifyConnection, isLoading: isLoadingGotify } =
|
|
||||||
api.notification.testGotifyConnection.useMutation();
|
|
||||||
const slackMutation = api.notification.updateSlack.useMutation();
|
|
||||||
const telegramMutation = api.notification.updateTelegram.useMutation();
|
|
||||||
const discordMutation = api.notification.updateDiscord.useMutation();
|
|
||||||
const emailMutation = api.notification.updateEmail.useMutation();
|
|
||||||
const gotifyMutation = api.notification.updateGotify.useMutation();
|
|
||||||
const { data: isCloud } = api.settings.isCloud.useQuery();
|
|
||||||
const form = useForm<NotificationSchema>({
|
|
||||||
defaultValues: {
|
|
||||||
type: "slack",
|
|
||||||
webhookUrl: "",
|
|
||||||
channel: "",
|
|
||||||
},
|
|
||||||
resolver: zodResolver(notificationSchema),
|
|
||||||
});
|
|
||||||
const type = form.watch("type");
|
|
||||||
|
|
||||||
const { fields, append, remove } = useFieldArray({
|
|
||||||
control: form.control,
|
|
||||||
name: "toAddresses" as never,
|
|
||||||
});
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (data) {
|
|
||||||
if (data.notificationType === "slack") {
|
|
||||||
form.reset({
|
|
||||||
appBuildError: data.appBuildError,
|
|
||||||
appDeploy: data.appDeploy,
|
|
||||||
dokployRestart: data.dokployRestart,
|
|
||||||
databaseBackup: data.databaseBackup,
|
|
||||||
dockerCleanup: data.dockerCleanup,
|
|
||||||
webhookUrl: data.slack?.webhookUrl,
|
|
||||||
channel: data.slack?.channel || "",
|
|
||||||
name: data.name,
|
|
||||||
type: data.notificationType,
|
|
||||||
});
|
|
||||||
} else if (data.notificationType === "telegram") {
|
|
||||||
form.reset({
|
|
||||||
appBuildError: data.appBuildError,
|
|
||||||
appDeploy: data.appDeploy,
|
|
||||||
dokployRestart: data.dokployRestart,
|
|
||||||
databaseBackup: data.databaseBackup,
|
|
||||||
botToken: data.telegram?.botToken,
|
|
||||||
chatId: data.telegram?.chatId,
|
|
||||||
type: data.notificationType,
|
|
||||||
name: data.name,
|
|
||||||
dockerCleanup: data.dockerCleanup,
|
|
||||||
});
|
|
||||||
} else if (data.notificationType === "discord") {
|
|
||||||
form.reset({
|
|
||||||
appBuildError: data.appBuildError,
|
|
||||||
appDeploy: data.appDeploy,
|
|
||||||
dokployRestart: data.dokployRestart,
|
|
||||||
databaseBackup: data.databaseBackup,
|
|
||||||
type: data.notificationType,
|
|
||||||
webhookUrl: data.discord?.webhookUrl,
|
|
||||||
decoration: data.discord?.decoration || undefined,
|
|
||||||
name: data.name,
|
|
||||||
dockerCleanup: data.dockerCleanup,
|
|
||||||
});
|
|
||||||
} else if (data.notificationType === "email") {
|
|
||||||
form.reset({
|
|
||||||
appBuildError: data.appBuildError,
|
|
||||||
appDeploy: data.appDeploy,
|
|
||||||
dokployRestart: data.dokployRestart,
|
|
||||||
databaseBackup: data.databaseBackup,
|
|
||||||
type: data.notificationType,
|
|
||||||
smtpServer: data.email?.smtpServer,
|
|
||||||
smtpPort: data.email?.smtpPort,
|
|
||||||
username: data.email?.username,
|
|
||||||
password: data.email?.password,
|
|
||||||
toAddresses: data.email?.toAddresses,
|
|
||||||
fromAddress: data.email?.fromAddress,
|
|
||||||
name: data.name,
|
|
||||||
dockerCleanup: data.dockerCleanup,
|
|
||||||
});
|
|
||||||
} else if (data.notificationType === "gotify") {
|
|
||||||
form.reset({
|
|
||||||
appBuildError: data.appBuildError,
|
|
||||||
appDeploy: data.appDeploy,
|
|
||||||
dokployRestart: data.dokployRestart,
|
|
||||||
databaseBackup: data.databaseBackup,
|
|
||||||
type: data.notificationType,
|
|
||||||
serverUrl: data.gotify?.serverUrl,
|
|
||||||
appToken: data.gotify?.appToken,
|
|
||||||
priority: data.gotify?.priority || 5,
|
|
||||||
decoration: data.gotify?.decoration || undefined,
|
|
||||||
name: data.name,
|
|
||||||
dockerCleanup: data.dockerCleanup,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [form, form.reset, data]);
|
|
||||||
|
|
||||||
const onSubmit = async (formData: NotificationSchema) => {
|
|
||||||
const {
|
|
||||||
appBuildError,
|
|
||||||
appDeploy,
|
|
||||||
dokployRestart,
|
|
||||||
databaseBackup,
|
|
||||||
dockerCleanup,
|
|
||||||
} = formData;
|
|
||||||
let promise: Promise<unknown> | null = null;
|
|
||||||
if (formData?.type === "slack" && data?.slackId) {
|
|
||||||
promise = slackMutation.mutateAsync({
|
|
||||||
appBuildError: appBuildError,
|
|
||||||
appDeploy: appDeploy,
|
|
||||||
dokployRestart: dokployRestart,
|
|
||||||
databaseBackup: databaseBackup,
|
|
||||||
webhookUrl: formData.webhookUrl,
|
|
||||||
channel: formData.channel,
|
|
||||||
name: formData.name,
|
|
||||||
notificationId: notificationId,
|
|
||||||
slackId: data?.slackId,
|
|
||||||
dockerCleanup: dockerCleanup,
|
|
||||||
});
|
|
||||||
} else if (formData.type === "telegram" && data?.telegramId) {
|
|
||||||
promise = telegramMutation.mutateAsync({
|
|
||||||
appBuildError: appBuildError,
|
|
||||||
appDeploy: appDeploy,
|
|
||||||
dokployRestart: dokployRestart,
|
|
||||||
databaseBackup: databaseBackup,
|
|
||||||
botToken: formData.botToken,
|
|
||||||
chatId: formData.chatId,
|
|
||||||
name: formData.name,
|
|
||||||
notificationId: notificationId,
|
|
||||||
telegramId: data?.telegramId,
|
|
||||||
dockerCleanup: dockerCleanup,
|
|
||||||
});
|
|
||||||
} else if (formData.type === "discord" && data?.discordId) {
|
|
||||||
promise = discordMutation.mutateAsync({
|
|
||||||
appBuildError: appBuildError,
|
|
||||||
appDeploy: appDeploy,
|
|
||||||
dokployRestart: dokployRestart,
|
|
||||||
databaseBackup: databaseBackup,
|
|
||||||
webhookUrl: formData.webhookUrl,
|
|
||||||
decoration: formData.decoration,
|
|
||||||
name: formData.name,
|
|
||||||
notificationId: notificationId,
|
|
||||||
discordId: data?.discordId,
|
|
||||||
dockerCleanup: dockerCleanup,
|
|
||||||
});
|
|
||||||
} else if (formData.type === "email" && data?.emailId) {
|
|
||||||
promise = emailMutation.mutateAsync({
|
|
||||||
appBuildError: appBuildError,
|
|
||||||
appDeploy: appDeploy,
|
|
||||||
dokployRestart: dokployRestart,
|
|
||||||
databaseBackup: databaseBackup,
|
|
||||||
smtpServer: formData.smtpServer,
|
|
||||||
smtpPort: formData.smtpPort,
|
|
||||||
username: formData.username,
|
|
||||||
password: formData.password,
|
|
||||||
fromAddress: formData.fromAddress,
|
|
||||||
toAddresses: formData.toAddresses,
|
|
||||||
name: formData.name,
|
|
||||||
notificationId: notificationId,
|
|
||||||
emailId: data?.emailId,
|
|
||||||
dockerCleanup: dockerCleanup,
|
|
||||||
});
|
|
||||||
} else if (formData.type === "gotify" && data?.gotifyId) {
|
|
||||||
promise = gotifyMutation.mutateAsync({
|
|
||||||
appBuildError: appBuildError,
|
|
||||||
appDeploy: appDeploy,
|
|
||||||
dokployRestart: dokployRestart,
|
|
||||||
databaseBackup: databaseBackup,
|
|
||||||
serverUrl: formData.serverUrl,
|
|
||||||
appToken: formData.appToken,
|
|
||||||
priority: formData.priority,
|
|
||||||
decoration: formData.decoration,
|
|
||||||
name: formData.name,
|
|
||||||
notificationId: notificationId,
|
|
||||||
gotifyId: data?.gotifyId,
|
|
||||||
dockerCleanup: dockerCleanup,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (promise) {
|
|
||||||
await promise
|
|
||||||
.then(async () => {
|
|
||||||
toast.success("Notification Updated");
|
|
||||||
await utils.notification.all.invalidate();
|
|
||||||
refetch();
|
|
||||||
setIsOpen(false);
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
toast.error("Error updating a notification");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<Dialog open={isOpen} onOpenChange={setIsOpen}>
|
|
||||||
<DialogTrigger className="" asChild>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="h-9 w-9 dark:hover:bg-zinc-900/80 hover:bg-gray-200/80"
|
|
||||||
>
|
|
||||||
<Pen className="size-4 text-muted-foreground" />
|
|
||||||
</Button>
|
|
||||||
</DialogTrigger>
|
|
||||||
<DialogContent className="max-h-screen overflow-y-auto sm:max-w-2xl">
|
|
||||||
<DialogHeader>
|
|
||||||
<DialogTitle>Update Notification</DialogTitle>
|
|
||||||
<DialogDescription>
|
|
||||||
Update the current notification config
|
|
||||||
</DialogDescription>
|
|
||||||
</DialogHeader>
|
|
||||||
<Form {...form}>
|
|
||||||
<form
|
|
||||||
id="hook-form"
|
|
||||||
onSubmit={form.handleSubmit(onSubmit)}
|
|
||||||
className="grid w-full gap-8 "
|
|
||||||
>
|
|
||||||
<div className="flex flex-col gap-4 ">
|
|
||||||
<div className="flex flex-row gap-2 w-full items-center">
|
|
||||||
<div className="flex flex-row gap-2 items-center w-full ">
|
|
||||||
<FormLabel className="text-lg font-semibold leading-none tracking-tight flex">
|
|
||||||
{data?.notificationType === "slack"
|
|
||||||
? "Slack"
|
|
||||||
: data?.notificationType === "telegram"
|
|
||||||
? "Telegram"
|
|
||||||
: data?.notificationType === "discord"
|
|
||||||
? "Discord"
|
|
||||||
: data?.notificationType === "email"
|
|
||||||
? "Email"
|
|
||||||
: "Gotify"}
|
|
||||||
</FormLabel>
|
|
||||||
</div>
|
|
||||||
{data?.notificationType === "slack" && (
|
|
||||||
<SlackIcon className="text-muted-foreground size-6 flex-shrink-0" />
|
|
||||||
)}
|
|
||||||
{data?.notificationType === "telegram" && (
|
|
||||||
<TelegramIcon className="text-muted-foreground size-8 flex-shrink-0" />
|
|
||||||
)}
|
|
||||||
{data?.notificationType === "discord" && (
|
|
||||||
<DiscordIcon className="text-muted-foreground size-7 flex-shrink-0" />
|
|
||||||
)}
|
|
||||||
{data?.notificationType === "email" && (
|
|
||||||
<Mail
|
|
||||||
size={29}
|
|
||||||
className="text-muted-foreground size-6 flex-shrink-0"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{data?.notificationType === "gotify" && (
|
|
||||||
<Mail
|
|
||||||
size={29}
|
|
||||||
className="text-muted-foreground size-6 flex-shrink-0"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex flex-col gap-2">
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="name"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>Name</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input placeholder="Name" {...field} />
|
|
||||||
</FormControl>
|
|
||||||
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{type === "slack" && (
|
|
||||||
<>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="webhookUrl"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>Webhook URL</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
placeholder="https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="channel"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>Channel</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input placeholder="Channel" {...field} />
|
|
||||||
</FormControl>
|
|
||||||
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{type === "telegram" && (
|
|
||||||
<>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="botToken"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>Bot Token</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
placeholder="6660491268:AAFMGmajZOVewpMNZCgJr5H7cpXpoZPgvXw"
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="chatId"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>Chat ID</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input placeholder="431231869" {...field} />
|
|
||||||
</FormControl>
|
|
||||||
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{type === "discord" && (
|
|
||||||
<>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="webhookUrl"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>Webhook URL</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
placeholder="https://discord.com/api/webhooks/123456789/ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="decoration"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="flex items-center justify-between rounded-lg border p-3 shadow-sm">
|
|
||||||
<div className="space-y-0.5">
|
|
||||||
<FormLabel>Decoration</FormLabel>
|
|
||||||
<FormDescription>
|
|
||||||
Decorate the notification with emojis.
|
|
||||||
</FormDescription>
|
|
||||||
</div>
|
|
||||||
<FormControl>
|
|
||||||
<Switch
|
|
||||||
checked={field.value}
|
|
||||||
onCheckedChange={field.onChange}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{type === "email" && (
|
|
||||||
<>
|
|
||||||
<div className="flex md:flex-row flex-col gap-2 w-full">
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="smtpServer"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="w-full">
|
|
||||||
<FormLabel>SMTP Server</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input placeholder="smtp.gmail.com" {...field} />
|
|
||||||
</FormControl>
|
|
||||||
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="smtpPort"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="w-full">
|
|
||||||
<FormLabel>SMTP Port</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
placeholder="587"
|
|
||||||
{...field}
|
|
||||||
onChange={(e) => {
|
|
||||||
const value = e.target.value;
|
|
||||||
if (value) {
|
|
||||||
const port = Number.parseInt(value);
|
|
||||||
if (port > 0 && port < 65536) {
|
|
||||||
field.onChange(port);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex md:flex-row flex-col gap-2 w-full">
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="username"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="w-full">
|
|
||||||
<FormLabel>Username</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input placeholder="username" {...field} />
|
|
||||||
</FormControl>
|
|
||||||
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="password"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="w-full">
|
|
||||||
<FormLabel>Password</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
type="password"
|
|
||||||
placeholder="******************"
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="fromAddress"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>From Address</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input placeholder="from@example.com" {...field} />
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<div className="flex flex-col gap-2 pt-2">
|
|
||||||
<FormLabel>To Addresses</FormLabel>
|
|
||||||
|
|
||||||
{fields.map((field, index) => (
|
|
||||||
<div
|
|
||||||
key={field.id}
|
|
||||||
className="flex flex-row gap-2 w-full"
|
|
||||||
>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name={`toAddresses.${index}`}
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="w-full">
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
placeholder="email@example.com"
|
|
||||||
className="w-full"
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
variant="outline"
|
|
||||||
type="button"
|
|
||||||
onClick={() => {
|
|
||||||
remove(index);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Remove
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
{type === "email" &&
|
|
||||||
"toAddresses" in form.formState.errors && (
|
|
||||||
<div className="text-sm font-medium text-destructive">
|
|
||||||
{form.formState?.errors?.toAddresses?.root?.message}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
variant="outline"
|
|
||||||
type="button"
|
|
||||||
onClick={() => {
|
|
||||||
append("");
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Add
|
|
||||||
</Button>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{type === "gotify" && (
|
|
||||||
<>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="serverUrl"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>Server URL</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
placeholder="https://gotify.example.com"
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="appToken"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>App Token</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input placeholder="AzxF2.d9KzP..." {...field} />
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="priority"
|
|
||||||
defaultValue={5}
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="w-full">
|
|
||||||
<FormLabel>Priority</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
placeholder="5"
|
|
||||||
{...field}
|
|
||||||
onChange={(e) => {
|
|
||||||
const value = e.target.value;
|
|
||||||
if (value) {
|
|
||||||
const priority = Number.parseInt(value);
|
|
||||||
if (priority > 0 && priority < 10) {
|
|
||||||
field.onChange(priority);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
type="number"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="decoration"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="flex items-center justify-between rounded-lg border p-3 shadow-sm">
|
|
||||||
<div className="space-y-0.5">
|
|
||||||
<FormLabel>Decoration</FormLabel>
|
|
||||||
<FormDescription>
|
|
||||||
Decorate the notification with emojis.
|
|
||||||
</FormDescription>
|
|
||||||
</div>
|
|
||||||
<FormControl>
|
|
||||||
<Switch
|
|
||||||
checked={field.value}
|
|
||||||
onCheckedChange={field.onChange}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="flex flex-col gap-4">
|
|
||||||
<FormLabel className="text-lg font-semibold leading-none tracking-tight">
|
|
||||||
Select the actions.
|
|
||||||
</FormLabel>
|
|
||||||
|
|
||||||
<div className="grid md:grid-cols-2 gap-4">
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
defaultValue={form.control._defaultValues.appDeploy}
|
|
||||||
name="appDeploy"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className=" flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm gap-2">
|
|
||||||
<div className="space-y-0.5">
|
|
||||||
<FormLabel>App Deploy</FormLabel>
|
|
||||||
<FormDescription>
|
|
||||||
Trigger the action when a app is deployed.
|
|
||||||
</FormDescription>
|
|
||||||
</div>
|
|
||||||
<FormControl>
|
|
||||||
<Switch
|
|
||||||
checked={field.value}
|
|
||||||
onCheckedChange={field.onChange}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
defaultValue={form.control._defaultValues.appBuildError}
|
|
||||||
name="appBuildError"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className=" flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm gap-2">
|
|
||||||
<div className="space-y-0.5">
|
|
||||||
<FormLabel>App Builder Error</FormLabel>
|
|
||||||
<FormDescription>
|
|
||||||
Trigger the action when the build fails.
|
|
||||||
</FormDescription>
|
|
||||||
</div>
|
|
||||||
<FormControl>
|
|
||||||
<Switch
|
|
||||||
checked={field.value}
|
|
||||||
onCheckedChange={field.onChange}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="databaseBackup"
|
|
||||||
defaultValue={form.control._defaultValues.databaseBackup}
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className=" flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm gap-2">
|
|
||||||
<div className="space-y-0.5">
|
|
||||||
<FormLabel>Database Backup</FormLabel>
|
|
||||||
<FormDescription>
|
|
||||||
Trigger the action when a database backup is created.
|
|
||||||
</FormDescription>
|
|
||||||
</div>
|
|
||||||
<FormControl>
|
|
||||||
<Switch
|
|
||||||
checked={field.value}
|
|
||||||
onCheckedChange={field.onChange}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="dockerCleanup"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className=" flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm gap-2">
|
|
||||||
<div className="space-y-0.5">
|
|
||||||
<FormLabel>Docker Cleanup</FormLabel>
|
|
||||||
<FormDescription>
|
|
||||||
Trigger the action when the docker cleanup is
|
|
||||||
performed.
|
|
||||||
</FormDescription>
|
|
||||||
</div>
|
|
||||||
<FormControl>
|
|
||||||
<Switch
|
|
||||||
checked={field.value}
|
|
||||||
onCheckedChange={field.onChange}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
{!isCloud && (
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
defaultValue={form.control._defaultValues.dokployRestart}
|
|
||||||
name="dokployRestart"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className=" flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm gap-2">
|
|
||||||
<div className="space-y-0.5">
|
|
||||||
<FormLabel>Dokploy Restart</FormLabel>
|
|
||||||
<FormDescription>
|
|
||||||
Trigger the action when a dokploy is restarted.
|
|
||||||
</FormDescription>
|
|
||||||
</div>
|
|
||||||
<FormControl>
|
|
||||||
<Switch
|
|
||||||
checked={field.value}
|
|
||||||
onCheckedChange={field.onChange}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<DialogFooter className="flex flex-row gap-2 !justify-between w-full">
|
|
||||||
<Button
|
|
||||||
isLoading={
|
|
||||||
isLoadingSlack ||
|
|
||||||
isLoadingTelegram ||
|
|
||||||
isLoadingDiscord ||
|
|
||||||
isLoadingEmail ||
|
|
||||||
isLoadingGotify
|
|
||||||
}
|
|
||||||
variant="secondary"
|
|
||||||
onClick={async () => {
|
|
||||||
try {
|
|
||||||
if (type === "slack") {
|
|
||||||
await testSlackConnection({
|
|
||||||
webhookUrl: form.getValues("webhookUrl"),
|
|
||||||
channel: form.getValues("channel"),
|
|
||||||
});
|
|
||||||
} else if (type === "telegram") {
|
|
||||||
await testTelegramConnection({
|
|
||||||
botToken: form.getValues("botToken"),
|
|
||||||
chatId: form.getValues("chatId"),
|
|
||||||
});
|
|
||||||
} else if (type === "discord") {
|
|
||||||
await testDiscordConnection({
|
|
||||||
webhookUrl: form.getValues("webhookUrl"),
|
|
||||||
decoration: form.getValues("decoration"),
|
|
||||||
});
|
|
||||||
} else if (type === "email") {
|
|
||||||
await testEmailConnection({
|
|
||||||
smtpServer: form.getValues("smtpServer"),
|
|
||||||
smtpPort: form.getValues("smtpPort"),
|
|
||||||
username: form.getValues("username"),
|
|
||||||
password: form.getValues("password"),
|
|
||||||
toAddresses: form.getValues("toAddresses"),
|
|
||||||
fromAddress: form.getValues("fromAddress"),
|
|
||||||
});
|
|
||||||
} else if (type === "gotify") {
|
|
||||||
await testGotifyConnection({
|
|
||||||
priority: form.getValues("priority"),
|
|
||||||
serverUrl: form.getValues("serverUrl"),
|
|
||||||
appToken: form.getValues("appToken"),
|
|
||||||
decoration: form.getValues("decoration"),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
toast.success("Connection Success");
|
|
||||||
} catch (err) {
|
|
||||||
toast.error("Error testing the provider");
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Test Notification
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
isLoading={form.formState.isSubmitting}
|
|
||||||
form="hook-form"
|
|
||||||
type="submit"
|
|
||||||
>
|
|
||||||
Update
|
|
||||||
</Button>
|
|
||||||
</DialogFooter>
|
|
||||||
</Form>
|
|
||||||
</DialogContent>
|
|
||||||
</Dialog>
|
|
||||||
);
|
|
||||||
};
|
|
15
apps/dokploy/drizzle/0056_majestic_skaar.sql
Normal file
15
apps/dokploy/drizzle/0056_majestic_skaar.sql
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
ALTER TYPE "notificationType" ADD VALUE 'gotify';--> statement-breakpoint
|
||||||
|
CREATE TABLE IF NOT EXISTS "gotify" (
|
||||||
|
"gotifyId" text PRIMARY KEY NOT NULL,
|
||||||
|
"serverUrl" text NOT NULL,
|
||||||
|
"appToken" text NOT NULL,
|
||||||
|
"priority" integer DEFAULT 5 NOT NULL,
|
||||||
|
"decoration" boolean
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "notification" ADD COLUMN "gotifyId" text;--> statement-breakpoint
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE "notification" ADD CONSTRAINT "notification_gotifyId_gotify_gotifyId_fk" FOREIGN KEY ("gotifyId") REFERENCES "public"."gotify"("gotifyId") ON DELETE cascade ON UPDATE no action;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN null;
|
||||||
|
END $$;
|
4314
apps/dokploy/drizzle/meta/0056_snapshot.json
Normal file
4314
apps/dokploy/drizzle/meta/0056_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -393,6 +393,13 @@
|
|||||||
"when": 1736669623831,
|
"when": 1736669623831,
|
||||||
"tag": "0055_next_serpent_society",
|
"tag": "0055_next_serpent_society",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 56,
|
||||||
|
"version": "6",
|
||||||
|
"when": 1736789918294,
|
||||||
|
"tag": "0056_majestic_skaar",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -6,6 +6,7 @@ import { and, eq } from "drizzle-orm";
|
|||||||
import {
|
import {
|
||||||
sendDiscordNotification,
|
sendDiscordNotification,
|
||||||
sendEmailNotification,
|
sendEmailNotification,
|
||||||
|
sendGotifyNotification,
|
||||||
sendSlackNotification,
|
sendSlackNotification,
|
||||||
sendTelegramNotification,
|
sendTelegramNotification,
|
||||||
} from "./utils";
|
} from "./utils";
|
||||||
@ -39,11 +40,12 @@ export const sendBuildErrorNotifications = async ({
|
|||||||
discord: true,
|
discord: true,
|
||||||
telegram: true,
|
telegram: true,
|
||||||
slack: true,
|
slack: true,
|
||||||
|
gotify: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const notification of notificationList) {
|
for (const notification of notificationList) {
|
||||||
const { email, discord, telegram, slack } = notification;
|
const { email, discord, telegram, slack, gotify } = notification;
|
||||||
if (email) {
|
if (email) {
|
||||||
const template = await renderAsync(
|
const template = await renderAsync(
|
||||||
BuildFailedEmail({
|
BuildFailedEmail({
|
||||||
@ -112,6 +114,21 @@ export const sendBuildErrorNotifications = async ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gotify) {
|
||||||
|
const decorate = (decoration: string, text: string) =>
|
||||||
|
`${gotify.decoration ? decoration : ""} ${text}`.trim();
|
||||||
|
await sendGotifyNotification(
|
||||||
|
gotify,
|
||||||
|
decorate("⚠️", "Build Failed"),
|
||||||
|
`${decorate("🛠️", `Project: ${projectName}`)}
|
||||||
|
${decorate("⚙️", `Application: ${applicationName}`)}
|
||||||
|
${decorate("❔", `Type: ${applicationType}`)}
|
||||||
|
${decorate("🕒", `Date: ${date.toLocaleString()}`)}
|
||||||
|
${decorate("⚠️", `Error:\n${errorMessage}`)}
|
||||||
|
${decorate("🔗", `Build details:\n${buildLink}`)}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (telegram) {
|
if (telegram) {
|
||||||
await sendTelegramNotification(
|
await sendTelegramNotification(
|
||||||
telegram,
|
telegram,
|
||||||
|
@ -6,6 +6,7 @@ import { and, eq } from "drizzle-orm";
|
|||||||
import {
|
import {
|
||||||
sendDiscordNotification,
|
sendDiscordNotification,
|
||||||
sendEmailNotification,
|
sendEmailNotification,
|
||||||
|
sendGotifyNotification,
|
||||||
sendSlackNotification,
|
sendSlackNotification,
|
||||||
sendTelegramNotification,
|
sendTelegramNotification,
|
||||||
} from "./utils";
|
} from "./utils";
|
||||||
@ -37,11 +38,12 @@ export const sendBuildSuccessNotifications = async ({
|
|||||||
discord: true,
|
discord: true,
|
||||||
telegram: true,
|
telegram: true,
|
||||||
slack: true,
|
slack: true,
|
||||||
|
gotify: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const notification of notificationList) {
|
for (const notification of notificationList) {
|
||||||
const { email, discord, telegram, slack } = notification;
|
const { email, discord, telegram, slack, gotify } = notification;
|
||||||
|
|
||||||
if (email) {
|
if (email) {
|
||||||
const template = await renderAsync(
|
const template = await renderAsync(
|
||||||
@ -106,6 +108,20 @@ export const sendBuildSuccessNotifications = async ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gotify) {
|
||||||
|
const decorate = (decoration: string, text: string) =>
|
||||||
|
`${gotify.decoration ? decoration : ""} ${text}`.trim();
|
||||||
|
await sendGotifyNotification(
|
||||||
|
gotify,
|
||||||
|
decorate("✅", "Build Success"),
|
||||||
|
`${decorate("🛠️", `Project: ${projectName}`)}
|
||||||
|
${decorate("⚙️", `Application: ${applicationName}`)}
|
||||||
|
${decorate("❔", `Type: ${applicationType}`)}
|
||||||
|
${decorate("🕒", `Date: ${date.toLocaleString()}`)}
|
||||||
|
${decorate("🔗", `Build details:\n${buildLink}`)}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (telegram) {
|
if (telegram) {
|
||||||
await sendTelegramNotification(
|
await sendTelegramNotification(
|
||||||
telegram,
|
telegram,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { error } from "node:console";
|
||||||
import { db } from "@dokploy/server/db";
|
import { db } from "@dokploy/server/db";
|
||||||
import { notifications } from "@dokploy/server/db/schema";
|
import { notifications } from "@dokploy/server/db/schema";
|
||||||
import DatabaseBackupEmail from "@dokploy/server/emails/emails/database-backup";
|
import DatabaseBackupEmail from "@dokploy/server/emails/emails/database-backup";
|
||||||
@ -6,6 +7,7 @@ import { and, eq } from "drizzle-orm";
|
|||||||
import {
|
import {
|
||||||
sendDiscordNotification,
|
sendDiscordNotification,
|
||||||
sendEmailNotification,
|
sendEmailNotification,
|
||||||
|
sendGotifyNotification,
|
||||||
sendSlackNotification,
|
sendSlackNotification,
|
||||||
sendTelegramNotification,
|
sendTelegramNotification,
|
||||||
} from "./utils";
|
} from "./utils";
|
||||||
@ -37,11 +39,12 @@ export const sendDatabaseBackupNotifications = async ({
|
|||||||
discord: true,
|
discord: true,
|
||||||
telegram: true,
|
telegram: true,
|
||||||
slack: true,
|
slack: true,
|
||||||
|
gotify: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const notification of notificationList) {
|
for (const notification of notificationList) {
|
||||||
const { email, discord, telegram, slack } = notification;
|
const { email, discord, telegram, slack, gotify } = notification;
|
||||||
|
|
||||||
if (email) {
|
if (email) {
|
||||||
const template = await renderAsync(
|
const template = await renderAsync(
|
||||||
@ -120,6 +123,24 @@ export const sendDatabaseBackupNotifications = async ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gotify) {
|
||||||
|
const decorate = (decoration: string, text: string) =>
|
||||||
|
`${gotify.decoration ? decoration : ""} ${text}`.trim();
|
||||||
|
|
||||||
|
await sendGotifyNotification(
|
||||||
|
gotify,
|
||||||
|
decorate(
|
||||||
|
type === "success" ? "✅" : "❌",
|
||||||
|
`Database Backup ${type === "success" ? "Successful" : "Failed"}`,
|
||||||
|
),
|
||||||
|
`${decorate("🛠️", `Project: ${projectName}`)}
|
||||||
|
${decorate("⚙️", `Application: ${applicationName}`)}
|
||||||
|
${decorate("❔", `Type: ${databaseType}`)}
|
||||||
|
${decorate("🕒", `Date: ${date.toLocaleString()}`)}
|
||||||
|
${type === "error" && errorMessage ? decorate("❌", `Error:\n${errorMessage}`) : ""}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (telegram) {
|
if (telegram) {
|
||||||
const statusEmoji = type === "success" ? "✅" : "❌";
|
const statusEmoji = type === "success" ? "✅" : "❌";
|
||||||
const messageText = `
|
const messageText = `
|
||||||
|
@ -6,6 +6,7 @@ import { and, eq } from "drizzle-orm";
|
|||||||
import {
|
import {
|
||||||
sendDiscordNotification,
|
sendDiscordNotification,
|
||||||
sendEmailNotification,
|
sendEmailNotification,
|
||||||
|
sendGotifyNotification,
|
||||||
sendSlackNotification,
|
sendSlackNotification,
|
||||||
sendTelegramNotification,
|
sendTelegramNotification,
|
||||||
} from "./utils";
|
} from "./utils";
|
||||||
@ -26,11 +27,12 @@ export const sendDockerCleanupNotifications = async (
|
|||||||
discord: true,
|
discord: true,
|
||||||
telegram: true,
|
telegram: true,
|
||||||
slack: true,
|
slack: true,
|
||||||
|
gotify: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const notification of notificationList) {
|
for (const notification of notificationList) {
|
||||||
const { email, discord, telegram, slack } = notification;
|
const { email, discord, telegram, slack, gotify } = notification;
|
||||||
|
|
||||||
if (email) {
|
if (email) {
|
||||||
const template = await renderAsync(
|
const template = await renderAsync(
|
||||||
@ -79,6 +81,17 @@ export const sendDockerCleanupNotifications = async (
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gotify) {
|
||||||
|
const decorate = (decoration: string, text: string) =>
|
||||||
|
`${gotify.decoration ? decoration : ""} ${text}`.trim();
|
||||||
|
await sendGotifyNotification(
|
||||||
|
gotify,
|
||||||
|
decorate("✅", "Docker Cleanup"),
|
||||||
|
`${decorate("🕒", `Date: ${date.toLocaleString()}`)}
|
||||||
|
${decorate("📜", `Message:\n${message}`)}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (telegram) {
|
if (telegram) {
|
||||||
await sendTelegramNotification(
|
await sendTelegramNotification(
|
||||||
telegram,
|
telegram,
|
||||||
|
@ -6,6 +6,7 @@ import { eq } from "drizzle-orm";
|
|||||||
import {
|
import {
|
||||||
sendDiscordNotification,
|
sendDiscordNotification,
|
||||||
sendEmailNotification,
|
sendEmailNotification,
|
||||||
|
sendGotifyNotification,
|
||||||
sendSlackNotification,
|
sendSlackNotification,
|
||||||
sendTelegramNotification,
|
sendTelegramNotification,
|
||||||
} from "./utils";
|
} from "./utils";
|
||||||
@ -20,11 +21,12 @@ export const sendDokployRestartNotifications = async () => {
|
|||||||
discord: true,
|
discord: true,
|
||||||
telegram: true,
|
telegram: true,
|
||||||
slack: true,
|
slack: true,
|
||||||
|
gotify: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const notification of notificationList) {
|
for (const notification of notificationList) {
|
||||||
const { email, discord, telegram, slack } = notification;
|
const { email, discord, telegram, slack, gotify } = notification;
|
||||||
|
|
||||||
if (email) {
|
if (email) {
|
||||||
const template = await renderAsync(
|
const template = await renderAsync(
|
||||||
@ -64,11 +66,21 @@ export const sendDokployRestartNotifications = async () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gotify) {
|
||||||
|
const decorate = (decoration: string, text: string) =>
|
||||||
|
`${gotify.decoration ? decoration : ""} ${text}`.trim();
|
||||||
|
await sendGotifyNotification(
|
||||||
|
gotify,
|
||||||
|
decorate("✅", "Dokploy Server Restarted"),
|
||||||
|
`${decorate("🕒", `Date: ${date.toLocaleString()}`)}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (telegram) {
|
if (telegram) {
|
||||||
await sendTelegramNotification(
|
await sendTelegramNotification(
|
||||||
telegram,
|
telegram,
|
||||||
`
|
`
|
||||||
<b>✅ Dokploy Serverd Restarted</b>
|
<b>✅ Dokploy Server Restarted</b>
|
||||||
<b>Time:</b> ${date.toLocaleString()}
|
<b>Time:</b> ${date.toLocaleString()}
|
||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user