mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
Revision notification (#7)
* Update build-success.ts * Update compose.ts * Update application.ts * Update notification.ts * Update utils.ts * Update dokploy-restart.ts * Update docker-cleanup.ts * Update database-backup.ts * Update build-success.ts * Update build-success.ts
This commit is contained in:
@@ -134,7 +134,7 @@ export const notificationRouter = createTRPCRouter({
|
|||||||
.input(apiTestTelegramConnection)
|
.input(apiTestTelegramConnection)
|
||||||
.mutation(async ({ input }) => {
|
.mutation(async ({ input }) => {
|
||||||
try {
|
try {
|
||||||
await sendTelegramNotification(input, "Hi, From Dokploy 👋", []);
|
await sendTelegramNotification(input, "Hi, From Dokploy 👋");
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
|
|||||||
@@ -176,7 +176,6 @@ export const deployApplication = async ({
|
|||||||
}) => {
|
}) => {
|
||||||
const application = await findApplicationById(applicationId);
|
const application = await findApplicationById(applicationId);
|
||||||
const buildLink = `${await getDokployUrl()}/dashboard/project/${application.projectId}/services/application/${application.applicationId}?tab=deployments`;
|
const buildLink = `${await getDokployUrl()}/dashboard/project/${application.projectId}/services/application/${application.applicationId}?tab=deployments`;
|
||||||
const domains = application.domains.map(({ host, https }) => ({ host, https }));
|
|
||||||
const deployment = await createDeployment({
|
const deployment = await createDeployment({
|
||||||
applicationId: applicationId,
|
applicationId: applicationId,
|
||||||
title: titleLog,
|
title: titleLog,
|
||||||
@@ -214,7 +213,7 @@ export const deployApplication = async ({
|
|||||||
applicationType: "application",
|
applicationType: "application",
|
||||||
buildLink,
|
buildLink,
|
||||||
adminId: application.project.adminId,
|
adminId: application.project.adminId,
|
||||||
domains
|
domains: application.domains
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await updateDeploymentStatus(deployment.deploymentId, "error");
|
await updateDeploymentStatus(deployment.deploymentId, "error");
|
||||||
@@ -287,7 +286,6 @@ export const deployRemoteApplication = async ({
|
|||||||
}) => {
|
}) => {
|
||||||
const application = await findApplicationById(applicationId);
|
const application = await findApplicationById(applicationId);
|
||||||
const buildLink = `${await getDokployUrl()}/dashboard/project/${application.projectId}/services/application/${application.applicationId}?tab=deployments`;
|
const buildLink = `${await getDokployUrl()}/dashboard/project/${application.projectId}/services/application/${application.applicationId}?tab=deployments`;
|
||||||
const domains = application.domains.map(({ host, https }) => ({ host, https }));
|
|
||||||
const deployment = await createDeployment({
|
const deployment = await createDeployment({
|
||||||
applicationId: applicationId,
|
applicationId: applicationId,
|
||||||
title: titleLog,
|
title: titleLog,
|
||||||
@@ -335,7 +333,7 @@ export const deployRemoteApplication = async ({
|
|||||||
applicationType: "application",
|
applicationType: "application",
|
||||||
buildLink,
|
buildLink,
|
||||||
adminId: application.project.adminId,
|
adminId: application.project.adminId,
|
||||||
domains
|
domains: application.domains
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|||||||
@@ -209,7 +209,6 @@ export const deployCompose = async ({
|
|||||||
const buildLink = `${await getDokployUrl()}/dashboard/project/${
|
const buildLink = `${await getDokployUrl()}/dashboard/project/${
|
||||||
compose.projectId
|
compose.projectId
|
||||||
}/services/compose/${compose.composeId}?tab=deployments`;
|
}/services/compose/${compose.composeId}?tab=deployments`;
|
||||||
const domains = compose.domains.map(({ host, https }) => ({ host, https }));
|
|
||||||
const deployment = await createDeploymentCompose({
|
const deployment = await createDeploymentCompose({
|
||||||
composeId: composeId,
|
composeId: composeId,
|
||||||
title: titleLog,
|
title: titleLog,
|
||||||
@@ -244,7 +243,7 @@ export const deployCompose = async ({
|
|||||||
applicationType: "compose",
|
applicationType: "compose",
|
||||||
buildLink,
|
buildLink,
|
||||||
adminId: compose.project.adminId,
|
adminId: compose.project.adminId,
|
||||||
domains
|
domains: compose.domains,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await updateDeploymentStatus(deployment.deploymentId, "error");
|
await updateDeploymentStatus(deployment.deploymentId, "error");
|
||||||
@@ -315,7 +314,6 @@ export const deployRemoteCompose = async ({
|
|||||||
const buildLink = `${await getDokployUrl()}/dashboard/project/${
|
const buildLink = `${await getDokployUrl()}/dashboard/project/${
|
||||||
compose.projectId
|
compose.projectId
|
||||||
}/services/compose/${compose.composeId}?tab=deployments`;
|
}/services/compose/${compose.composeId}?tab=deployments`;
|
||||||
const domains = compose.domains.map(({ host, https }) => ({ host, https }));
|
|
||||||
const deployment = await createDeploymentCompose({
|
const deployment = await createDeploymentCompose({
|
||||||
composeId: composeId,
|
composeId: composeId,
|
||||||
title: titleLog,
|
title: titleLog,
|
||||||
@@ -369,7 +367,7 @@ export const deployRemoteCompose = async ({
|
|||||||
applicationType: "compose",
|
applicationType: "compose",
|
||||||
buildLink,
|
buildLink,
|
||||||
adminId: compose.project.adminId,
|
adminId: compose.project.adminId,
|
||||||
domains
|
domains: compose.domains,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
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 { Domain } from "@dokploy/server/services/domain";
|
||||||
import { renderAsync } from "@react-email/components";
|
import { renderAsync } from "@react-email/components";
|
||||||
import { and, eq } from "drizzle-orm";
|
import { and, eq } from "drizzle-orm";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
@@ -17,10 +18,7 @@ interface Props {
|
|||||||
applicationType: string;
|
applicationType: string;
|
||||||
buildLink: string;
|
buildLink: string;
|
||||||
adminId: string;
|
adminId: string;
|
||||||
domains: {
|
domains: Domain[];
|
||||||
host: string;
|
|
||||||
https: boolean;
|
|
||||||
}[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const sendBuildSuccessNotifications = async ({
|
export const sendBuildSuccessNotifications = async ({
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ export const sendDatabaseBackupNotifications = async ({
|
|||||||
|
|
||||||
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>Date:</b> ${format(date, "PP")}\n<b>Time:</b> ${format(date, "pp")}${isError ? errorMsg : ""}`;
|
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>Date:</b> ${format(date, "PP")}\n<b>Time:</b> ${format(date, "pp")}${isError ? errorMsg : ""}`;
|
||||||
|
|
||||||
await sendTelegramNotification(telegram, messageText, []);
|
await sendTelegramNotification(telegram, messageText);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slack) {
|
if (slack) {
|
||||||
|
|||||||
@@ -83,8 +83,7 @@ export const sendDockerCleanupNotifications = async (
|
|||||||
if (telegram) {
|
if (telegram) {
|
||||||
await sendTelegramNotification(
|
await sendTelegramNotification(
|
||||||
telegram,
|
telegram,
|
||||||
`<b>✅ Docker Cleanup</b>\n\n<b>Message:</b> ${message}\n<b>Date:</b> ${format(date, "PP")}\n<b>Time:</b> ${format(date, "pp")}`,
|
`<b>✅ Docker Cleanup</b>\n\n<b>Message:</b> ${message}\n<b>Date:</b> ${format(date, "PP")}\n<b>Time:</b> ${format(date, "pp")}`
|
||||||
[]
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,8 +68,7 @@ export const sendDokployRestartNotifications = async () => {
|
|||||||
if (telegram) {
|
if (telegram) {
|
||||||
await sendTelegramNotification(
|
await sendTelegramNotification(
|
||||||
telegram,
|
telegram,
|
||||||
`<b>✅ Dokploy Serverd Restarted</b>\n\n<b>Date:</b> ${format(date, "PP")}\n<b>Time:</b> ${format(date, "pp")}`,
|
`<b>✅ Dokploy Serverd Restarted</b>\n\n<b>Date:</b> ${format(date, "PP")}\n<b>Time:</b> ${format(date, "pp")}`
|
||||||
[]
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export const sendDiscordNotification = async (
|
|||||||
export const sendTelegramNotification = async (
|
export const sendTelegramNotification = async (
|
||||||
connection: typeof telegram.$inferInsert,
|
connection: typeof telegram.$inferInsert,
|
||||||
messageText: string,
|
messageText: string,
|
||||||
inlineButton: {
|
inlineButton?: {
|
||||||
text: string;
|
text: string;
|
||||||
url: string;
|
url: string;
|
||||||
}[][]
|
}[][]
|
||||||
|
|||||||
Reference in New Issue
Block a user