mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-20 11:08:46 +00:00
feat: add resend notification functionality
- Introduced a new notification type "resend" to the system. - Added database schema for resend notifications including fields for apiKey, fromAddress, and toAddress. - Implemented functions to create, update, and send resend notifications. - Updated notification router to handle resend notifications with appropriate API endpoints. - Enhanced existing notification services to support sending notifications via the Resend service. - Modified various notification utilities to accommodate the new resend functionality.
This commit is contained in:
+1890
-1734
File diff suppressed because it is too large
Load Diff
@@ -5,6 +5,7 @@ import {
|
|||||||
GotifyIcon,
|
GotifyIcon,
|
||||||
LarkIcon,
|
LarkIcon,
|
||||||
NtfyIcon,
|
NtfyIcon,
|
||||||
|
ResendIcon,
|
||||||
SlackIcon,
|
SlackIcon,
|
||||||
TelegramIcon,
|
TelegramIcon,
|
||||||
} from "@/components/icons/notification-icons";
|
} from "@/components/icons/notification-icons";
|
||||||
@@ -36,7 +37,7 @@ export const ShowNotifications = () => {
|
|||||||
</CardTitle>
|
</CardTitle>
|
||||||
<CardDescription>
|
<CardDescription>
|
||||||
Add your providers to receive notifications, like Discord, Slack,
|
Add your providers to receive notifications, like Discord, Slack,
|
||||||
Telegram, Email, Lark.
|
Telegram, Email, Resend, Lark.
|
||||||
</CardDescription>
|
</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="space-y-2 py-8 border-t">
|
<CardContent className="space-y-2 py-8 border-t">
|
||||||
@@ -86,6 +87,11 @@ export const ShowNotifications = () => {
|
|||||||
<Mail className="size-6 text-muted-foreground" />
|
<Mail className="size-6 text-muted-foreground" />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{notification.notificationType === "resend" && (
|
||||||
|
<div className="flex items-center justify-center rounded-lg ">
|
||||||
|
<ResendIcon className="size-6 text-muted-foreground" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{notification.notificationType === "gotify" && (
|
{notification.notificationType === "gotify" && (
|
||||||
<div className="flex items-center justify-center rounded-lg ">
|
<div className="flex items-center justify-center rounded-lg ">
|
||||||
<GotifyIcon className="size-6" />
|
<GotifyIcon className="size-6" />
|
||||||
|
|||||||
@@ -1,237 +1,237 @@
|
|||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
export const SlackIcon = ({ className }: Props) => {
|
export const SlackIcon = ({ className }: Props) => {
|
||||||
return (
|
return (
|
||||||
<svg
|
<svg
|
||||||
viewBox="0 0 2447.6 2452.5"
|
viewBox="0 0 2447.6 2452.5"
|
||||||
className={cn("size-8", className)}
|
className={cn("size-8", className)}
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
>
|
>
|
||||||
<g clipRule="evenodd" fillRule="evenodd">
|
<g clipRule="evenodd" fillRule="evenodd">
|
||||||
<path
|
<path
|
||||||
d="m897.4 0c-135.3.1-244.8 109.9-244.7 245.2-.1 135.3 109.5 245.1 244.8 245.2h244.8v-245.1c.1-135.3-109.5-245.1-244.9-245.3.1 0 .1 0 0 0m0 654h-652.6c-135.3.1-244.9 109.9-244.8 245.2-.2 135.3 109.4 245.1 244.7 245.3h652.7c135.3-.1 244.9-109.9 244.8-245.2.1-135.4-109.5-245.2-244.8-245.3z"
|
d="m897.4 0c-135.3.1-244.8 109.9-244.7 245.2-.1 135.3 109.5 245.1 244.8 245.2h244.8v-245.1c.1-135.3-109.5-245.1-244.9-245.3.1 0 .1 0 0 0m0 654h-652.6c-135.3.1-244.9 109.9-244.8 245.2-.2 135.3 109.4 245.1 244.7 245.3h652.7c135.3-.1 244.9-109.9 244.8-245.2.1-135.4-109.5-245.2-244.8-245.3z"
|
||||||
fill="#36c5f0"
|
fill="#36c5f0"
|
||||||
/>
|
/>
|
||||||
<path
|
<path
|
||||||
d="m2447.6 899.2c.1-135.3-109.5-245.1-244.8-245.2-135.3.1-244.9 109.9-244.8 245.2v245.3h244.8c135.3-.1 244.9-109.9 244.8-245.3zm-652.7 0v-654c.1-135.2-109.4-245-244.7-245.2-135.3.1-244.9 109.9-244.8 245.2v654c-.2 135.3 109.4 245.1 244.7 245.3 135.3-.1 244.9-109.9 244.8-245.3z"
|
d="m2447.6 899.2c.1-135.3-109.5-245.1-244.8-245.2-135.3.1-244.9 109.9-244.8 245.2v245.3h244.8c135.3-.1 244.9-109.9 244.8-245.3zm-652.7 0v-654c.1-135.2-109.4-245-244.7-245.2-135.3.1-244.9 109.9-244.8 245.2v654c-.2 135.3 109.4 245.1 244.7 245.3 135.3-.1 244.9-109.9 244.8-245.3z"
|
||||||
fill="#2eb67d"
|
fill="#2eb67d"
|
||||||
/>
|
/>
|
||||||
<path
|
<path
|
||||||
d="m1550.1 2452.5c135.3-.1 244.9-109.9 244.8-245.2.1-135.3-109.5-245.1-244.8-245.2h-244.8v245.2c-.1 135.2 109.5 245 244.8 245.2zm0-654.1h652.7c135.3-.1 244.9-109.9 244.8-245.2.2-135.3-109.4-245.1-244.7-245.3h-652.7c-135.3.1-244.9 109.9-244.8 245.2-.1 135.4 109.4 245.2 244.7 245.3z"
|
d="m1550.1 2452.5c135.3-.1 244.9-109.9 244.8-245.2.1-135.3-109.5-245.1-244.8-245.2h-244.8v245.2c-.1 135.2 109.5 245 244.8 245.2zm0-654.1h652.7c135.3-.1 244.9-109.9 244.8-245.2.2-135.3-109.4-245.1-244.7-245.3h-652.7c-135.3.1-244.9 109.9-244.8 245.2-.1 135.4 109.4 245.2 244.7 245.3z"
|
||||||
fill="#ecb22e"
|
fill="#ecb22e"
|
||||||
/>
|
/>
|
||||||
<path
|
<path
|
||||||
d="m0 1553.2c-.1 135.3 109.5 245.1 244.8 245.2 135.3-.1 244.9-109.9 244.8-245.2v-245.2h-244.8c-135.3.1-244.9 109.9-244.8 245.2zm652.7 0v654c-.2 135.3 109.4 245.1 244.7 245.3 135.3-.1 244.9-109.9 244.8-245.2v-653.9c.2-135.3-109.4-245.1-244.7-245.3-135.4 0-244.9 109.8-244.8 245.1 0 0 0 .1 0 0"
|
d="m0 1553.2c-.1 135.3 109.5 245.1 244.8 245.2 135.3-.1 244.9-109.9 244.8-245.2v-245.2h-244.8c-135.3.1-244.9 109.9-244.8 245.2zm652.7 0v654c-.2 135.3 109.4 245.1 244.7 245.3 135.3-.1 244.9-109.9 244.8-245.2v-653.9c.2-135.3-109.4-245.1-244.7-245.3-135.4 0-244.9 109.8-244.8 245.1 0 0 0 .1 0 0"
|
||||||
fill="#e01e5a"
|
fill="#e01e5a"
|
||||||
/>
|
/>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const TelegramIcon = ({ className }: Props) => {
|
export const TelegramIcon = ({ className }: Props) => {
|
||||||
return (
|
return (
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
viewBox="0 0 48 48"
|
viewBox="0 0 48 48"
|
||||||
width="48px"
|
width="48px"
|
||||||
height="48px"
|
height="48px"
|
||||||
className={cn("size-9", className)}
|
className={cn("size-9", className)}
|
||||||
>
|
>
|
||||||
<linearGradient
|
<linearGradient
|
||||||
id="BiF7D16UlC0RZ_VqXJHnXa"
|
id="BiF7D16UlC0RZ_VqXJHnXa"
|
||||||
x1="9.858"
|
x1="9.858"
|
||||||
x2="38.142"
|
x2="38.142"
|
||||||
y1="9.858"
|
y1="9.858"
|
||||||
y2="38.142"
|
y2="38.142"
|
||||||
gradientUnits="userSpaceOnUse"
|
gradientUnits="userSpaceOnUse"
|
||||||
>
|
>
|
||||||
<stop offset="0" stopColor="#33bef0" />
|
<stop offset="0" stopColor="#33bef0" />
|
||||||
<stop offset="1" stopColor="#0a85d9" />
|
<stop offset="1" stopColor="#0a85d9" />
|
||||||
</linearGradient>
|
</linearGradient>
|
||||||
<path
|
<path
|
||||||
fill="url(#BiF7D16UlC0RZ_VqXJHnXa)"
|
fill="url(#BiF7D16UlC0RZ_VqXJHnXa)"
|
||||||
d="M44,24c0,11.045-8.955,20-20,20S4,35.045,4,24S12.955,4,24,4S44,12.955,44,24z"
|
d="M44,24c0,11.045-8.955,20-20,20S4,35.045,4,24S12.955,4,24,4S44,12.955,44,24z"
|
||||||
/>
|
/>
|
||||||
<path
|
<path
|
||||||
d="M10.119,23.466c8.155-3.695,17.733-7.704,19.208-8.284c3.252-1.279,4.67,0.028,4.448,2.113 c-0.273,2.555-1.567,9.99-2.363,15.317c-0.466,3.117-2.154,4.072-4.059,2.863c-1.445-0.917-6.413-4.17-7.72-5.282 c-0.891-0.758-1.512-1.608-0.88-2.474c0.185-0.253,0.658-0.763,0.921-1.017c1.319-1.278,1.141-1.553-0.454-0.412 c-0.19,0.136-1.292,0.935-1.745,1.237c-1.11,0.74-2.131,0.78-3.862,0.192c-1.416-0.481-2.776-0.852-3.634-1.223 C8.794,25.983,8.34,24.272,10.119,23.466z"
|
d="M10.119,23.466c8.155-3.695,17.733-7.704,19.208-8.284c3.252-1.279,4.67,0.028,4.448,2.113 c-0.273,2.555-1.567,9.99-2.363,15.317c-0.466,3.117-2.154,4.072-4.059,2.863c-1.445-0.917-6.413-4.17-7.72-5.282 c-0.891-0.758-1.512-1.608-0.88-2.474c0.185-0.253,0.658-0.763,0.921-1.017c1.319-1.278,1.141-1.553-0.454-0.412 c-0.19,0.136-1.292,0.935-1.745,1.237c-1.11,0.74-2.131,0.78-3.862,0.192c-1.416-0.481-2.776-0.852-3.634-1.223 C8.794,25.983,8.34,24.272,10.119,23.466z"
|
||||||
opacity=".05"
|
opacity=".05"
|
||||||
/>
|
/>
|
||||||
<path
|
<path
|
||||||
d="M10.836,23.591c7.572-3.385,16.884-7.264,18.246-7.813c3.264-1.318,4.465-0.536,4.114,2.011 c-0.326,2.358-1.483,9.654-2.294,14.545c-0.478,2.879-1.874,3.513-3.692,2.337c-1.139-0.734-5.723-3.754-6.835-4.633 c-0.86-0.679-1.751-1.463-0.71-2.598c0.348-0.379,2.27-2.234,3.707-3.614c0.833-0.801,0.536-1.196-0.469-0.508 c-1.843,1.263-4.858,3.262-5.396,3.625c-1.025,0.69-1.988,0.856-3.664,0.329c-1.321-0.416-2.597-0.819-3.262-1.078 C9.095,25.618,9.075,24.378,10.836,23.591z"
|
d="M10.836,23.591c7.572-3.385,16.884-7.264,18.246-7.813c3.264-1.318,4.465-0.536,4.114,2.011 c-0.326,2.358-1.483,9.654-2.294,14.545c-0.478,2.879-1.874,3.513-3.692,2.337c-1.139-0.734-5.723-3.754-6.835-4.633 c-0.86-0.679-1.751-1.463-0.71-2.598c0.348-0.379,2.27-2.234,3.707-3.614c0.833-0.801,0.536-1.196-0.469-0.508 c-1.843,1.263-4.858,3.262-5.396,3.625c-1.025,0.69-1.988,0.856-3.664,0.329c-1.321-0.416-2.597-0.819-3.262-1.078 C9.095,25.618,9.075,24.378,10.836,23.591z"
|
||||||
opacity=".07"
|
opacity=".07"
|
||||||
/>
|
/>
|
||||||
<path
|
<path
|
||||||
fill="#fff"
|
fill="#fff"
|
||||||
d="M11.553,23.717c6.99-3.075,16.035-6.824,17.284-7.343c3.275-1.358,4.28-1.098,3.779,1.91 c-0.36,2.162-1.398,9.319-2.226,13.774c-0.491,2.642-1.593,2.955-3.325,1.812c-0.833-0.55-5.038-3.331-5.951-3.984 c-0.833-0.595-1.982-1.311-0.541-2.721c0.513-0.502,3.874-3.712,6.493-6.21c0.343-0.328-0.088-0.867-0.484-0.604 c-3.53,2.341-8.424,5.59-9.047,6.013c-0.941,0.639-1.845,0.932-3.467,0.466c-1.226-0.352-2.423-0.772-2.889-0.932 C9.384,25.282,9.81,24.484,11.553,23.717z"
|
d="M11.553,23.717c6.99-3.075,16.035-6.824,17.284-7.343c3.275-1.358,4.28-1.098,3.779,1.91 c-0.36,2.162-1.398,9.319-2.226,13.774c-0.491,2.642-1.593,2.955-3.325,1.812c-0.833-0.55-5.038-3.331-5.951-3.984 c-0.833-0.595-1.982-1.311-0.541-2.721c0.513-0.502,3.874-3.712,6.493-6.21c0.343-0.328-0.088-0.867-0.484-0.604 c-3.53,2.341-8.424,5.59-9.047,6.013c-0.941,0.639-1.845,0.932-3.467,0.466c-1.226-0.352-2.423-0.772-2.889-0.932 C9.384,25.282,9.81,24.484,11.553,23.717z"
|
||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DiscordIcon = ({ className }: Props) => {
|
export const DiscordIcon = ({ className }: Props) => {
|
||||||
return (
|
return (
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
viewBox="0 0 48 48"
|
viewBox="0 0 48 48"
|
||||||
width="48px"
|
width="48px"
|
||||||
height="48px"
|
height="48px"
|
||||||
className={cn("size-9", className)}
|
className={cn("size-9", className)}
|
||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
fill="#536dfe"
|
fill="#536dfe"
|
||||||
d="M39.248,10.177c-2.804-1.287-5.812-2.235-8.956-2.778c-0.057-0.01-0.114,0.016-0.144,0.068 c-0.387,0.688-0.815,1.585-1.115,2.291c-3.382-0.506-6.747-0.506-10.059,0c-0.3-0.721-0.744-1.603-1.133-2.291 c-0.03-0.051-0.087-0.077-0.144-0.068c-3.143,0.541-6.15,1.489-8.956,2.778c-0.024,0.01-0.045,0.028-0.059,0.051 c-5.704,8.522-7.267,16.835-6.5,25.044c0.003,0.04,0.026,0.079,0.057,0.103c3.763,2.764,7.409,4.442,10.987,5.554 c0.057,0.017,0.118-0.003,0.154-0.051c0.846-1.156,1.601-2.374,2.248-3.656c0.038-0.075,0.002-0.164-0.076-0.194 c-1.197-0.454-2.336-1.007-3.432-1.636c-0.087-0.051-0.094-0.175-0.014-0.234c0.231-0.173,0.461-0.353,0.682-0.534 c0.04-0.033,0.095-0.04,0.142-0.019c7.201,3.288,14.997,3.288,22.113,0c0.047-0.023,0.102-0.016,0.144,0.017 c0.22,0.182,0.451,0.363,0.683,0.536c0.08,0.059,0.075,0.183-0.012,0.234c-1.096,0.641-2.236,1.182-3.434,1.634 c-0.078,0.03-0.113,0.12-0.075,0.196c0.661,1.28,1.415,2.498,2.246,3.654c0.035,0.049,0.097,0.07,0.154,0.052 c3.595-1.112,7.241-2.79,11.004-5.554c0.033-0.024,0.054-0.061,0.057-0.101c0.917-9.491-1.537-17.735-6.505-25.044 C39.293,10.205,39.272,10.187,39.248,10.177z M16.703,30.273c-2.168,0-3.954-1.99-3.954-4.435s1.752-4.435,3.954-4.435 c2.22,0,3.989,2.008,3.954,4.435C20.658,28.282,18.906,30.273,16.703,30.273z M31.324,30.273c-2.168,0-3.954-1.99-3.954-4.435 s1.752-4.435,3.954-4.435c2.22,0,3.989,2.008,3.954,4.435C35.278,28.282,33.544,30.273,31.324,30.273z"
|
d="M39.248,10.177c-2.804-1.287-5.812-2.235-8.956-2.778c-0.057-0.01-0.114,0.016-0.144,0.068 c-0.387,0.688-0.815,1.585-1.115,2.291c-3.382-0.506-6.747-0.506-10.059,0c-0.3-0.721-0.744-1.603-1.133-2.291 c-0.03-0.051-0.087-0.077-0.144-0.068c-3.143,0.541-6.15,1.489-8.956,2.778c-0.024,0.01-0.045,0.028-0.059,0.051 c-5.704,8.522-7.267,16.835-6.5,25.044c0.003,0.04,0.026,0.079,0.057,0.103c3.763,2.764,7.409,4.442,10.987,5.554 c0.057,0.017,0.118-0.003,0.154-0.051c0.846-1.156,1.601-2.374,2.248-3.656c0.038-0.075,0.002-0.164-0.076-0.194 c-1.197-0.454-2.336-1.007-3.432-1.636c-0.087-0.051-0.094-0.175-0.014-0.234c0.231-0.173,0.461-0.353,0.682-0.534 c0.04-0.033,0.095-0.04,0.142-0.019c7.201,3.288,14.997,3.288,22.113,0c0.047-0.023,0.102-0.016,0.144,0.017 c0.22,0.182,0.451,0.363,0.683,0.536c0.08,0.059,0.075,0.183-0.012,0.234c-1.096,0.641-2.236,1.182-3.434,1.634 c-0.078,0.03-0.113,0.12-0.075,0.196c0.661,1.28,1.415,2.498,2.246,3.654c0.035,0.049,0.097,0.07,0.154,0.052 c3.595-1.112,7.241-2.79,11.004-5.554c0.033-0.024,0.054-0.061,0.057-0.101c0.917-9.491-1.537-17.735-6.505-25.044 C39.293,10.205,39.272,10.187,39.248,10.177z M16.703,30.273c-2.168,0-3.954-1.99-3.954-4.435s1.752-4.435,3.954-4.435 c2.22,0,3.989,2.008,3.954,4.435C20.658,28.282,18.906,30.273,16.703,30.273z M31.324,30.273c-2.168,0-3.954-1.99-3.954-4.435 s1.752-4.435,3.954-4.435c2.22,0,3.989,2.008,3.954,4.435C35.278,28.282,33.544,30.273,31.324,30.273z"
|
||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
export const LarkIcon = ({ className }: Props) => {
|
export const LarkIcon = ({ className }: Props) => {
|
||||||
return (
|
return (
|
||||||
<svg
|
<svg
|
||||||
width="1em"
|
width="1em"
|
||||||
height="1em"
|
height="1em"
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
fill="none"
|
fill="none"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
data-icon="LarkLogoColorful"
|
data-icon="LarkLogoColorful"
|
||||||
className={cn("size-9", className)}
|
className={cn("size-9", className)}
|
||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
d="m12.924 12.803.056-.054c.038-.034.076-.072.11-.11l.077-.076.23-.227 1.334-1.319.335-.331c.063-.063.13-.123.195-.183a7.777 7.777 0 0 1 1.823-1.24 7.607 7.607 0 0 1 1.014-.4 13.177 13.177 0 0 0-2.5-5.013 1.203 1.203 0 0 0-.94-.448h-9.65c-.173 0-.246.224-.107.325a28.23 28.23 0 0 1 8 9.098c.007-.006.016-.013.023-.022Z"
|
d="m12.924 12.803.056-.054c.038-.034.076-.072.11-.11l.077-.076.23-.227 1.334-1.319.335-.331c.063-.063.13-.123.195-.183a7.777 7.777 0 0 1 1.823-1.24 7.607 7.607 0 0 1 1.014-.4 13.177 13.177 0 0 0-2.5-5.013 1.203 1.203 0 0 0-.94-.448h-9.65c-.173 0-.246.224-.107.325a28.23 28.23 0 0 1 8 9.098c.007-.006.016-.013.023-.022Z"
|
||||||
fill="#00D6B9"
|
fill="#00D6B9"
|
||||||
/>
|
/>
|
||||||
<path
|
<path
|
||||||
d="M9.097 21.299a13.258 13.258 0 0 0 11.82-7.247 5.576 5.576 0 0 1-.731 1.076 5.315 5.315 0 0 1-.745.7 5.117 5.117 0 0 1-.615.404 4.626 4.626 0 0 1-.726.331 5.312 5.312 0 0 1-1.883.312 5.892 5.892 0 0 1-.524-.031 6.509 6.509 0 0 1-.729-.126c-.06-.016-.12-.029-.18-.044-.166-.044-.33-.092-.494-.14-.082-.024-.164-.046-.246-.072-.123-.038-.247-.072-.366-.11l-.3-.095-.284-.094-.192-.067c-.08-.025-.155-.053-.234-.082a3.49 3.49 0 0 1-.167-.06c-.11-.04-.221-.079-.328-.12-.063-.025-.126-.047-.19-.072l-.252-.098c-.088-.035-.18-.07-.268-.107l-.174-.07c-.072-.028-.141-.06-.214-.088l-.164-.07c-.057-.024-.114-.05-.17-.075l-.149-.066-.135-.06-.14-.063a90.183 90.183 0 0 1-.141-.066 4.808 4.808 0 0 0-.18-.083c-.063-.028-.123-.06-.186-.088a5.697 5.697 0 0 1-.199-.098 27.762 27.762 0 0 1-8.067-5.969.18.18 0 0 0-.312.123l.006 9.21c0 .4.199.779.533 1a13.177 13.177 0 0 0 7.326 2.205Z"
|
d="M9.097 21.299a13.258 13.258 0 0 0 11.82-7.247 5.576 5.576 0 0 1-.731 1.076 5.315 5.315 0 0 1-.745.7 5.117 5.117 0 0 1-.615.404 4.626 4.626 0 0 1-.726.331 5.312 5.312 0 0 1-1.883.312 5.892 5.892 0 0 1-.524-.031 6.509 6.509 0 0 1-.729-.126c-.06-.016-.12-.029-.18-.044-.166-.044-.33-.092-.494-.14-.082-.024-.164-.046-.246-.072-.123-.038-.247-.072-.366-.11l-.3-.095-.284-.094-.192-.067c-.08-.025-.155-.053-.234-.082a3.49 3.49 0 0 1-.167-.06c-.11-.04-.221-.079-.328-.12-.063-.025-.126-.047-.19-.072l-.252-.098c-.088-.035-.18-.07-.268-.107l-.174-.07c-.072-.028-.141-.06-.214-.088l-.164-.07c-.057-.024-.114-.05-.17-.075l-.149-.066-.135-.06-.14-.063a90.183 90.183 0 0 1-.141-.066 4.808 4.808 0 0 0-.18-.083c-.063-.028-.123-.06-.186-.088a5.697 5.697 0 0 1-.199-.098 27.762 27.762 0 0 1-8.067-5.969.18.18 0 0 0-.312.123l.006 9.21c0 .4.199.779.533 1a13.177 13.177 0 0 0 7.326 2.205Z"
|
||||||
fill="#3370FF"
|
fill="#3370FF"
|
||||||
/>
|
/>
|
||||||
<path
|
<path
|
||||||
d="M23.732 9.295a7.55 7.55 0 0 0-3.35-.776 7.521 7.521 0 0 0-2.284.35c-.054.016-.107.035-.158.05a8.297 8.297 0 0 0-.855.35 7.14 7.14 0 0 0-.552.297 6.716 6.716 0 0 0-.533.347c-.123.089-.243.18-.363.275-.13.104-.252.211-.375.321-.067.06-.13.123-.196.184l-.334.328-1.338 1.321-.23.228-.076.075c-.038.038-.076.073-.11.11l-.057.054a1.914 1.914 0 0 1-.085.08c-.032.028-.063.06-.095.088a13.286 13.286 0 0 1-2.748 1.946c.06.028.12.057.18.082l.142.066c.044.022.091.041.139.063l.135.06.149.067.17.075.164.07c.073.031.142.06.215.088.056.025.116.047.173.07.088.034.177.072.268.107.085.031.168.066.253.098l.189.072c.11.041.218.082.328.12.057.019.11.041.167.06.08.028.155.053.234.082l.192.066.284.095.3.095c.123.037.243.075.366.11l.246.072c.164.048.331.095.495.14.06.015.12.03.18.043.114.029.227.05.34.07.13.022.26.04.389.057a5.815 5.815 0 0 0 .994.019 5.172 5.172 0 0 0 1.413-.3 5.405 5.405 0 0 0 .726-.334c.06-.035.122-.07.182-.108a7.96 7.96 0 0 0 .432-.297 5.362 5.362 0 0 0 .577-.517 5.285 5.285 0 0 0 .37-.429 5.797 5.797 0 0 0 .527-.827l.13-.258 1.166-2.325-.003.006a7.391 7.391 0 0 1 1.527-2.186Z"
|
d="M23.732 9.295a7.55 7.55 0 0 0-3.35-.776 7.521 7.521 0 0 0-2.284.35c-.054.016-.107.035-.158.05a8.297 8.297 0 0 0-.855.35 7.14 7.14 0 0 0-.552.297 6.716 6.716 0 0 0-.533.347c-.123.089-.243.18-.363.275-.13.104-.252.211-.375.321-.067.06-.13.123-.196.184l-.334.328-1.338 1.321-.23.228-.076.075c-.038.038-.076.073-.11.11l-.057.054a1.914 1.914 0 0 1-.085.08c-.032.028-.063.06-.095.088a13.286 13.286 0 0 1-2.748 1.946c.06.028.12.057.18.082l.142.066c.044.022.091.041.139.063l.135.06.149.067.17.075.164.07c.073.031.142.06.215.088.056.025.116.047.173.07.088.034.177.072.268.107.085.031.168.066.253.098l.189.072c.11.041.218.082.328.12.057.019.11.041.167.06.08.028.155.053.234.082l.192.066.284.095.3.095c.123.037.243.075.366.11l.246.072c.164.048.331.095.495.14.06.015.12.03.18.043.114.029.227.05.34.07.13.022.26.04.389.057a5.815 5.815 0 0 0 .994.019 5.172 5.172 0 0 0 1.413-.3 5.405 5.405 0 0 0 .726-.334c.06-.035.122-.07.182-.108a7.96 7.96 0 0 0 .432-.297 5.362 5.362 0 0 0 .577-.517 5.285 5.285 0 0 0 .37-.429 5.797 5.797 0 0 0 .527-.827l.13-.258 1.166-2.325-.003.006a7.391 7.391 0 0 1 1.527-2.186Z"
|
||||||
fill="#133C9A"
|
fill="#133C9A"
|
||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
export const GotifyIcon = ({ className }: Props) => {
|
export const GotifyIcon = ({ className }: Props) => {
|
||||||
return (
|
return (
|
||||||
<svg
|
<svg
|
||||||
viewBox="0 0 500 500"
|
viewBox="0 0 500 500"
|
||||||
className={cn("size-8", className)}
|
className={cn("size-8", className)}
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
>
|
>
|
||||||
<defs>
|
<defs>
|
||||||
<style>
|
<style>
|
||||||
{`
|
{`
|
||||||
.gotify-st0{fill:#DDCBA2;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;}
|
.gotify-st0{fill:#DDCBA2;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;}
|
||||||
.gotify-st1{fill:#71CAEE;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;}
|
.gotify-st1{fill:#71CAEE;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;}
|
||||||
.gotify-st2{fill:#FFFFFF;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;}
|
.gotify-st2{fill:#FFFFFF;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;}
|
||||||
.gotify-st3{fill:#888E93;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;}
|
.gotify-st3{fill:#888E93;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;}
|
||||||
.gotify-st4{fill:#F0F0F0;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;}
|
.gotify-st4{fill:#F0F0F0;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;}
|
||||||
.gotify-st5{fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;}
|
.gotify-st5{fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;}
|
||||||
.gotify-st8{fill:#FFFFFF;}
|
.gotify-st8{fill:#FFFFFF;}
|
||||||
`}
|
`}
|
||||||
</style>
|
</style>
|
||||||
<linearGradient
|
<linearGradient
|
||||||
id="gotify-gradient"
|
id="gotify-gradient"
|
||||||
x1="265"
|
x1="265"
|
||||||
y1="280"
|
y1="280"
|
||||||
x2="275"
|
x2="275"
|
||||||
y2="302"
|
y2="302"
|
||||||
gradientUnits="userSpaceOnUse"
|
gradientUnits="userSpaceOnUse"
|
||||||
>
|
>
|
||||||
<stop offset="0" stopColor="#71CAEE" />
|
<stop offset="0" stopColor="#71CAEE" />
|
||||||
<stop offset="0.04" stopColor="#83CAE2" />
|
<stop offset="0.04" stopColor="#83CAE2" />
|
||||||
<stop offset="0.12" stopColor="#9FCACE" />
|
<stop offset="0.12" stopColor="#9FCACE" />
|
||||||
<stop offset="0.21" stopColor="#B6CBBE" />
|
<stop offset="0.21" stopColor="#B6CBBE" />
|
||||||
<stop offset="0.31" stopColor="#C7CBB1" />
|
<stop offset="0.31" stopColor="#C7CBB1" />
|
||||||
<stop offset="0.44" stopColor="#D4CBA8" />
|
<stop offset="0.44" stopColor="#D4CBA8" />
|
||||||
<stop offset="0.61" stopColor="#DBCBA3" />
|
<stop offset="0.61" stopColor="#DBCBA3" />
|
||||||
<stop offset="1" stopColor="#DDCBA2" />
|
<stop offset="1" stopColor="#DDCBA2" />
|
||||||
</linearGradient>
|
</linearGradient>
|
||||||
</defs>
|
</defs>
|
||||||
<g transform="matrix(2.33,0,0,2.33,-432,-323)">
|
<g transform="matrix(2.33,0,0,2.33,-432,-323)">
|
||||||
<g transform="translate(-25,26)">
|
<g transform="translate(-25,26)">
|
||||||
<path
|
<path
|
||||||
className="gotify-st1"
|
className="gotify-st1"
|
||||||
d="m258.9,119.7c-3,-0.9-6,-1.8-9,-2.7-4.6,-1.4-9.2,-2.8-14,-2.5-2.8,0.2-6.1,1.3-6.9,4-0.6,2-1.6,7.3-1.3,7.9 1.5,3.4 13.9,6.7 18.3,6.7"
|
d="m258.9,119.7c-3,-0.9-6,-1.8-9,-2.7-4.6,-1.4-9.2,-2.8-14,-2.5-2.8,0.2-6.1,1.3-6.9,4-0.6,2-1.6,7.3-1.3,7.9 1.5,3.4 13.9,6.7 18.3,6.7"
|
||||||
/>
|
/>
|
||||||
<path d="m392.6,177.9c-1.4,1.4-2.2,3.5-2.5,5.5-0.2,1.4-0.1,3 0.5,4.3 0.6,1.3 1.8,2.3 3.1,3 1.3,0.6 2.8,0.9 4.3,0.9 1.1,0 2.3,-0.1 3.1,-0.9 0.6,-0.7 0.8,-1.6 0.9,-2.5 0.2,-2.3-0.1,-4.7-0.9,-6.9-0.4,-1.1-0.9,-2.3-1.8,-3.1-1.7,-1.8-4.5,-2.2-6.4,-0.5-0.1,0-0.2,0.1-0.3,0.2z" />
|
<path d="m392.6,177.9c-1.4,1.4-2.2,3.5-2.5,5.5-0.2,1.4-0.1,3 0.5,4.3 0.6,1.3 1.8,2.3 3.1,3 1.3,0.6 2.8,0.9 4.3,0.9 1.1,0 2.3,-0.1 3.1,-0.9 0.6,-0.7 0.8,-1.6 0.9,-2.5 0.2,-2.3-0.1,-4.7-0.9,-6.9-0.4,-1.1-0.9,-2.3-1.8,-3.1-1.7,-1.8-4.5,-2.2-6.4,-0.5-0.1,0-0.2,0.1-0.3,0.2z" />
|
||||||
<path
|
<path
|
||||||
className="gotify-st2"
|
className="gotify-st2"
|
||||||
d="m358.5,164.2c-1,-1 0,-2.7 1,-3.7 5.8,-5.2 15.1,-4.6 21.8,-0.6 10.9,6.6 15.6,19.9 17.2,32.5 0.6,5.2 0.9,10.6-0.5,15.7-1.4,5.1-4.6,9.9-9.3,12.1-1.1,0.5-2.3,0.9-3.4,0.5-1.1,-0.4-1.9,-1.8-1.2,-2.8-9.4,-13.6-19,-26.8-20.9,-43.2-0.5,-4.1-1.8,-7.4-4.7,-10.5z"
|
d="m358.5,164.2c-1,-1 0,-2.7 1,-3.7 5.8,-5.2 15.1,-4.6 21.8,-0.6 10.9,6.6 15.6,19.9 17.2,32.5 0.6,5.2 0.9,10.6-0.5,15.7-1.4,5.1-4.6,9.9-9.3,12.1-1.1,0.5-2.3,0.9-3.4,0.5-1.1,-0.4-1.9,-1.8-1.2,-2.8-9.4,-13.6-19,-26.8-20.9,-43.2-0.5,-4.1-1.8,-7.4-4.7,-10.5z"
|
||||||
/>
|
/>
|
||||||
<path
|
<path
|
||||||
className="gotify-st1"
|
className="gotify-st1"
|
||||||
d="m220.1,133c34.6,-18 79.3,-19.6 112.2,-8.7 23.7,7.9 41.3,26.7 49.5,50 7.1,20.6 7.1,43.6 3,65.7-7.5,40.2-26.2,77.9-49,112.6-12.6,19-24.6,36-44.2,48.5-38.7,24.6-88.9,22.1-129.3,11.5-19.5,-5.1-38.4,-17.3-44.3,-37.3-3.8,-12.8-2.1,-27.6 4.6,-40 13.5,-24.8 46.2,-38.4 50.8,-67.9 1.4,-8.7-0.3,-17.3-1.6,-25.7-3.8,-23.4-5.4,-45.8 6.7,-68.7 9.5,-17.7 24.3,-31 41.7,-40z"
|
d="m220.1,133c34.6,-18 79.3,-19.6 112.2,-8.7 23.7,7.9 41.3,26.7 49.5,50 7.1,20.6 7.1,43.6 3,65.7-7.5,40.2-26.2,77.9-49,112.6-12.6,19-24.6,36-44.2,48.5-38.7,24.6-88.9,22.1-129.3,11.5-19.5,-5.1-38.4,-17.3-44.3,-37.3-3.8,-12.8-2.1,-27.6 4.6,-40 13.5,-24.8 46.2,-38.4 50.8,-67.9 1.4,-8.7-0.3,-17.3-1.6,-25.7-3.8,-23.4-5.4,-45.8 6.7,-68.7 9.5,-17.7 24.3,-31 41.7,-40z"
|
||||||
/>
|
/>
|
||||||
<path
|
<path
|
||||||
className="gotify-st2"
|
className="gotify-st2"
|
||||||
d="m264.5,174.9c-0.5,0.5-0.9,1-1.3,1.6-9,11.6-12,27.9-9.3,42.1 1.7,9 5.9,17.9 13.2,23.4 19.3,14.6 51.5,13.5 68.4,-1.5 24.4,-21.7 13,-67.6-14,-78.8-17.6,-7.2-43.7,-1.6-57,13.2z"
|
d="m264.5,174.9c-0.5,0.5-0.9,1-1.3,1.6-9,11.6-12,27.9-9.3,42.1 1.7,9 5.9,17.9 13.2,23.4 19.3,14.6 51.5,13.5 68.4,-1.5 24.4,-21.7 13,-67.6-14,-78.8-17.6,-7.2-43.7,-1.6-57,13.2z"
|
||||||
/>
|
/>
|
||||||
<path
|
<path
|
||||||
className="gotify-st2"
|
className="gotify-st2"
|
||||||
d="m382.1,237.1c1.4,-0.1 2.9,-0.1 4.3,0.1 0.3,0 0.7,0.1 1,0.4 0.2,0.3 0.4,0.7 0.5,1.1 1,3.9 0.5,8.2 0.1,12.4-0.1,0.9-0.2,1.8-0.6,2.6-1,2.1-3.1,2.7-4.7,2.7-0.1,0-0.2,0-0.3,-0.1-0.3,-0.2-0.3,-0.7-0.2,-1.2 0.3,-5.9-0.1,-11.9-0.1,-18z"
|
d="m382.1,237.1c1.4,-0.1 2.9,-0.1 4.3,0.1 0.3,0 0.7,0.1 1,0.4 0.2,0.3 0.4,0.7 0.5,1.1 1,3.9 0.5,8.2 0.1,12.4-0.1,0.9-0.2,1.8-0.6,2.6-1,2.1-3.1,2.7-4.7,2.7-0.1,0-0.2,0-0.3,-0.1-0.3,-0.2-0.3,-0.7-0.2,-1.2 0.3,-5.9-0.1,-11.9-0.1,-18z"
|
||||||
/>
|
/>
|
||||||
<path
|
<path
|
||||||
className="gotify-st2"
|
className="gotify-st2"
|
||||||
d="m378.7,236.8c-1.4,0.4-2.5,2-2.8,4.4-0.5,4.4-0.7,8.9-0.5,13.4 0,0.9 0.1,1.9 0.5,2.4 0.2,0.3 0.5,0.4 0.8,0.4 1.6,0.3 4.1,-0.6 5.6,-1 0,0 0,-5.2-0.1,-8-0.1,-2.8-0.1,-6.1-0.2,-8.9 0,-0.6 0,-1.5 0,-2.2 0.1,-0.7-2.6,-0.7-3.3,-0.5z"
|
d="m378.7,236.8c-1.4,0.4-2.5,2-2.8,4.4-0.5,4.4-0.7,8.9-0.5,13.4 0,0.9 0.1,1.9 0.5,2.4 0.2,0.3 0.5,0.4 0.8,0.4 1.6,0.3 4.1,-0.6 5.6,-1 0,0 0,-5.2-0.1,-8-0.1,-2.8-0.1,-6.1-0.2,-8.9 0,-0.6 0,-1.5 0,-2.2 0.1,-0.7-2.6,-0.7-3.3,-0.5z"
|
||||||
/>
|
/>
|
||||||
<path
|
<path
|
||||||
className="gotify-st0"
|
className="gotify-st0"
|
||||||
d="m358.3,231.8c-0.3,2.2 0.1,4.7 1.7,7.4 2.6,4.4 7,6.1 11.9,5.8 8.9,-0.6 25.3,-5.4 27.5,-15.7 0.6,-3-0.3,-6.1-2.2,-8.5-6.2,-7.8-17.8,-5.7-25.6,-2-5.9,2.7-12.4,7-13.3,13z"
|
d="m358.3,231.8c-0.3,2.2 0.1,4.7 1.7,7.4 2.6,4.4 7,6.1 11.9,5.8 8.9,-0.6 25.3,-5.4 27.5,-15.7 0.6,-3-0.3,-6.1-2.2,-8.5-6.2,-7.8-17.8,-5.7-25.6,-2-5.9,2.7-12.4,7-13.3,13z"
|
||||||
/>
|
/>
|
||||||
<path
|
<path
|
||||||
className="gotify-st3"
|
className="gotify-st3"
|
||||||
d="m386.4,208.6c2.2,1.4 3.7,3.8 4,7 0.3,3.6-1.4,7.5-5,8.8-2.9,1.1-6.2,0.6-9.1,-0.4-2.9,-1-5.8,-2.8-6.8,-5.7-0.7,-2-0.3,-4.3 0.7,-6.1 1.1,-1.8 2.8,-3.2 4.7,-4.1 3.9,-1.8 8.4,-1.6 11.5,0.5z"
|
d="m386.4,208.6c2.2,1.4 3.7,3.8 4,7 0.3,3.6-1.4,7.5-5,8.8-2.9,1.1-6.2,0.6-9.1,-0.4-2.9,-1-5.8,-2.8-6.8,-5.7-0.7,-2-0.3,-4.3 0.7,-6.1 1.1,-1.8 2.8,-3.2 4.7,-4.1 3.9,-1.8 8.4,-1.6 11.5,0.5z"
|
||||||
/>
|
/>
|
||||||
<path
|
<path
|
||||||
className="gotify-st0"
|
className="gotify-st0"
|
||||||
d="m414.7,262.6c2.4,0.6 4.8,2.1 5.6,4.4 0.8,2.3 0.1,4.9-1.6,6.7-1.7,1.8-4.2,2.5-6.6,2.5-0.8,0-1.7,-0.1-2.4,-0.5-2.5,-1.1-3.5,-4-4.2,-6.6-1.8,-6.8 3.6,-7.8 9.2,-6.5z"
|
d="m414.7,262.6c2.4,0.6 4.8,2.1 5.6,4.4 0.8,2.3 0.1,4.9-1.6,6.7-1.7,1.8-4.2,2.5-6.6,2.5-0.8,0-1.7,-0.1-2.4,-0.5-2.5,-1.1-3.5,-4-4.2,-6.6-1.8,-6.8 3.6,-7.8 9.2,-6.5z"
|
||||||
/>
|
/>
|
||||||
<path
|
<path
|
||||||
className="gotify-st4"
|
className="gotify-st4"
|
||||||
d="m267.1,284.7c2.3,-4.5 141.3,-36.2 144.7,-31.6 3.4,4.5 15.8,88.2 9,90.4-6.8,2.3-119.8,37.3-126.6,35-6.8,-2.3-29.4,-89.3-27.1,-93.8z"
|
d="m267.1,284.7c2.3,-4.5 141.3,-36.2 144.7,-31.6 3.4,4.5 15.8,88.2 9,90.4-6.8,2.3-119.8,37.3-126.6,35-6.8,-2.3-29.4,-89.3-27.1,-93.8z"
|
||||||
/>
|
/>
|
||||||
<path
|
<path
|
||||||
className="gotify-st5"
|
className="gotify-st5"
|
||||||
d="m294.2,378.5c0,0 54.3,-74.6 59.9,-76.9 5.7,-2.3 67.3,41.3 67.3,41.3"
|
d="m294.2,378.5c0,0 54.3,-74.6 59.9,-76.9 5.7,-2.3 67.3,41.3 67.3,41.3"
|
||||||
/>
|
/>
|
||||||
<path
|
<path
|
||||||
className="gotify-st4"
|
className="gotify-st4"
|
||||||
d="m267,287.7c0,0 86,38.8 91.6,36.6 5.7,-2.3 53.1,-71.2 53.1,-71.2"
|
d="m267,287.7c0,0 86,38.8 91.6,36.6 5.7,-2.3 53.1,-71.2 53.1,-71.2"
|
||||||
/>
|
/>
|
||||||
<path
|
<path
|
||||||
fill="url(#gotify-gradient)"
|
fill="url(#gotify-gradient)"
|
||||||
d="m261.9,283.5c-0.1,4.2 4.3,7.3 8.4,7.6 4.1,0.3 8.2,-1.3 12.2,-2.6 1.4,-0.4 2.9,-0.8 4.2,-0.2 1.8,0.9 2.7,4.1 1.8,5.9-0.9,1.8-3.4,3.5-5.3,4.4-6.5,3-12.9,3.6-19.9,2-5.3,-1.2-11.3,-4.3-13,-13.5"
|
d="m261.9,283.5c-0.1,4.2 4.3,7.3 8.4,7.6 4.1,0.3 8.2,-1.3 12.2,-2.6 1.4,-0.4 2.9,-0.8 4.2,-0.2 1.8,0.9 2.7,4.1 1.8,5.9-0.9,1.8-3.4,3.5-5.3,4.4-6.5,3-12.9,3.6-19.9,2-5.3,-1.2-11.3,-4.3-13,-13.5"
|
||||||
/>
|
/>
|
||||||
<path d="m318.4,198.4c-2,-0.3-4.1,0.1-5.9,1.3-3.2,2.1-4.7,6.2-4.7,9.9 0,1.9 0.4,3.8 1.4,5.3 1.2,1.7 3.1,2.9 5.2,3.4 3.4,0.8 8.2,0.7 10.5,-2.5 1,-1.5 1.4,-3.3 1.5,-5.1 0.5,-5.7-1.8,-11.4-8,-12.3z" />
|
<path d="m318.4,198.4c-2,-0.3-4.1,0.1-5.9,1.3-3.2,2.1-4.7,6.2-4.7,9.9 0,1.9 0.4,3.8 1.4,5.3 1.2,1.7 3.1,2.9 5.2,3.4 3.4,0.8 8.2,0.7 10.5,-2.5 1,-1.5 1.4,-3.3 1.5,-5.1 0.5,-5.7-1.8,-11.4-8,-12.3z" />
|
||||||
<path
|
<path
|
||||||
className="gotify-st8"
|
className="gotify-st8"
|
||||||
d="m320.4,203.3c0.9,0.3 1.7,0.8 2.1,1.7 0.4,0.8 0.4,1.7 0.3,2.5-0.1,1-0.6,2-1.5,2.7-0.7,0.5-1.7,0.7-2.6,0.5-0.9,-0.2-1.7,-0.8-2.2,-1.6-1.1,-1.6-0.9,-4.4 0.9,-5.5 0.9,-0.4 2,-0.6 3,-0.3z"
|
d="m320.4,203.3c0.9,0.3 1.7,0.8 2.1,1.7 0.4,0.8 0.4,1.7 0.3,2.5-0.1,1-0.6,2-1.5,2.7-0.7,0.5-1.7,0.7-2.6,0.5-0.9,-0.2-1.7,-0.8-2.2,-1.6-1.1,-1.6-0.9,-4.4 0.9,-5.5 0.9,-0.4 2,-0.6 3,-0.3z"
|
||||||
/>
|
/>
|
||||||
</g>
|
</g>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const NtfyIcon = ({ className }: Props) => {
|
export const NtfyIcon = ({ className }: Props) => {
|
||||||
return (
|
return (
|
||||||
<svg
|
<svg
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
className={cn("size-8", className)}
|
className={cn("size-8", className)}
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
fill="currentColor"
|
fill="currentColor"
|
||||||
d="M12.597 13.693v2.156h6.205v-2.156ZM5.183 6.549v2.363l3.591 1.901 0.023 0.01 -0.023 0.009 -3.591 1.901v2.35l0.386 -0.211 5.456 -2.969V9.729ZM3.659 2.037C1.915 2.037 0.42 3.41 0.42 5.154v0.002L0.438 18.73 0 21.963l5.956 -1.583h14.806c1.744 0 3.238 -1.374 3.238 -3.118V5.154c0 -1.744 -1.493 -3.116 -3.237 -3.117h-0.001zm0 2.2h17.104c0.613 0.001 1.037 0.447 1.037 0.917v12.108c0 0.47 -0.424 0.916 -1.038 0.916H5.633l-3.026 0.915 0.031 -0.179 -0.017 -13.76c0 -0.47 0.424 -0.917 1.038 -0.917z"
|
d="M12.597 13.693v2.156h6.205v-2.156ZM5.183 6.549v2.363l3.591 1.901 0.023 0.01 -0.023 0.009 -3.591 1.901v2.35l0.386 -0.211 5.456 -2.969V9.729ZM3.659 2.037C1.915 2.037 0.42 3.41 0.42 5.154v0.002L0.438 18.73 0 21.963l5.956 -1.583h14.806c1.744 0 3.238 -1.374 3.238 -3.118V5.154c0 -1.744 -1.493 -3.116 -3.237 -3.117h-0.001zm0 2.2h17.104c0.613 0.001 1.037 0.447 1.037 0.917v12.108c0 0.47 -0.424 0.916 -1.038 0.916H5.633l-3.026 0.915 0.031 -0.179 -0.017 -13.76c0 -0.47 0.424 -0.917 1.038 -0.917z"
|
||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PushoverIcon = ({ className }: Props) => {
|
export const PushoverIcon = ({ className }: Props) => {
|
||||||
return (
|
return (
|
||||||
<svg
|
<svg
|
||||||
@@ -257,3 +257,23 @@ export const PushoverIcon = ({ className }: Props) => {
|
|||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const ResendIcon = ({ className }: Props) => {
|
||||||
|
return (
|
||||||
|
<svg
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
className={cn("size-8", className)}
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<circle cx="12" cy="12" r="10" fill="currentColor" opacity="0.12" />
|
||||||
|
<path
|
||||||
|
d="M8 17V7h6a3 3 0 0 1 0 6H8m6 0 2 4"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth="1.6"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
fill="none"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
ALTER TYPE "public"."notificationType" ADD VALUE 'resend' BEFORE 'gotify';--> statement-breakpoint
|
||||||
|
CREATE TABLE "resend" (
|
||||||
|
"resendId" text PRIMARY KEY NOT NULL,
|
||||||
|
"apiKey" text NOT NULL,
|
||||||
|
"fromAddress" text NOT NULL,
|
||||||
|
"toAddress" text[] NOT NULL
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "notification" ADD COLUMN "resendId" text;--> statement-breakpoint
|
||||||
|
ALTER TABLE "notification" ADD CONSTRAINT "notification_resendId_resend_resendId_fk" FOREIGN KEY ("resendId") REFERENCES "public"."resend"("resendId") ON DELETE cascade ON UPDATE no action;
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -960,6 +960,13 @@
|
|||||||
"when": 1769580434296,
|
"when": 1769580434296,
|
||||||
"tag": "0136_tidy_puff_adder",
|
"tag": "0136_tidy_puff_adder",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 137,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1769595469101,
|
||||||
|
"tag": "0137_worried_shriek",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,7 @@ import {
|
|||||||
IS_CLOUD,
|
IS_CLOUD,
|
||||||
removeUserById,
|
removeUserById,
|
||||||
sendEmailNotification,
|
sendEmailNotification,
|
||||||
|
sendResendNotification,
|
||||||
updateUser,
|
updateUser,
|
||||||
} from "@dokploy/server";
|
} from "@dokploy/server";
|
||||||
import { db } from "@dokploy/server/db";
|
import { db } from "@dokploy/server/db";
|
||||||
@@ -509,15 +510,16 @@ export const userRouter = createTRPCRouter({
|
|||||||
const notification = await findNotificationById(input.notificationId);
|
const notification = await findNotificationById(input.notificationId);
|
||||||
|
|
||||||
const email = notification.email;
|
const email = notification.email;
|
||||||
|
const resend = notification.resend;
|
||||||
|
|
||||||
const currentInvitation = await db.query.invitation.findFirst({
|
const currentInvitation = await db.query.invitation.findFirst({
|
||||||
where: eq(invitation.id, input.invitationId),
|
where: eq(invitation.id, input.invitationId),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!email) {
|
if (!email && !resend) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "NOT_FOUND",
|
code: "NOT_FOUND",
|
||||||
message: "Email notification not found",
|
message: "Email provider not found",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -532,16 +534,29 @@ export const userRouter = createTRPCRouter({
|
|||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await sendEmailNotification(
|
const htmlContent = `
|
||||||
{
|
\t\t\t\t<p>You are invited to join ${organization?.name || "organization"} on Dokploy. Click the link to accept the invitation: <a href="${inviteLink}">Accept Invitation</a></p>
|
||||||
...email,
|
\t\t\t\t`;
|
||||||
toAddresses: [currentInvitation?.email || ""],
|
|
||||||
},
|
if (email) {
|
||||||
"Invitation to join organization",
|
await sendEmailNotification(
|
||||||
`
|
{
|
||||||
<p>You are invited to join ${organization?.name || "organization"} on Dokploy. Click the link to accept the invitation: <a href="${inviteLink}">Accept Invitation</a></p>
|
...email,
|
||||||
`,
|
toAddresses: [currentInvitation?.email || ""],
|
||||||
);
|
},
|
||||||
|
"Invitation to join organization",
|
||||||
|
htmlContent,
|
||||||
|
);
|
||||||
|
} else if (resend) {
|
||||||
|
await sendResendNotification(
|
||||||
|
{
|
||||||
|
...resend,
|
||||||
|
toAddresses: [currentInvitation?.email || ""],
|
||||||
|
},
|
||||||
|
"Invitation to join organization",
|
||||||
|
htmlContent,
|
||||||
|
);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
@@ -73,6 +73,7 @@
|
|||||||
"qrcode": "^1.5.4",
|
"qrcode": "^1.5.4",
|
||||||
"react": "18.2.0",
|
"react": "18.2.0",
|
||||||
"react-dom": "18.2.0",
|
"react-dom": "18.2.0",
|
||||||
|
"resend": "^6.0.2",
|
||||||
"shell-quote": "^1.8.1",
|
"shell-quote": "^1.8.1",
|
||||||
"slugify": "^1.6.6",
|
"slugify": "^1.6.6",
|
||||||
"ssh2": "1.15.0",
|
"ssh2": "1.15.0",
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ enum notificationType {
|
|||||||
telegram
|
telegram
|
||||||
discord
|
discord
|
||||||
email
|
email
|
||||||
|
resend
|
||||||
gotify
|
gotify
|
||||||
ntfy
|
ntfy
|
||||||
custom
|
custom
|
||||||
@@ -456,6 +457,13 @@ table email {
|
|||||||
toAddress text[] [not null]
|
toAddress text[] [not null]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table resend {
|
||||||
|
resendId text [pk, not null]
|
||||||
|
apiKey text [not null]
|
||||||
|
fromAddress text [not null]
|
||||||
|
toAddress text[] [not null]
|
||||||
|
}
|
||||||
|
|
||||||
table environment {
|
table environment {
|
||||||
environmentId text [pk, not null]
|
environmentId text [pk, not null]
|
||||||
name text [not null]
|
name text [not null]
|
||||||
@@ -695,6 +703,7 @@ table notification {
|
|||||||
telegramId text
|
telegramId text
|
||||||
discordId text
|
discordId text
|
||||||
emailId text
|
emailId text
|
||||||
|
resendId text
|
||||||
gotifyId text
|
gotifyId text
|
||||||
ntfyId text
|
ntfyId text
|
||||||
customId text
|
customId text
|
||||||
@@ -1139,6 +1148,8 @@ ref: notification.discordId - discord.discordId
|
|||||||
|
|
||||||
ref: notification.emailId - email.emailId
|
ref: notification.emailId - email.emailId
|
||||||
|
|
||||||
|
ref: notification.resendId - resend.resendId
|
||||||
|
|
||||||
ref: notification.gotifyId - gotify.gotifyId
|
ref: notification.gotifyId - gotify.gotifyId
|
||||||
|
|
||||||
ref: notification.ntfyId - ntfy.ntfyId
|
ref: notification.ntfyId - ntfy.ntfyId
|
||||||
@@ -1197,4 +1208,4 @@ ref: volume_backup.redisId - redis.redisId
|
|||||||
|
|
||||||
ref: volume_backup.composeId - compose.composeId
|
ref: volume_backup.composeId - compose.composeId
|
||||||
|
|
||||||
ref: volume_backup.destinationId - destination.destinationId
|
ref: volume_backup.destinationId - destination.destinationId
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ export const notificationType = pgEnum("notificationType", [
|
|||||||
"telegram",
|
"telegram",
|
||||||
"discord",
|
"discord",
|
||||||
"email",
|
"email",
|
||||||
|
"resend",
|
||||||
"gotify",
|
"gotify",
|
||||||
"ntfy",
|
"ntfy",
|
||||||
"pushover",
|
"pushover",
|
||||||
@@ -53,6 +54,9 @@ export const notifications = pgTable("notification", {
|
|||||||
emailId: text("emailId").references(() => email.emailId, {
|
emailId: text("emailId").references(() => email.emailId, {
|
||||||
onDelete: "cascade",
|
onDelete: "cascade",
|
||||||
}),
|
}),
|
||||||
|
resendId: text("resendId").references(() => resend.resendId, {
|
||||||
|
onDelete: "cascade",
|
||||||
|
}),
|
||||||
gotifyId: text("gotifyId").references(() => gotify.gotifyId, {
|
gotifyId: text("gotifyId").references(() => gotify.gotifyId, {
|
||||||
onDelete: "cascade",
|
onDelete: "cascade",
|
||||||
}),
|
}),
|
||||||
@@ -114,6 +118,16 @@ export const email = pgTable("email", {
|
|||||||
toAddresses: text("toAddress").array().notNull(),
|
toAddresses: text("toAddress").array().notNull(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const resend = pgTable("resend", {
|
||||||
|
resendId: text("resendId")
|
||||||
|
.notNull()
|
||||||
|
.primaryKey()
|
||||||
|
.$defaultFn(() => nanoid()),
|
||||||
|
apiKey: text("apiKey").notNull(),
|
||||||
|
fromAddress: text("fromAddress").notNull(),
|
||||||
|
toAddresses: text("toAddress").array().notNull(),
|
||||||
|
});
|
||||||
|
|
||||||
export const gotify = pgTable("gotify", {
|
export const gotify = pgTable("gotify", {
|
||||||
gotifyId: text("gotifyId")
|
gotifyId: text("gotifyId")
|
||||||
.notNull()
|
.notNull()
|
||||||
@@ -182,6 +196,10 @@ export const notificationsRelations = relations(notifications, ({ one }) => ({
|
|||||||
fields: [notifications.emailId],
|
fields: [notifications.emailId],
|
||||||
references: [email.emailId],
|
references: [email.emailId],
|
||||||
}),
|
}),
|
||||||
|
resend: one(resend, {
|
||||||
|
fields: [notifications.resendId],
|
||||||
|
references: [resend.resendId],
|
||||||
|
}),
|
||||||
gotify: one(gotify, {
|
gotify: one(gotify, {
|
||||||
fields: [notifications.gotifyId],
|
fields: [notifications.gotifyId],
|
||||||
references: [gotify.gotifyId],
|
references: [gotify.gotifyId],
|
||||||
@@ -335,6 +353,36 @@ export const apiTestEmailConnection = apiCreateEmail.pick({
|
|||||||
fromAddress: true,
|
fromAddress: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const apiCreateResend = notificationsSchema
|
||||||
|
.pick({
|
||||||
|
appBuildError: true,
|
||||||
|
databaseBackup: true,
|
||||||
|
volumeBackup: true,
|
||||||
|
dokployRestart: true,
|
||||||
|
name: true,
|
||||||
|
appDeploy: true,
|
||||||
|
dockerCleanup: true,
|
||||||
|
serverThreshold: true,
|
||||||
|
})
|
||||||
|
.extend({
|
||||||
|
apiKey: z.string().min(1),
|
||||||
|
fromAddress: z.string().min(1),
|
||||||
|
toAddresses: z.array(z.string()).min(1),
|
||||||
|
})
|
||||||
|
.required();
|
||||||
|
|
||||||
|
export const apiUpdateResend = apiCreateResend.partial().extend({
|
||||||
|
notificationId: z.string().min(1),
|
||||||
|
resendId: z.string().min(1),
|
||||||
|
organizationId: z.string().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const apiTestResendConnection = apiCreateResend.pick({
|
||||||
|
apiKey: true,
|
||||||
|
fromAddress: true,
|
||||||
|
toAddresses: true,
|
||||||
|
});
|
||||||
|
|
||||||
export const apiCreateGotify = notificationsSchema
|
export const apiCreateGotify = notificationsSchema
|
||||||
.pick({
|
.pick({
|
||||||
appBuildError: true,
|
appBuildError: true,
|
||||||
@@ -534,6 +582,7 @@ export const apiSendTest = notificationsSchema
|
|||||||
username: z.string(),
|
username: z.string(),
|
||||||
password: z.string(),
|
password: z.string(),
|
||||||
toAddresses: z.array(z.string()),
|
toAddresses: z.array(z.string()),
|
||||||
|
apiKey: z.string(),
|
||||||
serverUrl: z.string(),
|
serverUrl: z.string(),
|
||||||
topic: z.string(),
|
topic: z.string(),
|
||||||
appToken: z.string(),
|
appToken: z.string(),
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,61 +1,64 @@
|
|||||||
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 BuildFailedEmail from "@dokploy/server/emails/emails/build-failed";
|
import BuildFailedEmail from "@dokploy/server/emails/emails/build-failed";
|
||||||
import { renderAsync } from "@react-email/components";
|
import { renderAsync } from "@react-email/components";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import { and, eq } from "drizzle-orm";
|
import { and, eq } from "drizzle-orm";
|
||||||
import {
|
import {
|
||||||
sendCustomNotification,
|
sendCustomNotification,
|
||||||
sendDiscordNotification,
|
sendDiscordNotification,
|
||||||
sendEmailNotification,
|
sendEmailNotification,
|
||||||
sendGotifyNotification,
|
sendGotifyNotification,
|
||||||
sendLarkNotification,
|
sendLarkNotification,
|
||||||
sendNtfyNotification,
|
sendNtfyNotification,
|
||||||
sendPushoverNotification,
|
sendPushoverNotification,
|
||||||
|
sendResendNotification,
|
||||||
sendSlackNotification,
|
sendSlackNotification,
|
||||||
sendTelegramNotification,
|
sendTelegramNotification,
|
||||||
} from "./utils";
|
} from "./utils";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
projectName: string;
|
projectName: string;
|
||||||
applicationName: string;
|
applicationName: string;
|
||||||
applicationType: string;
|
applicationType: string;
|
||||||
errorMessage: string;
|
errorMessage: string;
|
||||||
buildLink: string;
|
buildLink: string;
|
||||||
organizationId: string;
|
organizationId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const sendBuildErrorNotifications = async ({
|
export const sendBuildErrorNotifications = async ({
|
||||||
projectName,
|
projectName,
|
||||||
applicationName,
|
applicationName,
|
||||||
applicationType,
|
applicationType,
|
||||||
errorMessage,
|
errorMessage,
|
||||||
buildLink,
|
buildLink,
|
||||||
organizationId,
|
organizationId,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
const unixDate = ~~(Number(date) / 1000);
|
const unixDate = ~~(Number(date) / 1000);
|
||||||
const notificationList = await db.query.notifications.findMany({
|
const notificationList = await db.query.notifications.findMany({
|
||||||
where: and(
|
where: and(
|
||||||
eq(notifications.appBuildError, true),
|
eq(notifications.appBuildError, true),
|
||||||
eq(notifications.organizationId, organizationId),
|
eq(notifications.organizationId, organizationId),
|
||||||
),
|
),
|
||||||
with: {
|
with: {
|
||||||
email: true,
|
email: true,
|
||||||
discord: true,
|
discord: true,
|
||||||
telegram: true,
|
telegram: true,
|
||||||
slack: true,
|
slack: true,
|
||||||
gotify: true,
|
resend: true,
|
||||||
ntfy: true,
|
gotify: true,
|
||||||
custom: true,
|
ntfy: true,
|
||||||
lark: true,
|
custom: true,
|
||||||
pushover: true,
|
lark: true,
|
||||||
},
|
pushover: true,
|
||||||
});
|
},
|
||||||
|
});
|
||||||
for (const notification of notificationList) {
|
|
||||||
|
for (const notification of notificationList) {
|
||||||
const {
|
const {
|
||||||
email,
|
email,
|
||||||
|
resend,
|
||||||
discord,
|
discord,
|
||||||
telegram,
|
telegram,
|
||||||
slack,
|
slack,
|
||||||
@@ -65,311 +68,322 @@ export const sendBuildErrorNotifications = async ({
|
|||||||
lark,
|
lark,
|
||||||
pushover,
|
pushover,
|
||||||
} = notification;
|
} = notification;
|
||||||
try {
|
try {
|
||||||
if (email) {
|
if (email || resend) {
|
||||||
const template = await renderAsync(
|
const template = await renderAsync(
|
||||||
BuildFailedEmail({
|
BuildFailedEmail({
|
||||||
projectName,
|
projectName,
|
||||||
applicationName,
|
applicationName,
|
||||||
applicationType,
|
applicationType,
|
||||||
errorMessage: errorMessage,
|
errorMessage: errorMessage,
|
||||||
buildLink,
|
buildLink,
|
||||||
date: date.toLocaleString(),
|
date: date.toLocaleString(),
|
||||||
}),
|
}),
|
||||||
).catch();
|
).catch();
|
||||||
await sendEmailNotification(
|
|
||||||
email,
|
if (email) {
|
||||||
"Build failed for dokploy",
|
await sendEmailNotification(
|
||||||
template,
|
email,
|
||||||
);
|
"Build failed for dokploy",
|
||||||
}
|
template,
|
||||||
|
);
|
||||||
if (discord) {
|
}
|
||||||
const decorate = (decoration: string, text: string) =>
|
|
||||||
`${discord.decoration ? decoration : ""} ${text}`.trim();
|
if (resend) {
|
||||||
|
await sendResendNotification(
|
||||||
const limitCharacter = 800;
|
resend,
|
||||||
const truncatedErrorMessage = errorMessage.substring(0, limitCharacter);
|
"Build failed for dokploy",
|
||||||
await sendDiscordNotification(discord, {
|
template,
|
||||||
title: decorate(">", "`⚠️` Build Failed"),
|
);
|
||||||
color: 0xed4245,
|
}
|
||||||
fields: [
|
}
|
||||||
{
|
|
||||||
name: decorate("`🛠️`", "Project"),
|
if (discord) {
|
||||||
value: projectName,
|
const decorate = (decoration: string, text: string) =>
|
||||||
inline: true,
|
`${discord.decoration ? decoration : ""} ${text}`.trim();
|
||||||
},
|
|
||||||
{
|
const limitCharacter = 800;
|
||||||
name: decorate("`⚙️`", "Application"),
|
const truncatedErrorMessage = errorMessage.substring(0, limitCharacter);
|
||||||
value: applicationName,
|
await sendDiscordNotification(discord, {
|
||||||
inline: true,
|
title: decorate(">", "`⚠️` Build Failed"),
|
||||||
},
|
color: 0xed4245,
|
||||||
{
|
fields: [
|
||||||
name: decorate("`❔`", "Type"),
|
{
|
||||||
value: applicationType,
|
name: decorate("`🛠️`", "Project"),
|
||||||
inline: true,
|
value: projectName,
|
||||||
},
|
inline: true,
|
||||||
{
|
},
|
||||||
name: decorate("`📅`", "Date"),
|
{
|
||||||
value: `<t:${unixDate}:D>`,
|
name: decorate("`⚙️`", "Application"),
|
||||||
inline: true,
|
value: applicationName,
|
||||||
},
|
inline: true,
|
||||||
{
|
},
|
||||||
name: decorate("`⌚`", "Time"),
|
{
|
||||||
value: `<t:${unixDate}:t>`,
|
name: decorate("`❔`", "Type"),
|
||||||
inline: true,
|
value: applicationType,
|
||||||
},
|
inline: true,
|
||||||
{
|
},
|
||||||
name: decorate("`❓`", "Type"),
|
{
|
||||||
value: "Failed",
|
name: decorate("`📅`", "Date"),
|
||||||
inline: true,
|
value: `<t:${unixDate}:D>`,
|
||||||
},
|
inline: true,
|
||||||
{
|
},
|
||||||
name: decorate("`⚠️`", "Error Message"),
|
{
|
||||||
value: `\`\`\`${truncatedErrorMessage}\`\`\``,
|
name: decorate("`⌚`", "Time"),
|
||||||
},
|
value: `<t:${unixDate}:t>`,
|
||||||
{
|
inline: true,
|
||||||
name: decorate("`🧷`", "Build Link"),
|
},
|
||||||
value: `[Click here to access build link](${buildLink})`,
|
{
|
||||||
},
|
name: decorate("`❓`", "Type"),
|
||||||
],
|
value: "Failed",
|
||||||
timestamp: date.toISOString(),
|
inline: true,
|
||||||
footer: {
|
},
|
||||||
text: "Dokploy Build Notification",
|
{
|
||||||
},
|
name: decorate("`⚠️`", "Error Message"),
|
||||||
});
|
value: `\`\`\`${truncatedErrorMessage}\`\`\``,
|
||||||
}
|
},
|
||||||
|
{
|
||||||
if (gotify) {
|
name: decorate("`🧷`", "Build Link"),
|
||||||
const decorate = (decoration: string, text: string) =>
|
value: `[Click here to access build link](${buildLink})`,
|
||||||
`${gotify.decoration ? decoration : ""} ${text}\n`;
|
},
|
||||||
await sendGotifyNotification(
|
],
|
||||||
gotify,
|
timestamp: date.toISOString(),
|
||||||
decorate("⚠️", "Build Failed"),
|
footer: {
|
||||||
`${decorate("🛠️", `Project: ${projectName}`)}` +
|
text: "Dokploy Build Notification",
|
||||||
`${decorate("⚙️", `Application: ${applicationName}`)}` +
|
},
|
||||||
`${decorate("❔", `Type: ${applicationType}`)}` +
|
});
|
||||||
`${decorate("🕒", `Date: ${date.toLocaleString()}`)}` +
|
}
|
||||||
`${decorate("⚠️", `Error:\n${errorMessage}`)}` +
|
|
||||||
`${decorate("🔗", `Build details:\n${buildLink}`)}`,
|
if (gotify) {
|
||||||
);
|
const decorate = (decoration: string, text: string) =>
|
||||||
}
|
`${gotify.decoration ? decoration : ""} ${text}\n`;
|
||||||
|
await sendGotifyNotification(
|
||||||
if (ntfy) {
|
gotify,
|
||||||
await sendNtfyNotification(
|
decorate("⚠️", "Build Failed"),
|
||||||
ntfy,
|
`${decorate("🛠️", `Project: ${projectName}`)}` +
|
||||||
"Build Failed",
|
`${decorate("⚙️", `Application: ${applicationName}`)}` +
|
||||||
"warning",
|
`${decorate("❔", `Type: ${applicationType}`)}` +
|
||||||
`view, Build details, ${buildLink}, clear=true;`,
|
`${decorate("🕒", `Date: ${date.toLocaleString()}`)}` +
|
||||||
`🛠️Project: ${projectName}\n` +
|
`${decorate("⚠️", `Error:\n${errorMessage}`)}` +
|
||||||
`⚙️Application: ${applicationName}\n` +
|
`${decorate("🔗", `Build details:\n${buildLink}`)}`,
|
||||||
`❔Type: ${applicationType}\n` +
|
);
|
||||||
`🕒Date: ${date.toLocaleString()}\n` +
|
}
|
||||||
`⚠️Error:\n${errorMessage}`,
|
|
||||||
);
|
if (ntfy) {
|
||||||
}
|
await sendNtfyNotification(
|
||||||
|
ntfy,
|
||||||
if (telegram) {
|
"Build Failed",
|
||||||
const inlineButton = [
|
"warning",
|
||||||
[
|
`view, Build details, ${buildLink}, clear=true;`,
|
||||||
{
|
`🛠️Project: ${projectName}\n` +
|
||||||
text: "Deployment Logs",
|
`⚙️Application: ${applicationName}\n` +
|
||||||
url: buildLink,
|
`❔Type: ${applicationType}\n` +
|
||||||
},
|
`🕒Date: ${date.toLocaleString()}\n` +
|
||||||
],
|
`⚠️Error:\n${errorMessage}`,
|
||||||
];
|
);
|
||||||
|
}
|
||||||
await sendTelegramNotification(
|
|
||||||
telegram,
|
if (telegram) {
|
||||||
`<b>⚠️ Build Failed</b>\n\n<b>Project:</b> ${projectName}\n<b>Application:</b> ${applicationName}\n<b>Type:</b> ${applicationType}\n<b>Date:</b> ${format(date, "PP")}\n<b>Time:</b> ${format(date, "pp")}\n\n<b>Error:</b>\n<pre>${errorMessage}</pre>`,
|
const inlineButton = [
|
||||||
inlineButton,
|
[
|
||||||
);
|
{
|
||||||
}
|
text: "Deployment Logs",
|
||||||
|
url: buildLink,
|
||||||
if (slack) {
|
},
|
||||||
const { channel } = slack;
|
],
|
||||||
await sendSlackNotification(slack, {
|
];
|
||||||
channel: channel,
|
|
||||||
attachments: [
|
await sendTelegramNotification(
|
||||||
{
|
telegram,
|
||||||
color: "#FF0000",
|
`<b>⚠️ Build Failed</b>\n\n<b>Project:</b> ${projectName}\n<b>Application:</b> ${applicationName}\n<b>Type:</b> ${applicationType}\n<b>Date:</b> ${format(date, "PP")}\n<b>Time:</b> ${format(date, "pp")}\n\n<b>Error:</b>\n<pre>${errorMessage}</pre>`,
|
||||||
pretext: ":warning: *Build Failed*",
|
inlineButton,
|
||||||
fields: [
|
);
|
||||||
{
|
}
|
||||||
title: "Project",
|
|
||||||
value: projectName,
|
if (slack) {
|
||||||
short: true,
|
const { channel } = slack;
|
||||||
},
|
await sendSlackNotification(slack, {
|
||||||
{
|
channel: channel,
|
||||||
title: "Application",
|
attachments: [
|
||||||
value: applicationName,
|
{
|
||||||
short: true,
|
color: "#FF0000",
|
||||||
},
|
pretext: ":warning: *Build Failed*",
|
||||||
{
|
fields: [
|
||||||
title: "Type",
|
{
|
||||||
value: applicationType,
|
title: "Project",
|
||||||
short: true,
|
value: projectName,
|
||||||
},
|
short: true,
|
||||||
{
|
},
|
||||||
title: "Time",
|
{
|
||||||
value: date.toLocaleString(),
|
title: "Application",
|
||||||
short: true,
|
value: applicationName,
|
||||||
},
|
short: true,
|
||||||
{
|
},
|
||||||
title: "Error",
|
{
|
||||||
value: `\`\`\`${errorMessage}\`\`\``,
|
title: "Type",
|
||||||
short: false,
|
value: applicationType,
|
||||||
},
|
short: true,
|
||||||
],
|
},
|
||||||
actions: [
|
{
|
||||||
{
|
title: "Time",
|
||||||
type: "button",
|
value: date.toLocaleString(),
|
||||||
text: "View Build Details",
|
short: true,
|
||||||
url: buildLink,
|
},
|
||||||
},
|
{
|
||||||
],
|
title: "Error",
|
||||||
},
|
value: `\`\`\`${errorMessage}\`\`\``,
|
||||||
],
|
short: false,
|
||||||
});
|
},
|
||||||
}
|
],
|
||||||
|
actions: [
|
||||||
if (custom) {
|
{
|
||||||
await sendCustomNotification(custom, {
|
type: "button",
|
||||||
title: "Build Error",
|
text: "View Build Details",
|
||||||
message: "Build failed with errors",
|
url: buildLink,
|
||||||
projectName,
|
},
|
||||||
applicationName,
|
],
|
||||||
applicationType,
|
},
|
||||||
errorMessage,
|
],
|
||||||
buildLink,
|
});
|
||||||
timestamp: date.toISOString(),
|
}
|
||||||
date: date.toLocaleString(),
|
|
||||||
status: "error",
|
if (custom) {
|
||||||
type: "build",
|
await sendCustomNotification(custom, {
|
||||||
});
|
title: "Build Error",
|
||||||
}
|
message: "Build failed with errors",
|
||||||
|
projectName,
|
||||||
if (lark) {
|
applicationName,
|
||||||
const limitCharacter = 800;
|
applicationType,
|
||||||
const truncatedErrorMessage = errorMessage.substring(0, limitCharacter);
|
errorMessage,
|
||||||
await sendLarkNotification(lark, {
|
buildLink,
|
||||||
msg_type: "interactive",
|
timestamp: date.toISOString(),
|
||||||
card: {
|
date: date.toLocaleString(),
|
||||||
schema: "2.0",
|
status: "error",
|
||||||
config: {
|
type: "build",
|
||||||
update_multi: true,
|
});
|
||||||
style: {
|
}
|
||||||
text_size: {
|
|
||||||
normal_v2: {
|
if (lark) {
|
||||||
default: "normal",
|
const limitCharacter = 800;
|
||||||
pc: "normal",
|
const truncatedErrorMessage = errorMessage.substring(0, limitCharacter);
|
||||||
mobile: "heading",
|
await sendLarkNotification(lark, {
|
||||||
},
|
msg_type: "interactive",
|
||||||
},
|
card: {
|
||||||
},
|
schema: "2.0",
|
||||||
},
|
config: {
|
||||||
header: {
|
update_multi: true,
|
||||||
title: {
|
style: {
|
||||||
tag: "plain_text",
|
text_size: {
|
||||||
content: "⚠️ Build Failed",
|
normal_v2: {
|
||||||
},
|
default: "normal",
|
||||||
subtitle: {
|
pc: "normal",
|
||||||
tag: "plain_text",
|
mobile: "heading",
|
||||||
content: "",
|
},
|
||||||
},
|
},
|
||||||
template: "red",
|
},
|
||||||
padding: "12px 12px 12px 12px",
|
},
|
||||||
},
|
header: {
|
||||||
body: {
|
title: {
|
||||||
direction: "vertical",
|
tag: "plain_text",
|
||||||
padding: "12px 12px 12px 12px",
|
content: "⚠️ Build Failed",
|
||||||
elements: [
|
},
|
||||||
{
|
subtitle: {
|
||||||
tag: "column_set",
|
tag: "plain_text",
|
||||||
columns: [
|
content: "",
|
||||||
{
|
},
|
||||||
tag: "column",
|
template: "red",
|
||||||
width: "weighted",
|
padding: "12px 12px 12px 12px",
|
||||||
elements: [
|
},
|
||||||
{
|
body: {
|
||||||
tag: "markdown",
|
direction: "vertical",
|
||||||
content: `**Project:**\n${projectName}`,
|
padding: "12px 12px 12px 12px",
|
||||||
text_align: "left",
|
elements: [
|
||||||
text_size: "normal_v2",
|
{
|
||||||
},
|
tag: "column_set",
|
||||||
{
|
columns: [
|
||||||
tag: "markdown",
|
{
|
||||||
content: `**Type:**\n${applicationType}`,
|
tag: "column",
|
||||||
text_align: "left",
|
width: "weighted",
|
||||||
text_size: "normal_v2",
|
elements: [
|
||||||
},
|
{
|
||||||
{
|
tag: "markdown",
|
||||||
tag: "markdown",
|
content: `**Project:**\n${projectName}`,
|
||||||
content: `**Error Message:**\n\`\`\`\n${truncatedErrorMessage}\n\`\`\``,
|
text_align: "left",
|
||||||
text_align: "left",
|
text_size: "normal_v2",
|
||||||
text_size: "normal_v2",
|
},
|
||||||
},
|
{
|
||||||
],
|
tag: "markdown",
|
||||||
vertical_align: "top",
|
content: `**Type:**\n${applicationType}`,
|
||||||
weight: 1,
|
text_align: "left",
|
||||||
},
|
text_size: "normal_v2",
|
||||||
{
|
},
|
||||||
tag: "column",
|
{
|
||||||
width: "weighted",
|
tag: "markdown",
|
||||||
elements: [
|
content: `**Error Message:**\n\`\`\`\n${truncatedErrorMessage}\n\`\`\``,
|
||||||
{
|
text_align: "left",
|
||||||
tag: "markdown",
|
text_size: "normal_v2",
|
||||||
content: `**Application:**\n${applicationName}`,
|
},
|
||||||
text_align: "left",
|
],
|
||||||
text_size: "normal_v2",
|
vertical_align: "top",
|
||||||
},
|
weight: 1,
|
||||||
{
|
},
|
||||||
tag: "markdown",
|
{
|
||||||
content: `**Date:**\n${format(date, "PP pp")}`,
|
tag: "column",
|
||||||
text_align: "left",
|
width: "weighted",
|
||||||
text_size: "normal_v2",
|
elements: [
|
||||||
},
|
{
|
||||||
],
|
tag: "markdown",
|
||||||
vertical_align: "top",
|
content: `**Application:**\n${applicationName}`,
|
||||||
weight: 1,
|
text_align: "left",
|
||||||
},
|
text_size: "normal_v2",
|
||||||
],
|
},
|
||||||
},
|
{
|
||||||
{
|
tag: "markdown",
|
||||||
tag: "button",
|
content: `**Date:**\n${format(date, "PP pp")}`,
|
||||||
text: {
|
text_align: "left",
|
||||||
tag: "plain_text",
|
text_size: "normal_v2",
|
||||||
content: "View Build Details",
|
},
|
||||||
},
|
],
|
||||||
type: "danger",
|
vertical_align: "top",
|
||||||
width: "default",
|
weight: 1,
|
||||||
size: "medium",
|
},
|
||||||
behaviors: [
|
],
|
||||||
{
|
},
|
||||||
type: "open_url",
|
{
|
||||||
default_url: buildLink,
|
tag: "button",
|
||||||
pc_url: "",
|
text: {
|
||||||
ios_url: "",
|
tag: "plain_text",
|
||||||
android_url: "",
|
content: "View Build Details",
|
||||||
},
|
},
|
||||||
],
|
type: "danger",
|
||||||
margin: "0px 0px 0px 0px",
|
width: "default",
|
||||||
},
|
size: "medium",
|
||||||
],
|
behaviors: [
|
||||||
},
|
{
|
||||||
},
|
type: "open_url",
|
||||||
});
|
default_url: buildLink,
|
||||||
}
|
pc_url: "",
|
||||||
|
ios_url: "",
|
||||||
if (pushover) {
|
android_url: "",
|
||||||
await sendPushoverNotification(
|
},
|
||||||
pushover,
|
],
|
||||||
"Build Failed",
|
margin: "0px 0px 0px 0px",
|
||||||
`Project: ${projectName}\nApplication: ${applicationName}\nType: ${applicationType}\nDate: ${date.toLocaleString()}\nError: ${errorMessage}`,
|
},
|
||||||
);
|
],
|
||||||
}
|
},
|
||||||
} catch (error) {
|
},
|
||||||
console.log(error);
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
if (pushover) {
|
||||||
|
await sendPushoverNotification(
|
||||||
|
pushover,
|
||||||
|
"Build Failed",
|
||||||
|
`Project: ${projectName}\nApplication: ${applicationName}\nType: ${applicationType}\nDate: ${date.toLocaleString()}\nError: ${errorMessage}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,64 +1,67 @@
|
|||||||
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 BuildSuccessEmail from "@dokploy/server/emails/emails/build-success";
|
import BuildSuccessEmail from "@dokploy/server/emails/emails/build-success";
|
||||||
import type { Domain } from "@dokploy/server/services/domain";
|
import type { Domain } from "@dokploy/server/services/domain";
|
||||||
import { renderAsync } from "@react-email/components";
|
import { renderAsync } from "@react-email/components";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import { and, eq } from "drizzle-orm";
|
import { and, eq } from "drizzle-orm";
|
||||||
import {
|
import {
|
||||||
sendCustomNotification,
|
sendCustomNotification,
|
||||||
sendDiscordNotification,
|
sendDiscordNotification,
|
||||||
sendEmailNotification,
|
sendEmailNotification,
|
||||||
sendGotifyNotification,
|
sendGotifyNotification,
|
||||||
sendLarkNotification,
|
sendLarkNotification,
|
||||||
sendNtfyNotification,
|
sendNtfyNotification,
|
||||||
sendPushoverNotification,
|
sendPushoverNotification,
|
||||||
|
sendResendNotification,
|
||||||
sendSlackNotification,
|
sendSlackNotification,
|
||||||
sendTelegramNotification,
|
sendTelegramNotification,
|
||||||
} from "./utils";
|
} from "./utils";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
projectName: string;
|
projectName: string;
|
||||||
applicationName: string;
|
applicationName: string;
|
||||||
applicationType: string;
|
applicationType: string;
|
||||||
buildLink: string;
|
buildLink: string;
|
||||||
organizationId: string;
|
organizationId: string;
|
||||||
domains: Domain[];
|
domains: Domain[];
|
||||||
environmentName: string;
|
environmentName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const sendBuildSuccessNotifications = async ({
|
export const sendBuildSuccessNotifications = async ({
|
||||||
projectName,
|
projectName,
|
||||||
applicationName,
|
applicationName,
|
||||||
applicationType,
|
applicationType,
|
||||||
buildLink,
|
buildLink,
|
||||||
organizationId,
|
organizationId,
|
||||||
domains,
|
domains,
|
||||||
environmentName,
|
environmentName,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
const unixDate = ~~(Number(date) / 1000);
|
const unixDate = ~~(Number(date) / 1000);
|
||||||
const notificationList = await db.query.notifications.findMany({
|
const notificationList = await db.query.notifications.findMany({
|
||||||
where: and(
|
where: and(
|
||||||
eq(notifications.appDeploy, true),
|
eq(notifications.appDeploy, true),
|
||||||
eq(notifications.organizationId, organizationId),
|
eq(notifications.organizationId, organizationId),
|
||||||
),
|
),
|
||||||
with: {
|
with: {
|
||||||
email: true,
|
email: true,
|
||||||
discord: true,
|
discord: true,
|
||||||
telegram: true,
|
telegram: true,
|
||||||
slack: true,
|
slack: true,
|
||||||
gotify: true,
|
resend: true,
|
||||||
ntfy: true,
|
gotify: true,
|
||||||
custom: true,
|
ntfy: true,
|
||||||
lark: true,
|
custom: true,
|
||||||
pushover: true,
|
lark: true,
|
||||||
},
|
pushover: true,
|
||||||
});
|
},
|
||||||
|
});
|
||||||
for (const notification of notificationList) {
|
|
||||||
|
for (const notification of notificationList) {
|
||||||
const {
|
const {
|
||||||
email,
|
email,
|
||||||
|
resend,
|
||||||
discord,
|
discord,
|
||||||
telegram,
|
telegram,
|
||||||
slack,
|
slack,
|
||||||
@@ -68,322 +71,333 @@ export const sendBuildSuccessNotifications = async ({
|
|||||||
lark,
|
lark,
|
||||||
pushover,
|
pushover,
|
||||||
} = notification;
|
} = notification;
|
||||||
try {
|
try {
|
||||||
if (email) {
|
if (email || resend) {
|
||||||
const template = await renderAsync(
|
const template = await renderAsync(
|
||||||
BuildSuccessEmail({
|
BuildSuccessEmail({
|
||||||
projectName,
|
projectName,
|
||||||
applicationName,
|
applicationName,
|
||||||
applicationType,
|
applicationType,
|
||||||
buildLink,
|
buildLink,
|
||||||
date: date.toLocaleString(),
|
date: date.toLocaleString(),
|
||||||
environmentName,
|
environmentName,
|
||||||
}),
|
}),
|
||||||
).catch();
|
).catch();
|
||||||
await sendEmailNotification(
|
|
||||||
email,
|
if (email) {
|
||||||
"Build success for dokploy",
|
await sendEmailNotification(
|
||||||
template,
|
email,
|
||||||
);
|
"Build success for dokploy",
|
||||||
}
|
template,
|
||||||
|
);
|
||||||
if (discord) {
|
}
|
||||||
const decorate = (decoration: string, text: string) =>
|
|
||||||
`${discord.decoration ? decoration : ""} ${text}`.trim();
|
if (resend) {
|
||||||
|
await sendResendNotification(
|
||||||
await sendDiscordNotification(discord, {
|
resend,
|
||||||
title: decorate(">", "`✅` Build Successes"),
|
"Build success for dokploy",
|
||||||
color: 0x57f287,
|
template,
|
||||||
fields: [
|
);
|
||||||
{
|
}
|
||||||
name: decorate("`🛠️`", "Project"),
|
}
|
||||||
value: projectName,
|
|
||||||
inline: true,
|
if (discord) {
|
||||||
},
|
const decorate = (decoration: string, text: string) =>
|
||||||
{
|
`${discord.decoration ? decoration : ""} ${text}`.trim();
|
||||||
name: decorate("`⚙️`", "Application"),
|
|
||||||
value: applicationName,
|
await sendDiscordNotification(discord, {
|
||||||
inline: true,
|
title: decorate(">", "`✅` Build Successes"),
|
||||||
},
|
color: 0x57f287,
|
||||||
{
|
fields: [
|
||||||
name: decorate("`🌍`", "Environment"),
|
{
|
||||||
value: environmentName,
|
name: decorate("`🛠️`", "Project"),
|
||||||
inline: true,
|
value: projectName,
|
||||||
},
|
inline: true,
|
||||||
{
|
},
|
||||||
name: decorate("`❔`", "Type"),
|
{
|
||||||
value: applicationType,
|
name: decorate("`⚙️`", "Application"),
|
||||||
inline: true,
|
value: applicationName,
|
||||||
},
|
inline: true,
|
||||||
{
|
},
|
||||||
name: decorate("`📅`", "Date"),
|
{
|
||||||
value: `<t:${unixDate}:D>`,
|
name: decorate("`🌍`", "Environment"),
|
||||||
inline: true,
|
value: environmentName,
|
||||||
},
|
inline: true,
|
||||||
{
|
},
|
||||||
name: decorate("`⌚`", "Time"),
|
{
|
||||||
value: `<t:${unixDate}:t>`,
|
name: decorate("`❔`", "Type"),
|
||||||
inline: true,
|
value: applicationType,
|
||||||
},
|
inline: true,
|
||||||
{
|
},
|
||||||
name: decorate("`❓`", "Type"),
|
{
|
||||||
value: "Successful",
|
name: decorate("`📅`", "Date"),
|
||||||
inline: true,
|
value: `<t:${unixDate}:D>`,
|
||||||
},
|
inline: true,
|
||||||
{
|
},
|
||||||
name: decorate("`🧷`", "Build Link"),
|
{
|
||||||
value: `[Click here to access build link](${buildLink})`,
|
name: decorate("`⌚`", "Time"),
|
||||||
},
|
value: `<t:${unixDate}:t>`,
|
||||||
],
|
inline: true,
|
||||||
timestamp: date.toISOString(),
|
},
|
||||||
footer: {
|
{
|
||||||
text: "Dokploy Build Notification",
|
name: decorate("`❓`", "Type"),
|
||||||
},
|
value: "Successful",
|
||||||
});
|
inline: true,
|
||||||
}
|
},
|
||||||
|
{
|
||||||
if (gotify) {
|
name: decorate("`🧷`", "Build Link"),
|
||||||
const decorate = (decoration: string, text: string) =>
|
value: `[Click here to access build link](${buildLink})`,
|
||||||
`${gotify.decoration ? decoration : ""} ${text}\n`;
|
},
|
||||||
await sendGotifyNotification(
|
],
|
||||||
gotify,
|
timestamp: date.toISOString(),
|
||||||
decorate("✅", "Build Success"),
|
footer: {
|
||||||
`${decorate("🛠️", `Project: ${projectName}`)}` +
|
text: "Dokploy Build Notification",
|
||||||
`${decorate("⚙️", `Application: ${applicationName}`)}` +
|
},
|
||||||
`${decorate("🌍", `Environment: ${environmentName}`)}` +
|
});
|
||||||
`${decorate("❔", `Type: ${applicationType}`)}` +
|
}
|
||||||
`${decorate("🕒", `Date: ${date.toLocaleString()}`)}` +
|
|
||||||
`${decorate("🔗", `Build details:\n${buildLink}`)}`,
|
if (gotify) {
|
||||||
);
|
const decorate = (decoration: string, text: string) =>
|
||||||
}
|
`${gotify.decoration ? decoration : ""} ${text}\n`;
|
||||||
|
await sendGotifyNotification(
|
||||||
if (ntfy) {
|
gotify,
|
||||||
await sendNtfyNotification(
|
decorate("✅", "Build Success"),
|
||||||
ntfy,
|
`${decorate("🛠️", `Project: ${projectName}`)}` +
|
||||||
"Build Success",
|
`${decorate("⚙️", `Application: ${applicationName}`)}` +
|
||||||
"white_check_mark",
|
`${decorate("🌍", `Environment: ${environmentName}`)}` +
|
||||||
`view, Build details, ${buildLink}, clear=true;`,
|
`${decorate("❔", `Type: ${applicationType}`)}` +
|
||||||
`🛠Project: ${projectName}\n` +
|
`${decorate("🕒", `Date: ${date.toLocaleString()}`)}` +
|
||||||
`⚙️Application: ${applicationName}\n` +
|
`${decorate("🔗", `Build details:\n${buildLink}`)}`,
|
||||||
`🌍Environment: ${environmentName}\n` +
|
);
|
||||||
`❔Type: ${applicationType}\n` +
|
}
|
||||||
`🕒Date: ${date.toLocaleString()}`,
|
|
||||||
);
|
if (ntfy) {
|
||||||
}
|
await sendNtfyNotification(
|
||||||
|
ntfy,
|
||||||
if (telegram) {
|
"Build Success",
|
||||||
const chunkArray = <T>(array: T[], chunkSize: number): T[][] =>
|
"white_check_mark",
|
||||||
Array.from({ length: Math.ceil(array.length / chunkSize) }, (_, i) =>
|
`view, Build details, ${buildLink}, clear=true;`,
|
||||||
array.slice(i * chunkSize, i * chunkSize + chunkSize),
|
`🛠Project: ${projectName}\n` +
|
||||||
);
|
`⚙️Application: ${applicationName}\n` +
|
||||||
|
`🌍Environment: ${environmentName}\n` +
|
||||||
const inlineButton = [
|
`❔Type: ${applicationType}\n` +
|
||||||
[
|
`🕒Date: ${date.toLocaleString()}`,
|
||||||
{
|
);
|
||||||
text: "Deployment Logs",
|
}
|
||||||
url: buildLink,
|
|
||||||
},
|
if (telegram) {
|
||||||
],
|
const chunkArray = <T>(array: T[], chunkSize: number): T[][] =>
|
||||||
...chunkArray(domains, 2).map((chunk) =>
|
Array.from({ length: Math.ceil(array.length / chunkSize) }, (_, i) =>
|
||||||
chunk.map((data) => ({
|
array.slice(i * chunkSize, i * chunkSize + chunkSize),
|
||||||
text: data.host,
|
);
|
||||||
url: `${data.https ? "https" : "http"}://${data.host}`,
|
|
||||||
})),
|
const inlineButton = [
|
||||||
),
|
[
|
||||||
];
|
{
|
||||||
|
text: "Deployment Logs",
|
||||||
await sendTelegramNotification(
|
url: buildLink,
|
||||||
telegram,
|
},
|
||||||
`<b>✅ Build Success</b>\n\n<b>Project:</b> ${projectName}\n<b>Application:</b> ${applicationName}\n<b>Environment:</b> ${environmentName}\n<b>Type:</b> ${applicationType}\n<b>Date:</b> ${format(
|
],
|
||||||
date,
|
...chunkArray(domains, 2).map((chunk) =>
|
||||||
"PP",
|
chunk.map((data) => ({
|
||||||
)}\n<b>Time:</b> ${format(date, "pp")}`,
|
text: data.host,
|
||||||
inlineButton,
|
url: `${data.https ? "https" : "http"}://${data.host}`,
|
||||||
);
|
})),
|
||||||
}
|
),
|
||||||
|
];
|
||||||
if (slack) {
|
|
||||||
const { channel } = slack;
|
await sendTelegramNotification(
|
||||||
await sendSlackNotification(slack, {
|
telegram,
|
||||||
channel: channel,
|
`<b>✅ Build Success</b>\n\n<b>Project:</b> ${projectName}\n<b>Application:</b> ${applicationName}\n<b>Environment:</b> ${environmentName}\n<b>Type:</b> ${applicationType}\n<b>Date:</b> ${format(
|
||||||
attachments: [
|
date,
|
||||||
{
|
"PP",
|
||||||
color: "#00FF00",
|
)}\n<b>Time:</b> ${format(date, "pp")}`,
|
||||||
pretext: ":white_check_mark: *Build Success*",
|
inlineButton,
|
||||||
fields: [
|
);
|
||||||
{
|
}
|
||||||
title: "Project",
|
|
||||||
value: projectName,
|
if (slack) {
|
||||||
short: true,
|
const { channel } = slack;
|
||||||
},
|
await sendSlackNotification(slack, {
|
||||||
{
|
channel: channel,
|
||||||
title: "Application",
|
attachments: [
|
||||||
value: applicationName,
|
{
|
||||||
short: true,
|
color: "#00FF00",
|
||||||
},
|
pretext: ":white_check_mark: *Build Success*",
|
||||||
{
|
fields: [
|
||||||
title: "Environment",
|
{
|
||||||
value: environmentName,
|
title: "Project",
|
||||||
short: true,
|
value: projectName,
|
||||||
},
|
short: true,
|
||||||
{
|
},
|
||||||
title: "Type",
|
{
|
||||||
value: applicationType,
|
title: "Application",
|
||||||
short: true,
|
value: applicationName,
|
||||||
},
|
short: true,
|
||||||
{
|
},
|
||||||
title: "Time",
|
{
|
||||||
value: date.toLocaleString(),
|
title: "Environment",
|
||||||
short: true,
|
value: environmentName,
|
||||||
},
|
short: true,
|
||||||
],
|
},
|
||||||
actions: [
|
{
|
||||||
{
|
title: "Type",
|
||||||
type: "button",
|
value: applicationType,
|
||||||
text: "View Build Details",
|
short: true,
|
||||||
url: buildLink,
|
},
|
||||||
},
|
{
|
||||||
],
|
title: "Time",
|
||||||
},
|
value: date.toLocaleString(),
|
||||||
],
|
short: true,
|
||||||
});
|
},
|
||||||
}
|
],
|
||||||
|
actions: [
|
||||||
if (custom) {
|
{
|
||||||
await sendCustomNotification(custom, {
|
type: "button",
|
||||||
title: "Build Success",
|
text: "View Build Details",
|
||||||
message: "Build completed successfully",
|
url: buildLink,
|
||||||
projectName,
|
},
|
||||||
applicationName,
|
],
|
||||||
applicationType,
|
},
|
||||||
buildLink,
|
],
|
||||||
timestamp: date.toISOString(),
|
});
|
||||||
date: date.toLocaleString(),
|
}
|
||||||
domains: domains.map((domain) => domain.host).join(", "),
|
|
||||||
status: "success",
|
if (custom) {
|
||||||
type: "build",
|
await sendCustomNotification(custom, {
|
||||||
});
|
title: "Build Success",
|
||||||
}
|
message: "Build completed successfully",
|
||||||
|
projectName,
|
||||||
if (lark) {
|
applicationName,
|
||||||
await sendLarkNotification(lark, {
|
applicationType,
|
||||||
msg_type: "interactive",
|
buildLink,
|
||||||
card: {
|
timestamp: date.toISOString(),
|
||||||
schema: "2.0",
|
date: date.toLocaleString(),
|
||||||
config: {
|
domains: domains.map((domain) => domain.host).join(", "),
|
||||||
update_multi: true,
|
status: "success",
|
||||||
style: {
|
type: "build",
|
||||||
text_size: {
|
});
|
||||||
normal_v2: {
|
}
|
||||||
default: "normal",
|
|
||||||
pc: "normal",
|
if (lark) {
|
||||||
mobile: "heading",
|
await sendLarkNotification(lark, {
|
||||||
},
|
msg_type: "interactive",
|
||||||
},
|
card: {
|
||||||
},
|
schema: "2.0",
|
||||||
},
|
config: {
|
||||||
header: {
|
update_multi: true,
|
||||||
title: {
|
style: {
|
||||||
tag: "plain_text",
|
text_size: {
|
||||||
content: "✅ Build Success",
|
normal_v2: {
|
||||||
},
|
default: "normal",
|
||||||
subtitle: {
|
pc: "normal",
|
||||||
tag: "plain_text",
|
mobile: "heading",
|
||||||
content: "",
|
},
|
||||||
},
|
},
|
||||||
template: "green",
|
},
|
||||||
padding: "12px 12px 12px 12px",
|
},
|
||||||
},
|
header: {
|
||||||
body: {
|
title: {
|
||||||
direction: "vertical",
|
tag: "plain_text",
|
||||||
padding: "12px 12px 12px 12px",
|
content: "✅ Build Success",
|
||||||
elements: [
|
},
|
||||||
{
|
subtitle: {
|
||||||
tag: "column_set",
|
tag: "plain_text",
|
||||||
columns: [
|
content: "",
|
||||||
{
|
},
|
||||||
tag: "column",
|
template: "green",
|
||||||
width: "weighted",
|
padding: "12px 12px 12px 12px",
|
||||||
elements: [
|
},
|
||||||
{
|
body: {
|
||||||
tag: "markdown",
|
direction: "vertical",
|
||||||
content: `**Project:**\n${projectName}`,
|
padding: "12px 12px 12px 12px",
|
||||||
text_align: "left",
|
elements: [
|
||||||
text_size: "normal_v2",
|
{
|
||||||
},
|
tag: "column_set",
|
||||||
{
|
columns: [
|
||||||
tag: "markdown",
|
{
|
||||||
content: `**Environment:**\n${environmentName}`,
|
tag: "column",
|
||||||
text_align: "left",
|
width: "weighted",
|
||||||
text_size: "normal_v2",
|
elements: [
|
||||||
},
|
{
|
||||||
{
|
tag: "markdown",
|
||||||
tag: "markdown",
|
content: `**Project:**\n${projectName}`,
|
||||||
content: `**Type:**\n${applicationType}`,
|
text_align: "left",
|
||||||
text_align: "left",
|
text_size: "normal_v2",
|
||||||
text_size: "normal_v2",
|
},
|
||||||
},
|
{
|
||||||
],
|
tag: "markdown",
|
||||||
vertical_align: "top",
|
content: `**Environment:**\n${environmentName}`,
|
||||||
weight: 1,
|
text_align: "left",
|
||||||
},
|
text_size: "normal_v2",
|
||||||
{
|
},
|
||||||
tag: "column",
|
{
|
||||||
width: "weighted",
|
tag: "markdown",
|
||||||
elements: [
|
content: `**Type:**\n${applicationType}`,
|
||||||
{
|
text_align: "left",
|
||||||
tag: "markdown",
|
text_size: "normal_v2",
|
||||||
content: `**Application:**\n${applicationName}`,
|
},
|
||||||
text_align: "left",
|
],
|
||||||
text_size: "normal_v2",
|
vertical_align: "top",
|
||||||
},
|
weight: 1,
|
||||||
{
|
},
|
||||||
tag: "markdown",
|
{
|
||||||
content: `**Date:**\n${format(date, "PP pp")}`,
|
tag: "column",
|
||||||
text_align: "left",
|
width: "weighted",
|
||||||
text_size: "normal_v2",
|
elements: [
|
||||||
},
|
{
|
||||||
],
|
tag: "markdown",
|
||||||
vertical_align: "top",
|
content: `**Application:**\n${applicationName}`,
|
||||||
weight: 1,
|
text_align: "left",
|
||||||
},
|
text_size: "normal_v2",
|
||||||
],
|
},
|
||||||
},
|
{
|
||||||
{
|
tag: "markdown",
|
||||||
tag: "button",
|
content: `**Date:**\n${format(date, "PP pp")}`,
|
||||||
text: {
|
text_align: "left",
|
||||||
tag: "plain_text",
|
text_size: "normal_v2",
|
||||||
content: "View Build Details",
|
},
|
||||||
},
|
],
|
||||||
type: "primary",
|
vertical_align: "top",
|
||||||
width: "default",
|
weight: 1,
|
||||||
size: "medium",
|
},
|
||||||
behaviors: [
|
],
|
||||||
{
|
},
|
||||||
type: "open_url",
|
{
|
||||||
default_url: buildLink,
|
tag: "button",
|
||||||
pc_url: "",
|
text: {
|
||||||
ios_url: "",
|
tag: "plain_text",
|
||||||
android_url: "",
|
content: "View Build Details",
|
||||||
},
|
},
|
||||||
],
|
type: "primary",
|
||||||
margin: "0px 0px 0px 0px",
|
width: "default",
|
||||||
},
|
size: "medium",
|
||||||
],
|
behaviors: [
|
||||||
},
|
{
|
||||||
},
|
type: "open_url",
|
||||||
});
|
default_url: buildLink,
|
||||||
}
|
pc_url: "",
|
||||||
|
ios_url: "",
|
||||||
if (pushover) {
|
android_url: "",
|
||||||
await sendPushoverNotification(
|
},
|
||||||
pushover,
|
],
|
||||||
"Build Success",
|
margin: "0px 0px 0px 0px",
|
||||||
`Project: ${projectName}\nApplication: ${applicationName}\nEnvironment: ${environmentName}\nType: ${applicationType}\nDate: ${date.toLocaleString()}`,
|
},
|
||||||
);
|
],
|
||||||
}
|
},
|
||||||
} catch (error) {
|
},
|
||||||
console.log(error);
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
if (pushover) {
|
||||||
|
await sendPushoverNotification(
|
||||||
|
pushover,
|
||||||
|
"Build Success",
|
||||||
|
`Project: ${projectName}\nApplication: ${applicationName}\nEnvironment: ${environmentName}\nType: ${applicationType}\nDate: ${date.toLocaleString()}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,61 +1,64 @@
|
|||||||
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";
|
||||||
import { renderAsync } from "@react-email/components";
|
import { renderAsync } from "@react-email/components";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import { and, eq } from "drizzle-orm";
|
import { and, eq } from "drizzle-orm";
|
||||||
import {
|
import {
|
||||||
sendCustomNotification,
|
sendCustomNotification,
|
||||||
sendDiscordNotification,
|
sendDiscordNotification,
|
||||||
sendEmailNotification,
|
sendEmailNotification,
|
||||||
sendGotifyNotification,
|
sendGotifyNotification,
|
||||||
sendLarkNotification,
|
sendLarkNotification,
|
||||||
sendNtfyNotification,
|
sendNtfyNotification,
|
||||||
sendPushoverNotification,
|
sendPushoverNotification,
|
||||||
|
sendResendNotification,
|
||||||
sendSlackNotification,
|
sendSlackNotification,
|
||||||
sendTelegramNotification,
|
sendTelegramNotification,
|
||||||
} from "./utils";
|
} from "./utils";
|
||||||
|
|
||||||
export const sendDatabaseBackupNotifications = async ({
|
export const sendDatabaseBackupNotifications = async ({
|
||||||
projectName,
|
projectName,
|
||||||
applicationName,
|
applicationName,
|
||||||
databaseType,
|
databaseType,
|
||||||
type,
|
type,
|
||||||
errorMessage,
|
errorMessage,
|
||||||
organizationId,
|
organizationId,
|
||||||
databaseName,
|
databaseName,
|
||||||
}: {
|
}: {
|
||||||
projectName: string;
|
projectName: string;
|
||||||
applicationName: string;
|
applicationName: string;
|
||||||
databaseType: "postgres" | "mysql" | "mongodb" | "mariadb";
|
databaseType: "postgres" | "mysql" | "mongodb" | "mariadb";
|
||||||
type: "error" | "success";
|
type: "error" | "success";
|
||||||
organizationId: string;
|
organizationId: string;
|
||||||
errorMessage?: string;
|
errorMessage?: string;
|
||||||
databaseName: string;
|
databaseName: string;
|
||||||
}) => {
|
}) => {
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
const unixDate = ~~(Number(date) / 1000);
|
const unixDate = ~~(Number(date) / 1000);
|
||||||
const notificationList = await db.query.notifications.findMany({
|
const notificationList = await db.query.notifications.findMany({
|
||||||
where: and(
|
where: and(
|
||||||
eq(notifications.databaseBackup, true),
|
eq(notifications.databaseBackup, true),
|
||||||
eq(notifications.organizationId, organizationId),
|
eq(notifications.organizationId, organizationId),
|
||||||
),
|
),
|
||||||
with: {
|
with: {
|
||||||
email: true,
|
email: true,
|
||||||
discord: true,
|
discord: true,
|
||||||
telegram: true,
|
telegram: true,
|
||||||
slack: true,
|
slack: true,
|
||||||
gotify: true,
|
resend: true,
|
||||||
ntfy: true,
|
gotify: true,
|
||||||
custom: true,
|
ntfy: true,
|
||||||
lark: true,
|
custom: true,
|
||||||
pushover: true,
|
lark: true,
|
||||||
},
|
pushover: true,
|
||||||
});
|
},
|
||||||
|
});
|
||||||
for (const notification of notificationList) {
|
|
||||||
|
for (const notification of notificationList) {
|
||||||
const {
|
const {
|
||||||
email,
|
email,
|
||||||
|
resend,
|
||||||
discord,
|
discord,
|
||||||
telegram,
|
telegram,
|
||||||
slack,
|
slack,
|
||||||
@@ -65,339 +68,350 @@ export const sendDatabaseBackupNotifications = async ({
|
|||||||
lark,
|
lark,
|
||||||
pushover,
|
pushover,
|
||||||
} = notification;
|
} = notification;
|
||||||
try {
|
try {
|
||||||
if (email) {
|
if (email || resend) {
|
||||||
const template = await renderAsync(
|
const template = await renderAsync(
|
||||||
DatabaseBackupEmail({
|
DatabaseBackupEmail({
|
||||||
projectName,
|
projectName,
|
||||||
applicationName,
|
applicationName,
|
||||||
databaseType,
|
databaseType,
|
||||||
type,
|
type,
|
||||||
errorMessage,
|
errorMessage,
|
||||||
date: date.toLocaleString(),
|
date: date.toLocaleString(),
|
||||||
}),
|
}),
|
||||||
).catch();
|
).catch();
|
||||||
await sendEmailNotification(
|
|
||||||
email,
|
if (email) {
|
||||||
"Database backup for dokploy",
|
await sendEmailNotification(
|
||||||
template,
|
email,
|
||||||
);
|
"Database backup for dokploy",
|
||||||
}
|
template,
|
||||||
|
);
|
||||||
if (discord) {
|
}
|
||||||
const decorate = (decoration: string, text: string) =>
|
|
||||||
`${discord.decoration ? decoration : ""} ${text}`.trim();
|
if (resend) {
|
||||||
|
await sendResendNotification(
|
||||||
await sendDiscordNotification(discord, {
|
resend,
|
||||||
title:
|
"Database backup for dokploy",
|
||||||
type === "success"
|
template,
|
||||||
? decorate(">", "`✅` Database Backup Successful")
|
);
|
||||||
: decorate(">", "`❌` Database Backup Failed"),
|
}
|
||||||
color: type === "success" ? 0x57f287 : 0xed4245,
|
}
|
||||||
fields: [
|
|
||||||
{
|
if (discord) {
|
||||||
name: decorate("`🛠️`", "Project"),
|
const decorate = (decoration: string, text: string) =>
|
||||||
value: projectName,
|
`${discord.decoration ? decoration : ""} ${text}`.trim();
|
||||||
inline: true,
|
|
||||||
},
|
await sendDiscordNotification(discord, {
|
||||||
{
|
title:
|
||||||
name: decorate("`⚙️`", "Application"),
|
type === "success"
|
||||||
value: applicationName,
|
? decorate(">", "`✅` Database Backup Successful")
|
||||||
inline: true,
|
: decorate(">", "`❌` Database Backup Failed"),
|
||||||
},
|
color: type === "success" ? 0x57f287 : 0xed4245,
|
||||||
{
|
fields: [
|
||||||
name: decorate("`❔`", "Database"),
|
{
|
||||||
value: databaseType,
|
name: decorate("`🛠️`", "Project"),
|
||||||
inline: true,
|
value: projectName,
|
||||||
},
|
inline: true,
|
||||||
{
|
},
|
||||||
name: decorate("`📂`", "Database Name"),
|
{
|
||||||
value: databaseName,
|
name: decorate("`⚙️`", "Application"),
|
||||||
inline: true,
|
value: applicationName,
|
||||||
},
|
inline: true,
|
||||||
{
|
},
|
||||||
name: decorate("`📅`", "Date"),
|
{
|
||||||
value: `<t:${unixDate}:D>`,
|
name: decorate("`❔`", "Database"),
|
||||||
inline: true,
|
value: databaseType,
|
||||||
},
|
inline: true,
|
||||||
{
|
},
|
||||||
name: decorate("`⌚`", "Time"),
|
{
|
||||||
value: `<t:${unixDate}:t>`,
|
name: decorate("`📂`", "Database Name"),
|
||||||
inline: true,
|
value: databaseName,
|
||||||
},
|
inline: true,
|
||||||
{
|
},
|
||||||
name: decorate("`❓`", "Type"),
|
{
|
||||||
value: type
|
name: decorate("`📅`", "Date"),
|
||||||
.replace("error", "Failed")
|
value: `<t:${unixDate}:D>`,
|
||||||
.replace("success", "Successful"),
|
inline: true,
|
||||||
inline: true,
|
},
|
||||||
},
|
{
|
||||||
...(type === "error" && errorMessage
|
name: decorate("`⌚`", "Time"),
|
||||||
? [
|
value: `<t:${unixDate}:t>`,
|
||||||
{
|
inline: true,
|
||||||
name: decorate("`⚠️`", "Error Message"),
|
},
|
||||||
value: `\`\`\`${errorMessage}\`\`\``,
|
{
|
||||||
},
|
name: decorate("`❓`", "Type"),
|
||||||
]
|
value: type
|
||||||
: []),
|
.replace("error", "Failed")
|
||||||
],
|
.replace("success", "Successful"),
|
||||||
timestamp: date.toISOString(),
|
inline: true,
|
||||||
footer: {
|
},
|
||||||
text: "Dokploy Database Backup Notification",
|
...(type === "error" && errorMessage
|
||||||
},
|
? [
|
||||||
});
|
{
|
||||||
}
|
name: decorate("`⚠️`", "Error Message"),
|
||||||
|
value: `\`\`\`${errorMessage}\`\`\``,
|
||||||
if (gotify) {
|
},
|
||||||
const decorate = (decoration: string, text: string) =>
|
]
|
||||||
`${gotify.decoration ? decoration : ""} ${text}\n`;
|
: []),
|
||||||
|
],
|
||||||
await sendGotifyNotification(
|
timestamp: date.toISOString(),
|
||||||
gotify,
|
footer: {
|
||||||
decorate(
|
text: "Dokploy Database Backup Notification",
|
||||||
type === "success" ? "✅" : "❌",
|
},
|
||||||
`Database Backup ${type === "success" ? "Successful" : "Failed"}`,
|
});
|
||||||
),
|
}
|
||||||
`${decorate("🛠️", `Project: ${projectName}`)}` +
|
|
||||||
`${decorate("⚙️", `Application: ${applicationName}`)}` +
|
if (gotify) {
|
||||||
`${decorate("❔", `Type: ${databaseType}`)}` +
|
const decorate = (decoration: string, text: string) =>
|
||||||
`${decorate("📂", `Database Name: ${databaseName}`)}` +
|
`${gotify.decoration ? decoration : ""} ${text}\n`;
|
||||||
`${decorate("🕒", `Date: ${date.toLocaleString()}`)}` +
|
|
||||||
`${type === "error" && errorMessage ? decorate("❌", `Error:\n${errorMessage}`) : ""}`,
|
await sendGotifyNotification(
|
||||||
);
|
gotify,
|
||||||
}
|
decorate(
|
||||||
|
type === "success" ? "✅" : "❌",
|
||||||
if (ntfy) {
|
`Database Backup ${type === "success" ? "Successful" : "Failed"}`,
|
||||||
await sendNtfyNotification(
|
),
|
||||||
ntfy,
|
`${decorate("🛠️", `Project: ${projectName}`)}` +
|
||||||
`Database Backup ${type === "success" ? "Successful" : "Failed"}`,
|
`${decorate("⚙️", `Application: ${applicationName}`)}` +
|
||||||
`${type === "success" ? "white_check_mark" : "x"}`,
|
`${decorate("❔", `Type: ${databaseType}`)}` +
|
||||||
"",
|
`${decorate("📂", `Database Name: ${databaseName}`)}` +
|
||||||
`🛠Project: ${projectName}\n` +
|
`${decorate("🕒", `Date: ${date.toLocaleString()}`)}` +
|
||||||
`⚙️Application: ${applicationName}\n` +
|
`${type === "error" && errorMessage ? decorate("❌", `Error:\n${errorMessage}`) : ""}`,
|
||||||
`❔Type: ${databaseType}\n` +
|
);
|
||||||
`📂Database Name: ${databaseName}` +
|
}
|
||||||
`🕒Date: ${date.toLocaleString()}\n` +
|
|
||||||
`${type === "error" && errorMessage ? `❌Error:\n${errorMessage}` : ""}`,
|
if (ntfy) {
|
||||||
);
|
await sendNtfyNotification(
|
||||||
}
|
ntfy,
|
||||||
|
`Database Backup ${type === "success" ? "Successful" : "Failed"}`,
|
||||||
if (telegram) {
|
`${type === "success" ? "white_check_mark" : "x"}`,
|
||||||
const isError = type === "error" && errorMessage;
|
"",
|
||||||
|
`🛠Project: ${projectName}\n` +
|
||||||
const statusEmoji = type === "success" ? "✅" : "❌";
|
`⚙️Application: ${applicationName}\n` +
|
||||||
const typeStatus = type === "success" ? "Successful" : "Failed";
|
`❔Type: ${databaseType}\n` +
|
||||||
const errorMsg = isError
|
`📂Database Name: ${databaseName}` +
|
||||||
? `\n\n<b>Error:</b>\n<pre>${errorMessage}</pre>`
|
`🕒Date: ${date.toLocaleString()}\n` +
|
||||||
: "";
|
`${type === "error" && errorMessage ? `❌Error:\n${errorMessage}` : ""}`,
|
||||||
|
);
|
||||||
const messageText = `<b>${statusEmoji} Database Backup ${typeStatus}</b>\n\n<b>Project:</b> ${projectName}\n<b>Application:</b> ${applicationName}\n<b>Type:</b> ${databaseType}\n<b>Database Name:</b> ${databaseName}\n<b>Date:</b> ${format(date, "PP")}\n<b>Time:</b> ${format(date, "pp")}${isError ? errorMsg : ""}`;
|
}
|
||||||
|
|
||||||
await sendTelegramNotification(telegram, messageText);
|
if (telegram) {
|
||||||
}
|
const isError = type === "error" && errorMessage;
|
||||||
|
|
||||||
if (slack) {
|
const statusEmoji = type === "success" ? "✅" : "❌";
|
||||||
const { channel } = slack;
|
const typeStatus = type === "success" ? "Successful" : "Failed";
|
||||||
await sendSlackNotification(slack, {
|
const errorMsg = isError
|
||||||
channel: channel,
|
? `\n\n<b>Error:</b>\n<pre>${errorMessage}</pre>`
|
||||||
attachments: [
|
: "";
|
||||||
{
|
|
||||||
color: type === "success" ? "#00FF00" : "#FF0000",
|
const messageText = `<b>${statusEmoji} Database Backup ${typeStatus}</b>\n\n<b>Project:</b> ${projectName}\n<b>Application:</b> ${applicationName}\n<b>Type:</b> ${databaseType}\n<b>Database Name:</b> ${databaseName}\n<b>Date:</b> ${format(date, "PP")}\n<b>Time:</b> ${format(date, "pp")}${isError ? errorMsg : ""}`;
|
||||||
pretext:
|
|
||||||
type === "success"
|
await sendTelegramNotification(telegram, messageText);
|
||||||
? ":white_check_mark: *Database Backup Successful*"
|
}
|
||||||
: ":x: *Database Backup Failed*",
|
|
||||||
fields: [
|
if (slack) {
|
||||||
...(type === "error" && errorMessage
|
const { channel } = slack;
|
||||||
? [
|
await sendSlackNotification(slack, {
|
||||||
{
|
channel: channel,
|
||||||
title: "Error Message",
|
attachments: [
|
||||||
value: errorMessage,
|
{
|
||||||
short: false,
|
color: type === "success" ? "#00FF00" : "#FF0000",
|
||||||
},
|
pretext:
|
||||||
]
|
type === "success"
|
||||||
: []),
|
? ":white_check_mark: *Database Backup Successful*"
|
||||||
{
|
: ":x: *Database Backup Failed*",
|
||||||
title: "Project",
|
fields: [
|
||||||
value: projectName,
|
...(type === "error" && errorMessage
|
||||||
short: true,
|
? [
|
||||||
},
|
{
|
||||||
{
|
title: "Error Message",
|
||||||
title: "Application",
|
value: errorMessage,
|
||||||
value: applicationName,
|
short: false,
|
||||||
short: true,
|
},
|
||||||
},
|
]
|
||||||
{
|
: []),
|
||||||
title: "Type",
|
{
|
||||||
value: databaseType,
|
title: "Project",
|
||||||
short: true,
|
value: projectName,
|
||||||
},
|
short: true,
|
||||||
{
|
},
|
||||||
title: "Database Name",
|
{
|
||||||
value: databaseName,
|
title: "Application",
|
||||||
},
|
value: applicationName,
|
||||||
{
|
short: true,
|
||||||
title: "Time",
|
},
|
||||||
value: date.toLocaleString(),
|
{
|
||||||
short: true,
|
title: "Type",
|
||||||
},
|
value: databaseType,
|
||||||
{
|
short: true,
|
||||||
title: "Type",
|
},
|
||||||
value: type,
|
{
|
||||||
},
|
title: "Database Name",
|
||||||
{
|
value: databaseName,
|
||||||
title: "Status",
|
},
|
||||||
value: type === "success" ? "Successful" : "Failed",
|
{
|
||||||
},
|
title: "Time",
|
||||||
],
|
value: date.toLocaleString(),
|
||||||
},
|
short: true,
|
||||||
],
|
},
|
||||||
});
|
{
|
||||||
}
|
title: "Type",
|
||||||
|
value: type,
|
||||||
if (custom) {
|
},
|
||||||
await sendCustomNotification(custom, {
|
{
|
||||||
title: `Database Backup ${type === "success" ? "Successful" : "Failed"}`,
|
title: "Status",
|
||||||
message:
|
value: type === "success" ? "Successful" : "Failed",
|
||||||
type === "success"
|
},
|
||||||
? "Database backup completed successfully"
|
],
|
||||||
: "Database backup failed",
|
},
|
||||||
projectName,
|
],
|
||||||
applicationName,
|
});
|
||||||
databaseType,
|
}
|
||||||
databaseName,
|
|
||||||
type,
|
if (custom) {
|
||||||
errorMessage: errorMessage || "",
|
await sendCustomNotification(custom, {
|
||||||
timestamp: date.toISOString(),
|
title: `Database Backup ${type === "success" ? "Successful" : "Failed"}`,
|
||||||
date: date.toLocaleString(),
|
message:
|
||||||
status: type,
|
type === "success"
|
||||||
});
|
? "Database backup completed successfully"
|
||||||
}
|
: "Database backup failed",
|
||||||
|
projectName,
|
||||||
if (lark) {
|
applicationName,
|
||||||
const limitCharacter = 800;
|
databaseType,
|
||||||
const truncatedErrorMessage =
|
databaseName,
|
||||||
errorMessage && errorMessage.length > limitCharacter
|
type,
|
||||||
? errorMessage.substring(0, limitCharacter)
|
errorMessage: errorMessage || "",
|
||||||
: errorMessage;
|
timestamp: date.toISOString(),
|
||||||
|
date: date.toLocaleString(),
|
||||||
await sendLarkNotification(lark, {
|
status: type,
|
||||||
msg_type: "interactive",
|
});
|
||||||
card: {
|
}
|
||||||
schema: "2.0",
|
|
||||||
config: {
|
if (lark) {
|
||||||
update_multi: true,
|
const limitCharacter = 800;
|
||||||
style: {
|
const truncatedErrorMessage =
|
||||||
text_size: {
|
errorMessage && errorMessage.length > limitCharacter
|
||||||
normal_v2: {
|
? errorMessage.substring(0, limitCharacter)
|
||||||
default: "normal",
|
: errorMessage;
|
||||||
pc: "normal",
|
|
||||||
mobile: "heading",
|
await sendLarkNotification(lark, {
|
||||||
},
|
msg_type: "interactive",
|
||||||
},
|
card: {
|
||||||
},
|
schema: "2.0",
|
||||||
},
|
config: {
|
||||||
header: {
|
update_multi: true,
|
||||||
title: {
|
style: {
|
||||||
tag: "plain_text",
|
text_size: {
|
||||||
content:
|
normal_v2: {
|
||||||
type === "success"
|
default: "normal",
|
||||||
? "✅ Database Backup Successful"
|
pc: "normal",
|
||||||
: "❌ Database Backup Failed",
|
mobile: "heading",
|
||||||
},
|
},
|
||||||
subtitle: {
|
},
|
||||||
tag: "plain_text",
|
},
|
||||||
content: "",
|
},
|
||||||
},
|
header: {
|
||||||
template: type === "success" ? "green" : "red",
|
title: {
|
||||||
padding: "12px 12px 12px 12px",
|
tag: "plain_text",
|
||||||
},
|
content:
|
||||||
body: {
|
type === "success"
|
||||||
direction: "vertical",
|
? "✅ Database Backup Successful"
|
||||||
padding: "12px 12px 12px 12px",
|
: "❌ Database Backup Failed",
|
||||||
elements: [
|
},
|
||||||
{
|
subtitle: {
|
||||||
tag: "column_set",
|
tag: "plain_text",
|
||||||
columns: [
|
content: "",
|
||||||
{
|
},
|
||||||
tag: "column",
|
template: type === "success" ? "green" : "red",
|
||||||
width: "weighted",
|
padding: "12px 12px 12px 12px",
|
||||||
elements: [
|
},
|
||||||
{
|
body: {
|
||||||
tag: "markdown",
|
direction: "vertical",
|
||||||
content: `**Project:**\n${projectName}`,
|
padding: "12px 12px 12px 12px",
|
||||||
text_align: "left",
|
elements: [
|
||||||
text_size: "normal_v2",
|
{
|
||||||
},
|
tag: "column_set",
|
||||||
{
|
columns: [
|
||||||
tag: "markdown",
|
{
|
||||||
content: `**Database Type:**\n${databaseType}`,
|
tag: "column",
|
||||||
text_align: "left",
|
width: "weighted",
|
||||||
text_size: "normal_v2",
|
elements: [
|
||||||
},
|
{
|
||||||
{
|
tag: "markdown",
|
||||||
tag: "markdown",
|
content: `**Project:**\n${projectName}`,
|
||||||
content: `**Status:**\n${type === "success" ? "Successful" : "Failed"}`,
|
text_align: "left",
|
||||||
text_align: "left",
|
text_size: "normal_v2",
|
||||||
text_size: "normal_v2",
|
},
|
||||||
},
|
{
|
||||||
],
|
tag: "markdown",
|
||||||
vertical_align: "top",
|
content: `**Database Type:**\n${databaseType}`,
|
||||||
weight: 1,
|
text_align: "left",
|
||||||
},
|
text_size: "normal_v2",
|
||||||
{
|
},
|
||||||
tag: "column",
|
{
|
||||||
width: "weighted",
|
tag: "markdown",
|
||||||
elements: [
|
content: `**Status:**\n${type === "success" ? "Successful" : "Failed"}`,
|
||||||
{
|
text_align: "left",
|
||||||
tag: "markdown",
|
text_size: "normal_v2",
|
||||||
content: `**Application:**\n${applicationName}`,
|
},
|
||||||
text_align: "left",
|
],
|
||||||
text_size: "normal_v2",
|
vertical_align: "top",
|
||||||
},
|
weight: 1,
|
||||||
{
|
},
|
||||||
tag: "markdown",
|
{
|
||||||
content: `**Database Name:**\n${databaseName}`,
|
tag: "column",
|
||||||
text_align: "left",
|
width: "weighted",
|
||||||
text_size: "normal_v2",
|
elements: [
|
||||||
},
|
{
|
||||||
{
|
tag: "markdown",
|
||||||
tag: "markdown",
|
content: `**Application:**\n${applicationName}`,
|
||||||
content: `**Date:**\n${format(date, "PP pp")}`,
|
text_align: "left",
|
||||||
text_align: "left",
|
text_size: "normal_v2",
|
||||||
text_size: "normal_v2",
|
},
|
||||||
},
|
{
|
||||||
],
|
tag: "markdown",
|
||||||
vertical_align: "top",
|
content: `**Database Name:**\n${databaseName}`,
|
||||||
weight: 1,
|
text_align: "left",
|
||||||
},
|
text_size: "normal_v2",
|
||||||
],
|
},
|
||||||
},
|
{
|
||||||
...(type === "error" && truncatedErrorMessage
|
tag: "markdown",
|
||||||
? [
|
content: `**Date:**\n${format(date, "PP pp")}`,
|
||||||
{
|
text_align: "left",
|
||||||
tag: "markdown",
|
text_size: "normal_v2",
|
||||||
content: `**Error Message:**\n\`\`\`\n${truncatedErrorMessage}\n\`\`\``,
|
},
|
||||||
text_align: "left",
|
],
|
||||||
text_size: "normal_v2",
|
vertical_align: "top",
|
||||||
},
|
weight: 1,
|
||||||
]
|
},
|
||||||
: []),
|
],
|
||||||
],
|
},
|
||||||
},
|
...(type === "error" && truncatedErrorMessage
|
||||||
},
|
? [
|
||||||
});
|
{
|
||||||
}
|
tag: "markdown",
|
||||||
|
content: `**Error Message:**\n\`\`\`\n${truncatedErrorMessage}\n\`\`\``,
|
||||||
if (pushover) {
|
text_align: "left",
|
||||||
await sendPushoverNotification(
|
text_size: "normal_v2",
|
||||||
pushover,
|
},
|
||||||
`Database Backup ${type === "success" ? "Successful" : "Failed"}`,
|
]
|
||||||
`Project: ${projectName}\nApplication: ${applicationName}\nDatabase: ${databaseType}\nDatabase Name: ${databaseName}\nDate: ${date.toLocaleString()}${type === "error" && errorMessage ? `\nError: ${errorMessage}` : ""}`,
|
: []),
|
||||||
);
|
],
|
||||||
}
|
},
|
||||||
} catch (error) {
|
},
|
||||||
console.log(error);
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
if (pushover) {
|
||||||
|
await sendPushoverNotification(
|
||||||
|
pushover,
|
||||||
|
`Database Backup ${type === "success" ? "Successful" : "Failed"}`,
|
||||||
|
`Project: ${projectName}\nApplication: ${applicationName}\nDatabase: ${databaseType}\nDatabase Name: ${databaseName}\nDate: ${date.toLocaleString()}${type === "error" && errorMessage ? `\nError: ${errorMessage}` : ""}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,48 +1,51 @@
|
|||||||
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 DockerCleanupEmail from "@dokploy/server/emails/emails/docker-cleanup";
|
import DockerCleanupEmail from "@dokploy/server/emails/emails/docker-cleanup";
|
||||||
import { renderAsync } from "@react-email/components";
|
import { renderAsync } from "@react-email/components";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import { and, eq } from "drizzle-orm";
|
import { and, eq } from "drizzle-orm";
|
||||||
import {
|
import {
|
||||||
sendCustomNotification,
|
sendCustomNotification,
|
||||||
sendDiscordNotification,
|
sendDiscordNotification,
|
||||||
sendEmailNotification,
|
sendEmailNotification,
|
||||||
sendGotifyNotification,
|
sendGotifyNotification,
|
||||||
sendLarkNotification,
|
sendLarkNotification,
|
||||||
sendNtfyNotification,
|
sendNtfyNotification,
|
||||||
sendPushoverNotification,
|
sendPushoverNotification,
|
||||||
|
sendResendNotification,
|
||||||
sendSlackNotification,
|
sendSlackNotification,
|
||||||
sendTelegramNotification,
|
sendTelegramNotification,
|
||||||
} from "./utils";
|
} from "./utils";
|
||||||
|
|
||||||
export const sendDockerCleanupNotifications = async (
|
export const sendDockerCleanupNotifications = async (
|
||||||
organizationId: string,
|
organizationId: string,
|
||||||
message = "Docker cleanup for dokploy",
|
message = "Docker cleanup for dokploy",
|
||||||
) => {
|
) => {
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
const unixDate = ~~(Number(date) / 1000);
|
const unixDate = ~~(Number(date) / 1000);
|
||||||
const notificationList = await db.query.notifications.findMany({
|
const notificationList = await db.query.notifications.findMany({
|
||||||
where: and(
|
where: and(
|
||||||
eq(notifications.dockerCleanup, true),
|
eq(notifications.dockerCleanup, true),
|
||||||
eq(notifications.organizationId, organizationId),
|
eq(notifications.organizationId, organizationId),
|
||||||
),
|
),
|
||||||
with: {
|
with: {
|
||||||
email: true,
|
email: true,
|
||||||
discord: true,
|
discord: true,
|
||||||
telegram: true,
|
telegram: true,
|
||||||
slack: true,
|
slack: true,
|
||||||
gotify: true,
|
resend: true,
|
||||||
ntfy: true,
|
gotify: true,
|
||||||
custom: true,
|
ntfy: true,
|
||||||
lark: true,
|
custom: true,
|
||||||
pushover: true,
|
lark: true,
|
||||||
},
|
pushover: true,
|
||||||
});
|
},
|
||||||
|
});
|
||||||
for (const notification of notificationList) {
|
|
||||||
|
for (const notification of notificationList) {
|
||||||
const {
|
const {
|
||||||
email,
|
email,
|
||||||
|
resend,
|
||||||
discord,
|
discord,
|
||||||
telegram,
|
telegram,
|
||||||
slack,
|
slack,
|
||||||
@@ -52,205 +55,215 @@ export const sendDockerCleanupNotifications = async (
|
|||||||
lark,
|
lark,
|
||||||
pushover,
|
pushover,
|
||||||
} = notification;
|
} = notification;
|
||||||
try {
|
try {
|
||||||
if (email) {
|
if (email || resend) {
|
||||||
const template = await renderAsync(
|
const template = await renderAsync(
|
||||||
DockerCleanupEmail({ message, date: date.toLocaleString() }),
|
DockerCleanupEmail({ message, date: date.toLocaleString() }),
|
||||||
).catch();
|
).catch();
|
||||||
|
|
||||||
await sendEmailNotification(
|
if (email) {
|
||||||
email,
|
await sendEmailNotification(
|
||||||
"Docker cleanup for dokploy",
|
email,
|
||||||
template,
|
"Docker cleanup for dokploy",
|
||||||
);
|
template,
|
||||||
}
|
);
|
||||||
|
}
|
||||||
if (discord) {
|
|
||||||
const decorate = (decoration: string, text: string) =>
|
if (resend) {
|
||||||
`${discord.decoration ? decoration : ""} ${text}`.trim();
|
await sendResendNotification(
|
||||||
|
resend,
|
||||||
await sendDiscordNotification(discord, {
|
"Docker cleanup for dokploy",
|
||||||
title: decorate(">", "`✅` Docker Cleanup"),
|
template,
|
||||||
color: 0x57f287,
|
);
|
||||||
fields: [
|
}
|
||||||
{
|
}
|
||||||
name: decorate("`📅`", "Date"),
|
|
||||||
value: `<t:${unixDate}:D>`,
|
if (discord) {
|
||||||
inline: true,
|
const decorate = (decoration: string, text: string) =>
|
||||||
},
|
`${discord.decoration ? decoration : ""} ${text}`.trim();
|
||||||
{
|
|
||||||
name: decorate("`⌚`", "Time"),
|
await sendDiscordNotification(discord, {
|
||||||
value: `<t:${unixDate}:t>`,
|
title: decorate(">", "`✅` Docker Cleanup"),
|
||||||
inline: true,
|
color: 0x57f287,
|
||||||
},
|
fields: [
|
||||||
{
|
{
|
||||||
name: decorate("`❓`", "Type"),
|
name: decorate("`📅`", "Date"),
|
||||||
value: "Successful",
|
value: `<t:${unixDate}:D>`,
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: decorate("`📜`", "Message"),
|
name: decorate("`⌚`", "Time"),
|
||||||
value: `\`\`\`${message}\`\`\``,
|
value: `<t:${unixDate}:t>`,
|
||||||
},
|
inline: true,
|
||||||
],
|
},
|
||||||
timestamp: date.toISOString(),
|
{
|
||||||
footer: {
|
name: decorate("`❓`", "Type"),
|
||||||
text: "Dokploy Docker Cleanup Notification",
|
value: "Successful",
|
||||||
},
|
inline: true,
|
||||||
});
|
},
|
||||||
}
|
{
|
||||||
|
name: decorate("`📜`", "Message"),
|
||||||
if (gotify) {
|
value: `\`\`\`${message}\`\`\``,
|
||||||
const decorate = (decoration: string, text: string) =>
|
},
|
||||||
`${gotify.decoration ? decoration : ""} ${text}\n`;
|
],
|
||||||
await sendGotifyNotification(
|
timestamp: date.toISOString(),
|
||||||
gotify,
|
footer: {
|
||||||
decorate("✅", "Docker Cleanup"),
|
text: "Dokploy Docker Cleanup Notification",
|
||||||
`${decorate("🕒", `Date: ${date.toLocaleString()}`)}` +
|
},
|
||||||
`${decorate("📜", `Message:\n${message}`)}`,
|
});
|
||||||
);
|
}
|
||||||
}
|
|
||||||
|
if (gotify) {
|
||||||
if (ntfy) {
|
const decorate = (decoration: string, text: string) =>
|
||||||
await sendNtfyNotification(
|
`${gotify.decoration ? decoration : ""} ${text}\n`;
|
||||||
ntfy,
|
await sendGotifyNotification(
|
||||||
"Docker Cleanup",
|
gotify,
|
||||||
"white_check_mark",
|
decorate("✅", "Docker Cleanup"),
|
||||||
"",
|
`${decorate("🕒", `Date: ${date.toLocaleString()}`)}` +
|
||||||
`🕒Date: ${date.toLocaleString()}\n` + `📜Message:\n${message}`,
|
`${decorate("📜", `Message:\n${message}`)}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (telegram) {
|
if (ntfy) {
|
||||||
await sendTelegramNotification(
|
await sendNtfyNotification(
|
||||||
telegram,
|
ntfy,
|
||||||
`<b>✅ Docker Cleanup</b>\n\n<b>Message:</b> ${message}\n<b>Date:</b> ${format(date, "PP")}\n<b>Time:</b> ${format(date, "pp")}`,
|
"Docker Cleanup",
|
||||||
);
|
"white_check_mark",
|
||||||
}
|
"",
|
||||||
|
`🕒Date: ${date.toLocaleString()}\n` + `📜Message:\n${message}`,
|
||||||
if (slack) {
|
);
|
||||||
const { channel } = slack;
|
}
|
||||||
await sendSlackNotification(slack, {
|
|
||||||
channel: channel,
|
if (telegram) {
|
||||||
attachments: [
|
await sendTelegramNotification(
|
||||||
{
|
telegram,
|
||||||
color: "#00FF00",
|
`<b>✅ Docker Cleanup</b>\n\n<b>Message:</b> ${message}\n<b>Date:</b> ${format(date, "PP")}\n<b>Time:</b> ${format(date, "pp")}`,
|
||||||
pretext: ":white_check_mark: *Docker Cleanup*",
|
);
|
||||||
fields: [
|
}
|
||||||
{
|
|
||||||
title: "Message",
|
if (slack) {
|
||||||
value: message,
|
const { channel } = slack;
|
||||||
},
|
await sendSlackNotification(slack, {
|
||||||
{
|
channel: channel,
|
||||||
title: "Time",
|
attachments: [
|
||||||
value: date.toLocaleString(),
|
{
|
||||||
short: true,
|
color: "#00FF00",
|
||||||
},
|
pretext: ":white_check_mark: *Docker Cleanup*",
|
||||||
],
|
fields: [
|
||||||
},
|
{
|
||||||
],
|
title: "Message",
|
||||||
});
|
value: message,
|
||||||
}
|
},
|
||||||
|
{
|
||||||
if (custom) {
|
title: "Time",
|
||||||
await sendCustomNotification(custom, {
|
value: date.toLocaleString(),
|
||||||
title: "Docker Cleanup",
|
short: true,
|
||||||
message: "Docker cleanup completed successfully",
|
},
|
||||||
cleanupMessage: message,
|
],
|
||||||
timestamp: date.toISOString(),
|
},
|
||||||
date: date.toLocaleString(),
|
],
|
||||||
status: "success",
|
});
|
||||||
type: "docker-cleanup",
|
}
|
||||||
});
|
|
||||||
}
|
if (custom) {
|
||||||
|
await sendCustomNotification(custom, {
|
||||||
if (lark) {
|
title: "Docker Cleanup",
|
||||||
await sendLarkNotification(lark, {
|
message: "Docker cleanup completed successfully",
|
||||||
msg_type: "interactive",
|
cleanupMessage: message,
|
||||||
card: {
|
timestamp: date.toISOString(),
|
||||||
schema: "2.0",
|
date: date.toLocaleString(),
|
||||||
config: {
|
status: "success",
|
||||||
update_multi: true,
|
type: "docker-cleanup",
|
||||||
style: {
|
});
|
||||||
text_size: {
|
}
|
||||||
normal_v2: {
|
|
||||||
default: "normal",
|
if (lark) {
|
||||||
pc: "normal",
|
await sendLarkNotification(lark, {
|
||||||
mobile: "heading",
|
msg_type: "interactive",
|
||||||
},
|
card: {
|
||||||
},
|
schema: "2.0",
|
||||||
},
|
config: {
|
||||||
},
|
update_multi: true,
|
||||||
header: {
|
style: {
|
||||||
title: {
|
text_size: {
|
||||||
tag: "plain_text",
|
normal_v2: {
|
||||||
content: "✅ Docker Cleanup",
|
default: "normal",
|
||||||
},
|
pc: "normal",
|
||||||
subtitle: {
|
mobile: "heading",
|
||||||
tag: "plain_text",
|
},
|
||||||
content: "",
|
},
|
||||||
},
|
},
|
||||||
template: "green",
|
},
|
||||||
padding: "12px 12px 12px 12px",
|
header: {
|
||||||
},
|
title: {
|
||||||
body: {
|
tag: "plain_text",
|
||||||
direction: "vertical",
|
content: "✅ Docker Cleanup",
|
||||||
padding: "12px 12px 12px 12px",
|
},
|
||||||
elements: [
|
subtitle: {
|
||||||
{
|
tag: "plain_text",
|
||||||
tag: "column_set",
|
content: "",
|
||||||
columns: [
|
},
|
||||||
{
|
template: "green",
|
||||||
tag: "column",
|
padding: "12px 12px 12px 12px",
|
||||||
width: "weighted",
|
},
|
||||||
elements: [
|
body: {
|
||||||
{
|
direction: "vertical",
|
||||||
tag: "markdown",
|
padding: "12px 12px 12px 12px",
|
||||||
content: "**Status:**\nSuccessful",
|
elements: [
|
||||||
text_align: "left",
|
{
|
||||||
text_size: "normal_v2",
|
tag: "column_set",
|
||||||
},
|
columns: [
|
||||||
{
|
{
|
||||||
tag: "markdown",
|
tag: "column",
|
||||||
content: `**Cleanup Details:**\n${message}`,
|
width: "weighted",
|
||||||
text_align: "left",
|
elements: [
|
||||||
text_size: "normal_v2",
|
{
|
||||||
},
|
tag: "markdown",
|
||||||
],
|
content: "**Status:**\nSuccessful",
|
||||||
vertical_align: "top",
|
text_align: "left",
|
||||||
weight: 1,
|
text_size: "normal_v2",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
tag: "column",
|
tag: "markdown",
|
||||||
width: "weighted",
|
content: `**Cleanup Details:**\n${message}`,
|
||||||
elements: [
|
text_align: "left",
|
||||||
{
|
text_size: "normal_v2",
|
||||||
tag: "markdown",
|
},
|
||||||
content: `**Date:**\n${format(date, "PP pp")}`,
|
],
|
||||||
text_align: "left",
|
vertical_align: "top",
|
||||||
text_size: "normal_v2",
|
weight: 1,
|
||||||
},
|
},
|
||||||
],
|
{
|
||||||
vertical_align: "top",
|
tag: "column",
|
||||||
weight: 1,
|
width: "weighted",
|
||||||
},
|
elements: [
|
||||||
],
|
{
|
||||||
},
|
tag: "markdown",
|
||||||
],
|
content: `**Date:**\n${format(date, "PP pp")}`,
|
||||||
},
|
text_align: "left",
|
||||||
},
|
text_size: "normal_v2",
|
||||||
});
|
},
|
||||||
}
|
],
|
||||||
|
vertical_align: "top",
|
||||||
if (pushover) {
|
weight: 1,
|
||||||
await sendPushoverNotification(
|
},
|
||||||
pushover,
|
],
|
||||||
"Docker Cleanup",
|
},
|
||||||
`Date: ${date.toLocaleString()}\nMessage: ${message}`,
|
],
|
||||||
);
|
},
|
||||||
}
|
},
|
||||||
} catch (error) {
|
});
|
||||||
console.log(error);
|
}
|
||||||
}
|
|
||||||
}
|
if (pushover) {
|
||||||
};
|
await sendPushoverNotification(
|
||||||
|
pushover,
|
||||||
|
"Docker Cleanup",
|
||||||
|
`Date: ${date.toLocaleString()}\nMessage: ${message}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,42 +1,45 @@
|
|||||||
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 DokployRestartEmail from "@dokploy/server/emails/emails/dokploy-restart";
|
import DokployRestartEmail from "@dokploy/server/emails/emails/dokploy-restart";
|
||||||
import { renderAsync } from "@react-email/components";
|
import { renderAsync } from "@react-email/components";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import { eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
import {
|
import {
|
||||||
sendCustomNotification,
|
sendCustomNotification,
|
||||||
sendDiscordNotification,
|
sendDiscordNotification,
|
||||||
sendEmailNotification,
|
sendEmailNotification,
|
||||||
sendGotifyNotification,
|
sendGotifyNotification,
|
||||||
sendLarkNotification,
|
sendLarkNotification,
|
||||||
sendNtfyNotification,
|
sendNtfyNotification,
|
||||||
sendPushoverNotification,
|
sendPushoverNotification,
|
||||||
|
sendResendNotification,
|
||||||
sendSlackNotification,
|
sendSlackNotification,
|
||||||
sendTelegramNotification,
|
sendTelegramNotification,
|
||||||
} from "./utils";
|
} from "./utils";
|
||||||
|
|
||||||
export const sendDokployRestartNotifications = async () => {
|
export const sendDokployRestartNotifications = async () => {
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
const unixDate = ~~(Number(date) / 1000);
|
const unixDate = ~~(Number(date) / 1000);
|
||||||
const notificationList = await db.query.notifications.findMany({
|
const notificationList = await db.query.notifications.findMany({
|
||||||
where: eq(notifications.dokployRestart, true),
|
where: eq(notifications.dokployRestart, true),
|
||||||
with: {
|
with: {
|
||||||
email: true,
|
email: true,
|
||||||
discord: true,
|
discord: true,
|
||||||
telegram: true,
|
telegram: true,
|
||||||
slack: true,
|
slack: true,
|
||||||
gotify: true,
|
resend: true,
|
||||||
ntfy: true,
|
gotify: true,
|
||||||
custom: true,
|
ntfy: true,
|
||||||
lark: true,
|
custom: true,
|
||||||
pushover: true,
|
lark: true,
|
||||||
},
|
pushover: true,
|
||||||
});
|
},
|
||||||
|
});
|
||||||
for (const notification of notificationList) {
|
|
||||||
|
for (const notification of notificationList) {
|
||||||
const {
|
const {
|
||||||
email,
|
email,
|
||||||
|
resend,
|
||||||
discord,
|
discord,
|
||||||
telegram,
|
telegram,
|
||||||
slack,
|
slack,
|
||||||
@@ -46,200 +49,210 @@ export const sendDokployRestartNotifications = async () => {
|
|||||||
lark,
|
lark,
|
||||||
pushover,
|
pushover,
|
||||||
} = notification;
|
} = notification;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (email) {
|
if (email || resend) {
|
||||||
const template = await renderAsync(
|
const template = await renderAsync(
|
||||||
DokployRestartEmail({ date: date.toLocaleString() }),
|
DokployRestartEmail({ date: date.toLocaleString() }),
|
||||||
).catch();
|
).catch();
|
||||||
|
|
||||||
await sendEmailNotification(
|
if (email) {
|
||||||
email,
|
await sendEmailNotification(
|
||||||
"Dokploy Server Restarted",
|
email,
|
||||||
template,
|
"Dokploy Server Restarted",
|
||||||
);
|
template,
|
||||||
}
|
);
|
||||||
|
}
|
||||||
if (discord) {
|
|
||||||
const decorate = (decoration: string, text: string) =>
|
if (resend) {
|
||||||
`${discord.decoration ? decoration : ""} ${text}`.trim();
|
await sendResendNotification(
|
||||||
|
resend,
|
||||||
await sendDiscordNotification(discord, {
|
"Dokploy Server Restarted",
|
||||||
title: decorate(">", "`✅` Dokploy Server Restarted"),
|
template,
|
||||||
color: 0x57f287,
|
);
|
||||||
fields: [
|
}
|
||||||
{
|
}
|
||||||
name: decorate("`📅`", "Date"),
|
|
||||||
value: `<t:${unixDate}:D>`,
|
if (discord) {
|
||||||
inline: true,
|
const decorate = (decoration: string, text: string) =>
|
||||||
},
|
`${discord.decoration ? decoration : ""} ${text}`.trim();
|
||||||
{
|
|
||||||
name: decorate("`⌚`", "Time"),
|
await sendDiscordNotification(discord, {
|
||||||
value: `<t:${unixDate}:t>`,
|
title: decorate(">", "`✅` Dokploy Server Restarted"),
|
||||||
inline: true,
|
color: 0x57f287,
|
||||||
},
|
fields: [
|
||||||
{
|
{
|
||||||
name: decorate("`❓`", "Type"),
|
name: decorate("`📅`", "Date"),
|
||||||
value: "Successful",
|
value: `<t:${unixDate}:D>`,
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
],
|
{
|
||||||
timestamp: date.toISOString(),
|
name: decorate("`⌚`", "Time"),
|
||||||
footer: {
|
value: `<t:${unixDate}:t>`,
|
||||||
text: "Dokploy Restart Notification",
|
inline: true,
|
||||||
},
|
},
|
||||||
});
|
{
|
||||||
}
|
name: decorate("`❓`", "Type"),
|
||||||
|
value: "Successful",
|
||||||
if (gotify) {
|
inline: true,
|
||||||
const decorate = (decoration: string, text: string) =>
|
},
|
||||||
`${gotify.decoration ? decoration : ""} ${text}\n`;
|
],
|
||||||
await sendGotifyNotification(
|
timestamp: date.toISOString(),
|
||||||
gotify,
|
footer: {
|
||||||
decorate("✅", "Dokploy Server Restarted"),
|
text: "Dokploy Restart Notification",
|
||||||
`${decorate("🕒", `Date: ${date.toLocaleString()}`)}`,
|
},
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ntfy) {
|
if (gotify) {
|
||||||
await sendNtfyNotification(
|
const decorate = (decoration: string, text: string) =>
|
||||||
ntfy,
|
`${gotify.decoration ? decoration : ""} ${text}\n`;
|
||||||
"Dokploy Server Restarted",
|
await sendGotifyNotification(
|
||||||
"white_check_mark",
|
gotify,
|
||||||
"",
|
decorate("✅", "Dokploy Server Restarted"),
|
||||||
`🕒Date: ${date.toLocaleString()}`,
|
`${decorate("🕒", `Date: ${date.toLocaleString()}`)}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (telegram) {
|
if (ntfy) {
|
||||||
await sendTelegramNotification(
|
await sendNtfyNotification(
|
||||||
telegram,
|
ntfy,
|
||||||
`<b>✅ Dokploy Server Restarted</b>\n\n<b>Date:</b> ${format(
|
"Dokploy Server Restarted",
|
||||||
date,
|
"white_check_mark",
|
||||||
"PP",
|
"",
|
||||||
)}\n<b>Time:</b> ${format(date, "pp")}`,
|
`🕒Date: ${date.toLocaleString()}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slack) {
|
if (telegram) {
|
||||||
const { channel } = slack;
|
await sendTelegramNotification(
|
||||||
await sendSlackNotification(slack, {
|
telegram,
|
||||||
channel: channel,
|
`<b>✅ Dokploy Server Restarted</b>\n\n<b>Date:</b> ${format(
|
||||||
attachments: [
|
date,
|
||||||
{
|
"PP",
|
||||||
color: "#00FF00",
|
)}\n<b>Time:</b> ${format(date, "pp")}`,
|
||||||
pretext: ":white_check_mark: *Dokploy Server Restarted*",
|
);
|
||||||
fields: [
|
}
|
||||||
{
|
|
||||||
title: "Time",
|
if (slack) {
|
||||||
value: date.toLocaleString(),
|
const { channel } = slack;
|
||||||
short: true,
|
await sendSlackNotification(slack, {
|
||||||
},
|
channel: channel,
|
||||||
],
|
attachments: [
|
||||||
},
|
{
|
||||||
],
|
color: "#00FF00",
|
||||||
});
|
pretext: ":white_check_mark: *Dokploy Server Restarted*",
|
||||||
}
|
fields: [
|
||||||
|
{
|
||||||
if (custom) {
|
title: "Time",
|
||||||
try {
|
value: date.toLocaleString(),
|
||||||
await sendCustomNotification(custom, {
|
short: true,
|
||||||
title: "Dokploy Server Restarted",
|
},
|
||||||
message: "Dokploy server has been restarted successfully",
|
],
|
||||||
timestamp: date.toISOString(),
|
},
|
||||||
date: date.toLocaleString(),
|
],
|
||||||
status: "success",
|
});
|
||||||
type: "dokploy-restart",
|
}
|
||||||
});
|
|
||||||
} catch (error) {
|
if (custom) {
|
||||||
console.log(error);
|
try {
|
||||||
}
|
await sendCustomNotification(custom, {
|
||||||
}
|
title: "Dokploy Server Restarted",
|
||||||
|
message: "Dokploy server has been restarted successfully",
|
||||||
if (lark) {
|
timestamp: date.toISOString(),
|
||||||
await sendLarkNotification(lark, {
|
date: date.toLocaleString(),
|
||||||
msg_type: "interactive",
|
status: "success",
|
||||||
card: {
|
type: "dokploy-restart",
|
||||||
schema: "2.0",
|
});
|
||||||
config: {
|
} catch (error) {
|
||||||
update_multi: true,
|
console.log(error);
|
||||||
style: {
|
}
|
||||||
text_size: {
|
}
|
||||||
normal_v2: {
|
|
||||||
default: "normal",
|
if (lark) {
|
||||||
pc: "normal",
|
await sendLarkNotification(lark, {
|
||||||
mobile: "heading",
|
msg_type: "interactive",
|
||||||
},
|
card: {
|
||||||
},
|
schema: "2.0",
|
||||||
},
|
config: {
|
||||||
},
|
update_multi: true,
|
||||||
header: {
|
style: {
|
||||||
title: {
|
text_size: {
|
||||||
tag: "plain_text",
|
normal_v2: {
|
||||||
content: "✅ Dokploy Server Restarted",
|
default: "normal",
|
||||||
},
|
pc: "normal",
|
||||||
subtitle: {
|
mobile: "heading",
|
||||||
tag: "plain_text",
|
},
|
||||||
content: "",
|
},
|
||||||
},
|
},
|
||||||
template: "green",
|
},
|
||||||
padding: "12px 12px 12px 12px",
|
header: {
|
||||||
},
|
title: {
|
||||||
body: {
|
tag: "plain_text",
|
||||||
direction: "vertical",
|
content: "✅ Dokploy Server Restarted",
|
||||||
padding: "12px 12px 12px 12px",
|
},
|
||||||
elements: [
|
subtitle: {
|
||||||
{
|
tag: "plain_text",
|
||||||
tag: "column_set",
|
content: "",
|
||||||
columns: [
|
},
|
||||||
{
|
template: "green",
|
||||||
tag: "column",
|
padding: "12px 12px 12px 12px",
|
||||||
width: "weighted",
|
},
|
||||||
elements: [
|
body: {
|
||||||
{
|
direction: "vertical",
|
||||||
tag: "markdown",
|
padding: "12px 12px 12px 12px",
|
||||||
content: "**Status:**\nSuccessful",
|
elements: [
|
||||||
text_align: "left",
|
{
|
||||||
text_size: "normal_v2",
|
tag: "column_set",
|
||||||
},
|
columns: [
|
||||||
],
|
{
|
||||||
vertical_align: "top",
|
tag: "column",
|
||||||
weight: 1,
|
width: "weighted",
|
||||||
},
|
elements: [
|
||||||
{
|
{
|
||||||
tag: "column",
|
tag: "markdown",
|
||||||
width: "weighted",
|
content: "**Status:**\nSuccessful",
|
||||||
elements: [
|
text_align: "left",
|
||||||
{
|
text_size: "normal_v2",
|
||||||
tag: "markdown",
|
},
|
||||||
content: `**Restart Time:**\n${format(
|
],
|
||||||
date,
|
vertical_align: "top",
|
||||||
"PP pp",
|
weight: 1,
|
||||||
)}`,
|
},
|
||||||
text_align: "left",
|
{
|
||||||
text_size: "normal_v2",
|
tag: "column",
|
||||||
},
|
width: "weighted",
|
||||||
],
|
elements: [
|
||||||
vertical_align: "top",
|
{
|
||||||
weight: 1,
|
tag: "markdown",
|
||||||
},
|
content: `**Restart Time:**\n${format(
|
||||||
],
|
date,
|
||||||
},
|
"PP pp",
|
||||||
],
|
)}`,
|
||||||
},
|
text_align: "left",
|
||||||
},
|
text_size: "normal_v2",
|
||||||
});
|
},
|
||||||
}
|
],
|
||||||
|
vertical_align: "top",
|
||||||
if (pushover) {
|
weight: 1,
|
||||||
await sendPushoverNotification(
|
},
|
||||||
pushover,
|
],
|
||||||
"Dokploy Server Restarted",
|
},
|
||||||
`Date: ${date.toLocaleString()}`,
|
],
|
||||||
);
|
},
|
||||||
}
|
},
|
||||||
} catch (error) {
|
});
|
||||||
console.log(error);
|
}
|
||||||
}
|
|
||||||
}
|
if (pushover) {
|
||||||
};
|
await sendPushoverNotification(
|
||||||
|
pushover,
|
||||||
|
"Dokploy Server Restarted",
|
||||||
|
`Date: ${date.toLocaleString()}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,256 +1,284 @@
|
|||||||
import type {
|
import type {
|
||||||
custom,
|
custom,
|
||||||
discord,
|
discord,
|
||||||
email,
|
email,
|
||||||
gotify,
|
gotify,
|
||||||
lark,
|
lark,
|
||||||
ntfy,
|
ntfy,
|
||||||
pushover,
|
pushover,
|
||||||
|
resend,
|
||||||
slack,
|
slack,
|
||||||
telegram,
|
telegram,
|
||||||
} from "@dokploy/server/db/schema";
|
} from "@dokploy/server/db/schema";
|
||||||
import nodemailer from "nodemailer";
|
import nodemailer from "nodemailer";
|
||||||
|
import { Resend } from "resend";
|
||||||
export const sendEmailNotification = async (
|
|
||||||
connection: typeof email.$inferInsert,
|
export const sendEmailNotification = async (
|
||||||
subject: string,
|
connection: typeof email.$inferInsert,
|
||||||
htmlContent: string,
|
subject: string,
|
||||||
) => {
|
htmlContent: string,
|
||||||
try {
|
) => {
|
||||||
const {
|
try {
|
||||||
smtpServer,
|
const {
|
||||||
smtpPort,
|
smtpServer,
|
||||||
username,
|
smtpPort,
|
||||||
password,
|
username,
|
||||||
fromAddress,
|
password,
|
||||||
toAddresses,
|
fromAddress,
|
||||||
} = connection;
|
toAddresses,
|
||||||
const transporter = nodemailer.createTransport({
|
} = connection;
|
||||||
host: smtpServer,
|
const transporter = nodemailer.createTransport({
|
||||||
port: smtpPort,
|
host: smtpServer,
|
||||||
auth: { user: username, pass: password },
|
port: smtpPort,
|
||||||
});
|
auth: { user: username, pass: password },
|
||||||
|
});
|
||||||
await transporter.sendMail({
|
|
||||||
from: fromAddress,
|
await transporter.sendMail({
|
||||||
to: toAddresses.join(", "),
|
from: fromAddress,
|
||||||
subject,
|
to: toAddresses.join(", "),
|
||||||
html: htmlContent,
|
subject,
|
||||||
textEncoding: "base64",
|
html: htmlContent,
|
||||||
});
|
textEncoding: "base64",
|
||||||
} catch (err) {
|
});
|
||||||
console.log(err);
|
} catch (err) {
|
||||||
throw new Error(
|
console.log(err);
|
||||||
`Failed to send email notification ${err instanceof Error ? err.message : "Unknown error"}`,
|
throw new Error(
|
||||||
);
|
`Failed to send email notification ${err instanceof Error ? err.message : "Unknown error"}`,
|
||||||
}
|
);
|
||||||
};
|
}
|
||||||
|
};
|
||||||
export const sendDiscordNotification = async (
|
|
||||||
connection: typeof discord.$inferInsert,
|
export const sendResendNotification = async (
|
||||||
embed: any,
|
connection: typeof resend.$inferInsert,
|
||||||
) => {
|
subject: string,
|
||||||
try {
|
htmlContent: string,
|
||||||
const response = await fetch(connection.webhookUrl, {
|
) => {
|
||||||
method: "POST",
|
try {
|
||||||
headers: { "Content-Type": "application/json" },
|
const client = new Resend(connection.apiKey);
|
||||||
body: JSON.stringify({ embeds: [embed] }),
|
|
||||||
});
|
const result = await client.emails.send({
|
||||||
if (!response.ok) {
|
from: connection.fromAddress,
|
||||||
throw new Error(
|
to: connection.toAddresses,
|
||||||
`Failed to send discord notification ${response.statusText}`,
|
subject,
|
||||||
);
|
html: htmlContent,
|
||||||
}
|
});
|
||||||
} catch (err) {
|
|
||||||
console.log("error", err);
|
if (result.error) {
|
||||||
throw new Error(
|
throw new Error(result.error.message);
|
||||||
`Failed to send discord notification ${err instanceof Error ? err.message : "Unknown error"}`,
|
}
|
||||||
);
|
} catch (err) {
|
||||||
}
|
console.log(err);
|
||||||
};
|
throw new Error(
|
||||||
|
`Failed to send Resend notification ${err instanceof Error ? err.message : "Unknown error"}`,
|
||||||
export const sendTelegramNotification = async (
|
);
|
||||||
connection: typeof telegram.$inferInsert,
|
}
|
||||||
messageText: string,
|
};
|
||||||
inlineButton?: {
|
|
||||||
text: string;
|
export const sendDiscordNotification = async (
|
||||||
url: string;
|
connection: typeof discord.$inferInsert,
|
||||||
}[][],
|
embed: any,
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const url = `https://api.telegram.org/bot${connection.botToken}/sendMessage`;
|
const response = await fetch(connection.webhookUrl, {
|
||||||
await fetch(url, {
|
method: "POST",
|
||||||
method: "POST",
|
headers: { "Content-Type": "application/json" },
|
||||||
headers: { "Content-Type": "application/json" },
|
body: JSON.stringify({ embeds: [embed] }),
|
||||||
body: JSON.stringify({
|
});
|
||||||
chat_id: connection.chatId,
|
if (!response.ok) {
|
||||||
message_thread_id: connection.messageThreadId,
|
throw new Error(
|
||||||
text: messageText,
|
`Failed to send discord notification ${response.statusText}`,
|
||||||
parse_mode: "HTML",
|
);
|
||||||
disable_web_page_preview: true,
|
}
|
||||||
reply_markup: {
|
} catch (err) {
|
||||||
inline_keyboard: inlineButton,
|
console.log("error", err);
|
||||||
},
|
throw new Error(
|
||||||
}),
|
`Failed to send discord notification ${err instanceof Error ? err.message : "Unknown error"}`,
|
||||||
});
|
);
|
||||||
} catch (err) {
|
}
|
||||||
console.log(err);
|
};
|
||||||
}
|
|
||||||
};
|
export const sendTelegramNotification = async (
|
||||||
|
connection: typeof telegram.$inferInsert,
|
||||||
export const sendSlackNotification = async (
|
messageText: string,
|
||||||
connection: typeof slack.$inferInsert,
|
inlineButton?: {
|
||||||
message: any,
|
text: string;
|
||||||
) => {
|
url: string;
|
||||||
try {
|
}[][],
|
||||||
const response = await fetch(connection.webhookUrl, {
|
) => {
|
||||||
method: "POST",
|
try {
|
||||||
headers: { "Content-Type": "application/json" },
|
const url = `https://api.telegram.org/bot${connection.botToken}/sendMessage`;
|
||||||
body: JSON.stringify(message),
|
await fetch(url, {
|
||||||
});
|
method: "POST",
|
||||||
if (!response.ok) {
|
headers: { "Content-Type": "application/json" },
|
||||||
throw new Error(
|
body: JSON.stringify({
|
||||||
`Failed to send slack notification ${response.statusText}`,
|
chat_id: connection.chatId,
|
||||||
);
|
message_thread_id: connection.messageThreadId,
|
||||||
}
|
text: messageText,
|
||||||
} catch (err) {
|
parse_mode: "HTML",
|
||||||
console.log("error", err);
|
disable_web_page_preview: true,
|
||||||
throw new Error(
|
reply_markup: {
|
||||||
`Failed to send slack notification ${err instanceof Error ? err.message : "Unknown error"}`,
|
inline_keyboard: inlineButton,
|
||||||
);
|
},
|
||||||
}
|
}),
|
||||||
};
|
});
|
||||||
|
} catch (err) {
|
||||||
export const sendGotifyNotification = async (
|
console.log(err);
|
||||||
connection: typeof gotify.$inferInsert,
|
}
|
||||||
title: string,
|
};
|
||||||
message: string,
|
|
||||||
) => {
|
export const sendSlackNotification = async (
|
||||||
const response = await fetch(`${connection.serverUrl}/message`, {
|
connection: typeof slack.$inferInsert,
|
||||||
method: "POST",
|
message: any,
|
||||||
headers: {
|
) => {
|
||||||
"Content-Type": "application/json",
|
try {
|
||||||
"X-Gotify-Key": connection.appToken,
|
const response = await fetch(connection.webhookUrl, {
|
||||||
},
|
method: "POST",
|
||||||
body: JSON.stringify({
|
headers: { "Content-Type": "application/json" },
|
||||||
title: title,
|
body: JSON.stringify(message),
|
||||||
message: message,
|
});
|
||||||
priority: connection.priority,
|
if (!response.ok) {
|
||||||
extras: {
|
throw new Error(
|
||||||
"client::display": {
|
`Failed to send slack notification ${response.statusText}`,
|
||||||
contentType: "text/plain",
|
);
|
||||||
},
|
}
|
||||||
},
|
} catch (err) {
|
||||||
}),
|
console.log("error", err);
|
||||||
});
|
throw new Error(
|
||||||
|
`Failed to send slack notification ${err instanceof Error ? err.message : "Unknown error"}`,
|
||||||
if (!response.ok) {
|
);
|
||||||
throw new Error(
|
}
|
||||||
`Failed to send Gotify notification: ${response.statusText}`,
|
};
|
||||||
);
|
|
||||||
}
|
export const sendGotifyNotification = async (
|
||||||
};
|
connection: typeof gotify.$inferInsert,
|
||||||
|
title: string,
|
||||||
export const sendNtfyNotification = async (
|
message: string,
|
||||||
connection: typeof ntfy.$inferInsert,
|
) => {
|
||||||
title: string,
|
const response = await fetch(`${connection.serverUrl}/message`, {
|
||||||
tags: string,
|
method: "POST",
|
||||||
actions: string,
|
headers: {
|
||||||
message: string,
|
"Content-Type": "application/json",
|
||||||
) => {
|
"X-Gotify-Key": connection.appToken,
|
||||||
const response = await fetch(`${connection.serverUrl}/${connection.topic}`, {
|
},
|
||||||
method: "POST",
|
body: JSON.stringify({
|
||||||
headers: {
|
title: title,
|
||||||
...(connection.accessToken && {
|
message: message,
|
||||||
Authorization: `Bearer ${connection.accessToken}`,
|
priority: connection.priority,
|
||||||
}),
|
extras: {
|
||||||
"X-Priority": connection.priority?.toString() || "3",
|
"client::display": {
|
||||||
"X-Title": title,
|
contentType: "text/plain",
|
||||||
"X-Tags": tags,
|
},
|
||||||
"X-Actions": actions,
|
},
|
||||||
},
|
}),
|
||||||
body: message,
|
});
|
||||||
});
|
|
||||||
|
if (!response.ok) {
|
||||||
if (!response.ok) {
|
throw new Error(
|
||||||
throw new Error(`Failed to send ntfy notification: ${response.statusText}`);
|
`Failed to send Gotify notification: ${response.statusText}`,
|
||||||
}
|
);
|
||||||
};
|
}
|
||||||
|
};
|
||||||
export const sendCustomNotification = async (
|
|
||||||
connection: typeof custom.$inferInsert,
|
export const sendNtfyNotification = async (
|
||||||
payload: Record<string, any>,
|
connection: typeof ntfy.$inferInsert,
|
||||||
) => {
|
title: string,
|
||||||
try {
|
tags: string,
|
||||||
// Merge default headers with custom headers (now already an object from jsonb)
|
actions: string,
|
||||||
const headers: Record<string, string> = {
|
message: string,
|
||||||
"Content-Type": "application/json",
|
) => {
|
||||||
...(connection.headers || {}),
|
const response = await fetch(`${connection.serverUrl}/${connection.topic}`, {
|
||||||
};
|
method: "POST",
|
||||||
|
headers: {
|
||||||
// Default body with payload
|
...(connection.accessToken && {
|
||||||
const body = JSON.stringify(payload);
|
Authorization: `Bearer ${connection.accessToken}`,
|
||||||
|
}),
|
||||||
const response = await fetch(connection.endpoint, {
|
"X-Priority": connection.priority?.toString() || "3",
|
||||||
method: "POST",
|
"X-Title": title,
|
||||||
headers,
|
"X-Tags": tags,
|
||||||
body,
|
"X-Actions": actions,
|
||||||
});
|
},
|
||||||
|
body: message,
|
||||||
if (!response.ok) {
|
});
|
||||||
throw new Error(
|
|
||||||
`Failed to send custom notification: ${response.statusText}`,
|
if (!response.ok) {
|
||||||
);
|
throw new Error(`Failed to send ntfy notification: ${response.statusText}`);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
return response;
|
|
||||||
} catch (error) {
|
export const sendCustomNotification = async (
|
||||||
console.error("Error sending custom notification:", error);
|
connection: typeof custom.$inferInsert,
|
||||||
throw error;
|
payload: Record<string, any>,
|
||||||
}
|
) => {
|
||||||
};
|
try {
|
||||||
|
// Merge default headers with custom headers (now already an object from jsonb)
|
||||||
export const sendLarkNotification = async (
|
const headers: Record<string, string> = {
|
||||||
connection: typeof lark.$inferInsert,
|
"Content-Type": "application/json",
|
||||||
message: any,
|
...(connection.headers || {}),
|
||||||
) => {
|
};
|
||||||
try {
|
|
||||||
await fetch(connection.webhookUrl, {
|
// Default body with payload
|
||||||
method: "POST",
|
const body = JSON.stringify(payload);
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
body: JSON.stringify(message),
|
const response = await fetch(connection.endpoint, {
|
||||||
});
|
method: "POST",
|
||||||
} catch (err) {
|
headers,
|
||||||
console.log(err);
|
body,
|
||||||
}
|
});
|
||||||
};
|
|
||||||
|
if (!response.ok) {
|
||||||
export const sendPushoverNotification = async (
|
throw new Error(
|
||||||
connection: typeof pushover.$inferInsert,
|
`Failed to send custom notification: ${response.statusText}`,
|
||||||
title: string,
|
);
|
||||||
message: string,
|
}
|
||||||
) => {
|
|
||||||
const formData = new URLSearchParams();
|
return response;
|
||||||
formData.append("token", connection.apiToken);
|
} catch (error) {
|
||||||
formData.append("user", connection.userKey);
|
console.error("Error sending custom notification:", error);
|
||||||
formData.append("title", title);
|
throw error;
|
||||||
formData.append("message", message);
|
}
|
||||||
formData.append("priority", connection.priority?.toString() || "0");
|
};
|
||||||
|
|
||||||
// For emergency priority (2), retry and expire are required
|
export const sendLarkNotification = async (
|
||||||
if (connection.priority === 2) {
|
connection: typeof lark.$inferInsert,
|
||||||
formData.append("retry", connection.retry?.toString() || "30");
|
message: any,
|
||||||
formData.append("expire", connection.expire?.toString() || "3600");
|
) => {
|
||||||
}
|
try {
|
||||||
|
await fetch(connection.webhookUrl, {
|
||||||
const response = await fetch("https://api.pushover.net/1/messages.json", {
|
method: "POST",
|
||||||
method: "POST",
|
headers: { "Content-Type": "application/json" },
|
||||||
body: formData,
|
body: JSON.stringify(message),
|
||||||
});
|
});
|
||||||
|
} catch (err) {
|
||||||
if (!response.ok) {
|
console.log(err);
|
||||||
throw new Error(
|
}
|
||||||
`Failed to send Pushover notification: ${response.statusText}`,
|
};
|
||||||
);
|
|
||||||
}
|
export const sendPushoverNotification = async (
|
||||||
};
|
connection: typeof pushover.$inferInsert,
|
||||||
|
title: string,
|
||||||
|
message: string,
|
||||||
|
) => {
|
||||||
|
const formData = new URLSearchParams();
|
||||||
|
formData.append("token", connection.apiToken);
|
||||||
|
formData.append("user", connection.userKey);
|
||||||
|
formData.append("title", title);
|
||||||
|
formData.append("message", message);
|
||||||
|
formData.append("priority", connection.priority?.toString() || "0");
|
||||||
|
|
||||||
|
// For emergency priority (2), retry and expire are required
|
||||||
|
if (connection.priority === 2) {
|
||||||
|
formData.append("retry", connection.retry?.toString() || "30");
|
||||||
|
formData.append("expire", connection.expire?.toString() || "3600");
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch("https://api.pushover.net/1/messages.json", {
|
||||||
|
method: "POST",
|
||||||
|
body: formData,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(
|
||||||
|
`Failed to send Pushover notification: ${response.statusText}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,285 +1,300 @@
|
|||||||
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 { VolumeBackupEmail } from "@dokploy/server/emails/emails/volume-backup";
|
import { VolumeBackupEmail } from "@dokploy/server/emails/emails/volume-backup";
|
||||||
import { renderAsync } from "@react-email/components";
|
import { renderAsync } from "@react-email/components";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import { and, eq } from "drizzle-orm";
|
import { and, eq } from "drizzle-orm";
|
||||||
import {
|
import {
|
||||||
sendDiscordNotification,
|
sendDiscordNotification,
|
||||||
sendEmailNotification,
|
sendEmailNotification,
|
||||||
sendGotifyNotification,
|
sendGotifyNotification,
|
||||||
sendNtfyNotification,
|
sendNtfyNotification,
|
||||||
sendPushoverNotification,
|
sendPushoverNotification,
|
||||||
|
sendResendNotification,
|
||||||
sendSlackNotification,
|
sendSlackNotification,
|
||||||
sendTelegramNotification,
|
sendTelegramNotification,
|
||||||
} from "./utils";
|
} from "./utils";
|
||||||
|
|
||||||
export const sendVolumeBackupNotifications = async ({
|
export const sendVolumeBackupNotifications = async ({
|
||||||
projectName,
|
projectName,
|
||||||
applicationName,
|
applicationName,
|
||||||
volumeName,
|
volumeName,
|
||||||
serviceType,
|
serviceType,
|
||||||
type,
|
type,
|
||||||
errorMessage,
|
errorMessage,
|
||||||
organizationId,
|
organizationId,
|
||||||
backupSize,
|
backupSize,
|
||||||
}: {
|
}: {
|
||||||
projectName: string;
|
projectName: string;
|
||||||
applicationName: string;
|
applicationName: string;
|
||||||
volumeName: string;
|
volumeName: string;
|
||||||
serviceType:
|
serviceType:
|
||||||
| "application"
|
| "application"
|
||||||
| "postgres"
|
| "postgres"
|
||||||
| "mysql"
|
| "mysql"
|
||||||
| "mongodb"
|
| "mongodb"
|
||||||
| "mariadb"
|
| "mariadb"
|
||||||
| "redis"
|
| "redis"
|
||||||
| "compose";
|
| "compose";
|
||||||
type: "error" | "success";
|
type: "error" | "success";
|
||||||
organizationId: string;
|
organizationId: string;
|
||||||
errorMessage?: string;
|
errorMessage?: string;
|
||||||
backupSize?: string;
|
backupSize?: string;
|
||||||
}) => {
|
}) => {
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
const unixDate = ~~(Number(date) / 1000);
|
const unixDate = ~~(Number(date) / 1000);
|
||||||
const notificationList = await db.query.notifications.findMany({
|
const notificationList = await db.query.notifications.findMany({
|
||||||
where: and(
|
where: and(
|
||||||
eq(notifications.volumeBackup, true),
|
eq(notifications.volumeBackup, true),
|
||||||
eq(notifications.organizationId, organizationId),
|
eq(notifications.organizationId, organizationId),
|
||||||
),
|
),
|
||||||
with: {
|
with: {
|
||||||
email: true,
|
email: true,
|
||||||
discord: true,
|
discord: true,
|
||||||
telegram: true,
|
telegram: true,
|
||||||
slack: true,
|
slack: true,
|
||||||
gotify: true,
|
resend: true,
|
||||||
ntfy: true,
|
gotify: true,
|
||||||
pushover: true,
|
ntfy: true,
|
||||||
},
|
pushover: true,
|
||||||
});
|
},
|
||||||
|
});
|
||||||
for (const notification of notificationList) {
|
|
||||||
const { email, discord, telegram, slack, gotify, ntfy, pushover } =
|
for (const notification of notificationList) {
|
||||||
notification;
|
const {
|
||||||
|
email,
|
||||||
if (email) {
|
resend,
|
||||||
const subject = `Volume Backup ${type === "success" ? "Successful" : "Failed"} - ${applicationName}`;
|
discord,
|
||||||
const htmlContent = await renderAsync(
|
telegram,
|
||||||
VolumeBackupEmail({
|
slack,
|
||||||
projectName,
|
gotify,
|
||||||
applicationName,
|
ntfy,
|
||||||
volumeName,
|
pushover,
|
||||||
serviceType,
|
} = notification;
|
||||||
type,
|
|
||||||
errorMessage,
|
if (email || resend) {
|
||||||
backupSize,
|
const subject = `Volume Backup ${type === "success" ? "Successful" : "Failed"} - ${applicationName}`;
|
||||||
date: date.toISOString(),
|
const htmlContent = await renderAsync(
|
||||||
}),
|
VolumeBackupEmail({
|
||||||
);
|
projectName,
|
||||||
await sendEmailNotification(email, subject, htmlContent);
|
applicationName,
|
||||||
}
|
volumeName,
|
||||||
|
serviceType,
|
||||||
if (discord) {
|
type,
|
||||||
const decorate = (decoration: string, text: string) =>
|
errorMessage,
|
||||||
`${discord.decoration ? decoration : ""} ${text}`.trim();
|
backupSize,
|
||||||
|
date: date.toISOString(),
|
||||||
await sendDiscordNotification(discord, {
|
}),
|
||||||
title:
|
);
|
||||||
type === "success"
|
if (email) {
|
||||||
? decorate(">", "`✅` Volume Backup Successful")
|
await sendEmailNotification(email, subject, htmlContent);
|
||||||
: decorate(">", "`❌` Volume Backup Failed"),
|
}
|
||||||
color: type === "success" ? 0x57f287 : 0xed4245,
|
if (resend) {
|
||||||
fields: [
|
await sendResendNotification(resend, subject, htmlContent);
|
||||||
{
|
}
|
||||||
name: decorate("`🛠️`", "Project"),
|
}
|
||||||
value: projectName,
|
|
||||||
inline: true,
|
if (discord) {
|
||||||
},
|
const decorate = (decoration: string, text: string) =>
|
||||||
{
|
`${discord.decoration ? decoration : ""} ${text}`.trim();
|
||||||
name: decorate("`⚙️`", "Application"),
|
|
||||||
value: applicationName,
|
await sendDiscordNotification(discord, {
|
||||||
inline: true,
|
title:
|
||||||
},
|
type === "success"
|
||||||
{
|
? decorate(">", "`✅` Volume Backup Successful")
|
||||||
name: decorate("`💾`", "Volume Name"),
|
: decorate(">", "`❌` Volume Backup Failed"),
|
||||||
value: volumeName,
|
color: type === "success" ? 0x57f287 : 0xed4245,
|
||||||
inline: true,
|
fields: [
|
||||||
},
|
{
|
||||||
{
|
name: decorate("`🛠️`", "Project"),
|
||||||
name: decorate("`🔧`", "Service Type"),
|
value: projectName,
|
||||||
value: serviceType,
|
inline: true,
|
||||||
inline: true,
|
},
|
||||||
},
|
{
|
||||||
...(backupSize
|
name: decorate("`⚙️`", "Application"),
|
||||||
? [
|
value: applicationName,
|
||||||
{
|
inline: true,
|
||||||
name: decorate("`📊`", "Backup Size"),
|
},
|
||||||
value: backupSize,
|
{
|
||||||
inline: true,
|
name: decorate("`💾`", "Volume Name"),
|
||||||
},
|
value: volumeName,
|
||||||
]
|
inline: true,
|
||||||
: []),
|
},
|
||||||
{
|
{
|
||||||
name: decorate("`📅`", "Date"),
|
name: decorate("`🔧`", "Service Type"),
|
||||||
value: `<t:${unixDate}:D>`,
|
value: serviceType,
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
...(backupSize
|
||||||
name: decorate("`⌚`", "Time"),
|
? [
|
||||||
value: `<t:${unixDate}:t>`,
|
{
|
||||||
inline: true,
|
name: decorate("`📊`", "Backup Size"),
|
||||||
},
|
value: backupSize,
|
||||||
{
|
inline: true,
|
||||||
name: decorate("`❓`", "Type"),
|
},
|
||||||
value: type
|
]
|
||||||
.replace("error", "Failed")
|
: []),
|
||||||
.replace("success", "Successful"),
|
{
|
||||||
inline: true,
|
name: decorate("`📅`", "Date"),
|
||||||
},
|
value: `<t:${unixDate}:D>`,
|
||||||
...(type === "error" && errorMessage
|
inline: true,
|
||||||
? [
|
},
|
||||||
{
|
{
|
||||||
name: decorate("`⚠️`", "Error Message"),
|
name: decorate("`⌚`", "Time"),
|
||||||
value: `\`\`\`${errorMessage}\`\`\``,
|
value: `<t:${unixDate}:t>`,
|
||||||
},
|
inline: true,
|
||||||
]
|
},
|
||||||
: []),
|
{
|
||||||
],
|
name: decorate("`❓`", "Type"),
|
||||||
timestamp: date.toISOString(),
|
value: type
|
||||||
footer: {
|
.replace("error", "Failed")
|
||||||
text: "Dokploy Volume Backup Notification",
|
.replace("success", "Successful"),
|
||||||
},
|
inline: true,
|
||||||
});
|
},
|
||||||
}
|
...(type === "error" && errorMessage
|
||||||
|
? [
|
||||||
if (gotify) {
|
{
|
||||||
const decorate = (decoration: string, text: string) =>
|
name: decorate("`⚠️`", "Error Message"),
|
||||||
`${gotify.decoration ? decoration : ""} ${text}\n`;
|
value: `\`\`\`${errorMessage}\`\`\``,
|
||||||
|
},
|
||||||
await sendGotifyNotification(
|
]
|
||||||
gotify,
|
: []),
|
||||||
decorate(
|
],
|
||||||
type === "success" ? "✅" : "❌",
|
timestamp: date.toISOString(),
|
||||||
`Volume Backup ${type === "success" ? "Successful" : "Failed"}`,
|
footer: {
|
||||||
),
|
text: "Dokploy Volume Backup Notification",
|
||||||
`${decorate("🛠️", `Project: ${projectName}`)}` +
|
},
|
||||||
`${decorate("⚙️", `Application: ${applicationName}`)}` +
|
});
|
||||||
`${decorate("💾", `Volume Name: ${volumeName}`)}` +
|
}
|
||||||
`${decorate("🔧", `Service Type: ${serviceType}`)}` +
|
|
||||||
`${backupSize ? decorate("📊", `Backup Size: ${backupSize}`) : ""}` +
|
if (gotify) {
|
||||||
`${decorate("🕒", `Date: ${date.toLocaleString()}`)}` +
|
const decorate = (decoration: string, text: string) =>
|
||||||
`${type === "error" && errorMessage ? decorate("❌", `Error:\n${errorMessage}`) : ""}`,
|
`${gotify.decoration ? decoration : ""} ${text}\n`;
|
||||||
);
|
|
||||||
}
|
await sendGotifyNotification(
|
||||||
|
gotify,
|
||||||
if (ntfy) {
|
decorate(
|
||||||
await sendNtfyNotification(
|
type === "success" ? "✅" : "❌",
|
||||||
ntfy,
|
`Volume Backup ${type === "success" ? "Successful" : "Failed"}`,
|
||||||
`Volume Backup ${type === "success" ? "Successful" : "Failed"}`,
|
),
|
||||||
`${type === "success" ? "white_check_mark" : "x"}`,
|
`${decorate("🛠️", `Project: ${projectName}`)}` +
|
||||||
"",
|
`${decorate("⚙️", `Application: ${applicationName}`)}` +
|
||||||
`🛠️Project: ${projectName}\n` +
|
`${decorate("💾", `Volume Name: ${volumeName}`)}` +
|
||||||
`⚙️Application: ${applicationName}\n` +
|
`${decorate("🔧", `Service Type: ${serviceType}`)}` +
|
||||||
`💾Volume Name: ${volumeName}\n` +
|
`${backupSize ? decorate("📊", `Backup Size: ${backupSize}`) : ""}` +
|
||||||
`🔧Service Type: ${serviceType}\n` +
|
`${decorate("🕒", `Date: ${date.toLocaleString()}`)}` +
|
||||||
`${backupSize ? `📊Backup Size: ${backupSize}\n` : ""}` +
|
`${type === "error" && errorMessage ? decorate("❌", `Error:\n${errorMessage}`) : ""}`,
|
||||||
`🕒Date: ${date.toLocaleString()}\n` +
|
);
|
||||||
`${type === "error" && errorMessage ? `❌Error:\n${errorMessage}` : ""}`,
|
}
|
||||||
);
|
|
||||||
}
|
if (ntfy) {
|
||||||
|
await sendNtfyNotification(
|
||||||
if (telegram) {
|
ntfy,
|
||||||
const isError = type === "error" && errorMessage;
|
`Volume Backup ${type === "success" ? "Successful" : "Failed"}`,
|
||||||
|
`${type === "success" ? "white_check_mark" : "x"}`,
|
||||||
const statusEmoji = type === "success" ? "✅" : "❌";
|
"",
|
||||||
const typeStatus = type === "success" ? "Successful" : "Failed";
|
`🛠️Project: ${projectName}\n` +
|
||||||
const errorMsg = isError
|
`⚙️Application: ${applicationName}\n` +
|
||||||
? `\n\n<b>Error:</b>\n<pre>${errorMessage}</pre>`
|
`💾Volume Name: ${volumeName}\n` +
|
||||||
: "";
|
`🔧Service Type: ${serviceType}\n` +
|
||||||
const sizeInfo = backupSize ? `\n<b>Backup Size:</b> ${backupSize}` : "";
|
`${backupSize ? `📊Backup Size: ${backupSize}\n` : ""}` +
|
||||||
|
`🕒Date: ${date.toLocaleString()}\n` +
|
||||||
const messageText = `<b>${statusEmoji} Volume Backup ${typeStatus}</b>\n\n<b>Project:</b> ${projectName}\n<b>Application:</b> ${applicationName}\n<b>Volume Name:</b> ${volumeName}\n<b>Service Type:</b> ${serviceType}${sizeInfo}\n<b>Date:</b> ${format(date, "PP")}\n<b>Time:</b> ${format(date, "pp")}${isError ? errorMsg : ""}`;
|
`${type === "error" && errorMessage ? `❌Error:\n${errorMessage}` : ""}`,
|
||||||
|
);
|
||||||
await sendTelegramNotification(telegram, messageText);
|
}
|
||||||
}
|
|
||||||
|
if (telegram) {
|
||||||
if (slack) {
|
const isError = type === "error" && errorMessage;
|
||||||
const { channel } = slack;
|
|
||||||
await sendSlackNotification(slack, {
|
const statusEmoji = type === "success" ? "✅" : "❌";
|
||||||
channel: channel,
|
const typeStatus = type === "success" ? "Successful" : "Failed";
|
||||||
attachments: [
|
const errorMsg = isError
|
||||||
{
|
? `\n\n<b>Error:</b>\n<pre>${errorMessage}</pre>`
|
||||||
color: type === "success" ? "#00FF00" : "#FF0000",
|
: "";
|
||||||
pretext:
|
const sizeInfo = backupSize ? `\n<b>Backup Size:</b> ${backupSize}` : "";
|
||||||
type === "success"
|
|
||||||
? ":white_check_mark: *Volume Backup Successful*"
|
const messageText = `<b>${statusEmoji} Volume Backup ${typeStatus}</b>\n\n<b>Project:</b> ${projectName}\n<b>Application:</b> ${applicationName}\n<b>Volume Name:</b> ${volumeName}\n<b>Service Type:</b> ${serviceType}${sizeInfo}\n<b>Date:</b> ${format(date, "PP")}\n<b>Time:</b> ${format(date, "pp")}${isError ? errorMsg : ""}`;
|
||||||
: ":x: *Volume Backup Failed*",
|
|
||||||
fields: [
|
await sendTelegramNotification(telegram, messageText);
|
||||||
...(type === "error" && errorMessage
|
}
|
||||||
? [
|
|
||||||
{
|
if (slack) {
|
||||||
title: "Error Message",
|
const { channel } = slack;
|
||||||
value: errorMessage,
|
await sendSlackNotification(slack, {
|
||||||
short: false,
|
channel: channel,
|
||||||
},
|
attachments: [
|
||||||
]
|
{
|
||||||
: []),
|
color: type === "success" ? "#00FF00" : "#FF0000",
|
||||||
{
|
pretext:
|
||||||
title: "Project",
|
type === "success"
|
||||||
value: projectName,
|
? ":white_check_mark: *Volume Backup Successful*"
|
||||||
short: true,
|
: ":x: *Volume Backup Failed*",
|
||||||
},
|
fields: [
|
||||||
{
|
...(type === "error" && errorMessage
|
||||||
title: "Application",
|
? [
|
||||||
value: applicationName,
|
{
|
||||||
short: true,
|
title: "Error Message",
|
||||||
},
|
value: errorMessage,
|
||||||
{
|
short: false,
|
||||||
title: "Volume Name",
|
},
|
||||||
value: volumeName,
|
]
|
||||||
short: true,
|
: []),
|
||||||
},
|
{
|
||||||
{
|
title: "Project",
|
||||||
title: "Service Type",
|
value: projectName,
|
||||||
value: serviceType,
|
short: true,
|
||||||
short: true,
|
},
|
||||||
},
|
{
|
||||||
...(backupSize
|
title: "Application",
|
||||||
? [
|
value: applicationName,
|
||||||
{
|
short: true,
|
||||||
title: "Backup Size",
|
},
|
||||||
value: backupSize,
|
{
|
||||||
short: true,
|
title: "Volume Name",
|
||||||
},
|
value: volumeName,
|
||||||
]
|
short: true,
|
||||||
: []),
|
},
|
||||||
{
|
{
|
||||||
title: "Time",
|
title: "Service Type",
|
||||||
value: date.toLocaleString(),
|
value: serviceType,
|
||||||
short: true,
|
short: true,
|
||||||
},
|
},
|
||||||
{
|
...(backupSize
|
||||||
title: "Type",
|
? [
|
||||||
value: type,
|
{
|
||||||
short: true,
|
title: "Backup Size",
|
||||||
},
|
value: backupSize,
|
||||||
{
|
short: true,
|
||||||
title: "Status",
|
},
|
||||||
value: type === "success" ? "Successful" : "Failed",
|
]
|
||||||
short: true,
|
: []),
|
||||||
},
|
{
|
||||||
],
|
title: "Time",
|
||||||
},
|
value: date.toLocaleString(),
|
||||||
],
|
short: true,
|
||||||
});
|
},
|
||||||
}
|
{
|
||||||
|
title: "Type",
|
||||||
if (pushover) {
|
value: type,
|
||||||
await sendPushoverNotification(
|
short: true,
|
||||||
pushover,
|
},
|
||||||
`Volume Backup ${type === "success" ? "Successful" : "Failed"}`,
|
{
|
||||||
`Project: ${projectName}\nApplication: ${applicationName}\nVolume: ${volumeName}\nService Type: ${serviceType}${backupSize ? `\nBackup Size: ${backupSize}` : ""}\nDate: ${date.toLocaleString()}${type === "error" && errorMessage ? `\nError: ${errorMessage}` : ""}`,
|
title: "Status",
|
||||||
);
|
value: type === "success" ? "Successful" : "Failed",
|
||||||
}
|
short: true,
|
||||||
}
|
},
|
||||||
};
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pushover) {
|
||||||
|
await sendPushoverNotification(
|
||||||
|
pushover,
|
||||||
|
`Volume Backup ${type === "success" ? "Successful" : "Failed"}`,
|
||||||
|
`Project: ${projectName}\nApplication: ${applicationName}\nVolume: ${volumeName}\nService Type: ${serviceType}${backupSize ? `\nBackup Size: ${backupSize}` : ""}\nDate: ${date.toLocaleString()}${type === "error" && errorMessage ? `\nError: ${errorMessage}` : ""}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
Generated
+50
@@ -711,6 +711,9 @@ importers:
|
|||||||
react-dom:
|
react-dom:
|
||||||
specifier: 18.2.0
|
specifier: 18.2.0
|
||||||
version: 18.2.0([email protected])
|
version: 18.2.0([email protected])
|
||||||
|
resend:
|
||||||
|
specifier: ^6.0.2
|
||||||
|
version: 6.8.0(@react-email/[email protected]([email protected]([email protected]))([email protected]))
|
||||||
semver:
|
semver:
|
||||||
specifier: 7.7.3
|
specifier: 7.7.3
|
||||||
version: 7.7.3
|
version: 7.7.3
|
||||||
@@ -3637,6 +3640,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-TV7t8GKYaJWsn00tFDqBw8+Uqmr8A0fRU1tvTQhyZzGv0sJCGRQL3JGMI3ucuKo3XIZdUP+Lx7/gh2t3lewy7g==}
|
resolution: {integrity: sha512-TV7t8GKYaJWsn00tFDqBw8+Uqmr8A0fRU1tvTQhyZzGv0sJCGRQL3JGMI3ucuKo3XIZdUP+Lx7/gh2t3lewy7g==}
|
||||||
engines: {node: '>=14.16'}
|
engines: {node: '>=14.16'}
|
||||||
|
|
||||||
|
'@stablelib/[email protected]':
|
||||||
|
resolution: {integrity: sha512-1bnPQqSxSuc3Ii6MhBysoWCg58j97aUjuCSZrGSmDxNqtytIi0k8utUenAwTZN4V5mXXYGsVUI9zeBqy+jBOSQ==}
|
||||||
|
|
||||||
'@standard-schema/[email protected]':
|
'@standard-schema/[email protected]':
|
||||||
resolution: {integrity: sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA==}
|
resolution: {integrity: sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA==}
|
||||||
|
|
||||||
@@ -5013,6 +5019,9 @@ packages:
|
|||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==}
|
resolution: {integrity: sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==}
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
resolution: {integrity: sha512-n11RGP/lrWEFI/bWdygLxhI+pVeo1ZYIVwvvPkW7azl/rOy+F3HYRZ2K5zeE9mmkhQppyv9sQFx0JM9UabnpPQ==}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==}
|
resolution: {integrity: sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==}
|
||||||
|
|
||||||
@@ -6686,6 +6695,15 @@ packages:
|
|||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-K/BG6eIky/SBpzfHZv/dd+9JBFiS4SWV7FIujVyJRux6e45+73RaUHXLmIR1f7WOMaQ0U1km6qwklRQxpJJY0w==}
|
resolution: {integrity: sha512-K/BG6eIky/SBpzfHZv/dd+9JBFiS4SWV7FIujVyJRux6e45+73RaUHXLmIR1f7WOMaQ0U1km6qwklRQxpJJY0w==}
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
resolution: {integrity: sha512-fDOXGqafQfQXl8nXe93wr93pus8tW7YPpowenE3SmG7dJJf0hH3xUWm3xqacnPvhqjCQTJH9xETg07rmUeSuqQ==}
|
||||||
|
engines: {node: '>=20'}
|
||||||
|
peerDependencies:
|
||||||
|
'@react-email/render': '*'
|
||||||
|
peerDependenciesMeta:
|
||||||
|
'@react-email/render':
|
||||||
|
optional: true
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==}
|
resolution: {integrity: sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==}
|
||||||
|
|
||||||
@@ -6898,6 +6916,9 @@ packages:
|
|||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==}
|
resolution: {integrity: sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==}
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
resolution: {integrity: sha512-BbHGOQK9olHPMvQNHWul6MYlrRTAOKn03rOe4A8O3CLWhNf4YHBqq2HJKKC+sfqpxiBY52pNeesD6jIiLDz8jg==}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==}
|
resolution: {integrity: sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==}
|
||||||
engines: {node: '>= 0.8'}
|
engines: {node: '>= 0.8'}
|
||||||
@@ -6993,6 +7014,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==}
|
resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
resolution: {integrity: sha512-K8DPPSZaW/XqXiz1kEyzSHYgmGLnhB43nQCMeKjWGCUpLIpAMMM8kx3rVVOSm6Bo6EHyK1RQLPT4R06skM/MlQ==}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-4bO+dhBbasP485Ak67o46cWNVUnV0/92ypb2997bhvxTO2M+IuQZM1ilkN/7nSaiGuxDKJhkuL54I35PVI3AAw==}
|
resolution: {integrity: sha512-4bO+dhBbasP485Ak67o46cWNVUnV0/92ypb2997bhvxTO2M+IuQZM1ilkN/7nSaiGuxDKJhkuL54I35PVI3AAw==}
|
||||||
|
|
||||||
@@ -7273,6 +7297,10 @@ packages:
|
|||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
|
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
resolution: {integrity: sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==}
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==}
|
resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
@@ -10346,6 +10374,8 @@ snapshots:
|
|||||||
|
|
||||||
'@sindresorhus/[email protected]': {}
|
'@sindresorhus/[email protected]': {}
|
||||||
|
|
||||||
|
'@stablelib/[email protected]': {}
|
||||||
|
|
||||||
'@standard-schema/[email protected]': {}
|
'@standard-schema/[email protected]': {}
|
||||||
|
|
||||||
'@stepperize/[email protected]([email protected]([email protected]))([email protected])':
|
'@stepperize/[email protected]([email protected]([email protected]))([email protected])':
|
||||||
@@ -12007,6 +12037,8 @@ snapshots:
|
|||||||
|
|
||||||
[email protected]: {}
|
[email protected]: {}
|
||||||
|
|
||||||
|
[email protected]: {}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
dependencies:
|
dependencies:
|
||||||
reusify: 1.1.0
|
reusify: 1.1.0
|
||||||
@@ -13914,6 +13946,12 @@ snapshots:
|
|||||||
|
|
||||||
[email protected]: {}
|
[email protected]: {}
|
||||||
|
|
||||||
|
[email protected](@react-email/[email protected]([email protected]([email protected]))([email protected])):
|
||||||
|
dependencies:
|
||||||
|
svix: 1.84.1
|
||||||
|
optionalDependencies:
|
||||||
|
'@react-email/render': 0.0.16([email protected]([email protected]))([email protected])
|
||||||
|
|
||||||
[email protected]: {}
|
[email protected]: {}
|
||||||
|
|
||||||
[email protected]: {}
|
[email protected]: {}
|
||||||
@@ -14148,6 +14186,11 @@ snapshots:
|
|||||||
|
|
||||||
[email protected]: {}
|
[email protected]: {}
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
dependencies:
|
||||||
|
'@stablelib/base64': 1.0.1
|
||||||
|
fast-sha256: 1.3.0
|
||||||
|
|
||||||
[email protected]: {}
|
[email protected]: {}
|
||||||
|
|
||||||
[email protected]: {}
|
[email protected]: {}
|
||||||
@@ -14241,6 +14284,11 @@ snapshots:
|
|||||||
|
|
||||||
[email protected]: {}
|
[email protected]: {}
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
dependencies:
|
||||||
|
standardwebhooks: 1.0.0
|
||||||
|
uuid: 10.0.0
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/runtime-corejs3': 7.27.3
|
'@babel/runtime-corejs3': 7.27.3
|
||||||
@@ -14585,6 +14633,8 @@ snapshots:
|
|||||||
|
|
||||||
[email protected]: {}
|
[email protected]: {}
|
||||||
|
|
||||||
|
[email protected]: {}
|
||||||
|
|
||||||
[email protected]: {}
|
[email protected]: {}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
|
|||||||
+12
-1
@@ -69,6 +69,7 @@ enum notificationType {
|
|||||||
telegram
|
telegram
|
||||||
discord
|
discord
|
||||||
email
|
email
|
||||||
|
resend
|
||||||
gotify
|
gotify
|
||||||
ntfy
|
ntfy
|
||||||
custom
|
custom
|
||||||
@@ -455,6 +456,13 @@ table email {
|
|||||||
toAddress text[] [not null]
|
toAddress text[] [not null]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table resend {
|
||||||
|
resendId text [pk, not null]
|
||||||
|
apiKey text [not null]
|
||||||
|
fromAddress text [not null]
|
||||||
|
toAddress text[] [not null]
|
||||||
|
}
|
||||||
|
|
||||||
table environment {
|
table environment {
|
||||||
environmentId text [pk, not null]
|
environmentId text [pk, not null]
|
||||||
name text [not null]
|
name text [not null]
|
||||||
@@ -691,6 +699,7 @@ table notification {
|
|||||||
telegramId text
|
telegramId text
|
||||||
discordId text
|
discordId text
|
||||||
emailId text
|
emailId text
|
||||||
|
resendId text
|
||||||
gotifyId text
|
gotifyId text
|
||||||
ntfyId text
|
ntfyId text
|
||||||
customId text
|
customId text
|
||||||
@@ -1133,6 +1142,8 @@ ref: notification.discordId - discord.discordId
|
|||||||
|
|
||||||
ref: notification.emailId - email.emailId
|
ref: notification.emailId - email.emailId
|
||||||
|
|
||||||
|
ref: notification.resendId - resend.resendId
|
||||||
|
|
||||||
ref: notification.gotifyId - gotify.gotifyId
|
ref: notification.gotifyId - gotify.gotifyId
|
||||||
|
|
||||||
ref: notification.ntfyId - ntfy.ntfyId
|
ref: notification.ntfyId - ntfy.ntfyId
|
||||||
@@ -1191,4 +1202,4 @@ ref: volume_backup.redisId - redis.redisId
|
|||||||
|
|
||||||
ref: volume_backup.composeId - compose.composeId
|
ref: volume_backup.composeId - compose.composeId
|
||||||
|
|
||||||
ref: volume_backup.destinationId - destination.destinationId
|
ref: volume_backup.destinationId - destination.destinationId
|
||||||
|
|||||||
Reference in New Issue
Block a user