[autofix.ci] apply automated fixes

This commit is contained in:
autofix-ci[bot]
2025-10-23 12:00:30 +00:00
committed by GitHub
parent 046606e496
commit 8e5be8dbcb
4 changed files with 98 additions and 53 deletions
@@ -25,7 +25,14 @@ export const sendVolumeBackupNotifications = async ({
projectName: string; projectName: string;
applicationName: string; applicationName: string;
volumeName: string; volumeName: string;
serviceType: "application" | "postgres" | "mysql" | "mongodb" | "mariadb" | "redis" | "compose"; serviceType:
| "application"
| "postgres"
| "mysql"
| "mongodb"
| "mariadb"
| "redis"
| "compose";
type: "error" | "success"; type: "error" | "success";
organizationId: string; organizationId: string;
errorMessage?: string; errorMessage?: string;
@@ -106,11 +113,15 @@ export const sendVolumeBackupNotifications = async ({
value: serviceType, value: serviceType,
inline: true, inline: true,
}, },
...(backupSize ? [{ ...(backupSize
? [
{
name: decorate("`📊`", "Backup Size"), name: decorate("`📊`", "Backup Size"),
value: backupSize, value: backupSize,
inline: true, inline: true,
}] : []), },
]
: []),
{ {
name: decorate("`📅`", "Date"), name: decorate("`📅`", "Date"),
value: `<t:${unixDate}:D>`, value: `<t:${unixDate}:D>`,
@@ -236,11 +247,15 @@ export const sendVolumeBackupNotifications = async ({
value: serviceType, value: serviceType,
short: true, short: true,
}, },
...(backupSize ? [{ ...(backupSize
? [
{
title: "Backup Size", title: "Backup Size",
value: backupSize, value: backupSize,
short: true, short: true,
}] : []), },
]
: []),
{ {
title: "Time", title: "Time",
value: date.toLocaleString(), value: date.toLocaleString(),
@@ -81,7 +81,8 @@ export const runVolumeBackup = async (volumeBackupId: string) => {
// Send success notification // Send success notification
try { try {
const projectName = volumeBackup.application?.environment?.project?.name || const projectName =
volumeBackup.application?.environment?.project?.name ||
volumeBackup.compose?.environment?.project?.name || volumeBackup.compose?.environment?.project?.name ||
volumeBackup.postgres?.environment?.project?.name || volumeBackup.postgres?.environment?.project?.name ||
volumeBackup.mysql?.environment?.project?.name || volumeBackup.mysql?.environment?.project?.name ||
@@ -90,7 +91,8 @@ export const runVolumeBackup = async (volumeBackupId: string) => {
volumeBackup.redis?.environment?.project?.name || volumeBackup.redis?.environment?.project?.name ||
"Unknown Project"; "Unknown Project";
const organizationId = volumeBackup.application?.environment?.project?.organizationId || const organizationId =
volumeBackup.application?.environment?.project?.organizationId ||
volumeBackup.compose?.environment?.project?.organizationId || volumeBackup.compose?.environment?.project?.organizationId ||
volumeBackup.postgres?.environment?.project?.organizationId || volumeBackup.postgres?.environment?.project?.organizationId ||
volumeBackup.mysql?.environment?.project?.organizationId || volumeBackup.mysql?.environment?.project?.organizationId ||
@@ -100,18 +102,31 @@ export const runVolumeBackup = async (volumeBackupId: string) => {
""; "";
// Map service type to match notification function expectations // Map service type to match notification function expectations
const mappedServiceType = volumeBackup.serviceType === "mongo" ? "mongodb" : volumeBackup.serviceType; const mappedServiceType =
volumeBackup.serviceType === "mongo"
? "mongodb"
: volumeBackup.serviceType;
await sendVolumeBackupNotifications({ await sendVolumeBackupNotifications({
projectName, projectName,
applicationName: volumeBackup.name, applicationName: volumeBackup.name,
volumeName: volumeBackup.volumeName, volumeName: volumeBackup.volumeName,
serviceType: mappedServiceType as "application" | "postgres" | "mysql" | "mongodb" | "mariadb" | "redis" | "compose", serviceType: mappedServiceType as
| "application"
| "postgres"
| "mysql"
| "mongodb"
| "mariadb"
| "redis"
| "compose",
type: "success", type: "success",
organizationId, organizationId,
}); });
} catch (notificationError) { } catch (notificationError) {
console.error("Failed to send volume backup success notification:", notificationError); console.error(
"Failed to send volume backup success notification:",
notificationError,
);
} }
} catch (error) { } catch (error) {
const { VOLUME_BACKUPS_PATH } = paths(!!serverId); const { VOLUME_BACKUPS_PATH } = paths(!!serverId);
@@ -130,7 +145,8 @@ export const runVolumeBackup = async (volumeBackupId: string) => {
// Send error notification // Send error notification
try { try {
const projectName = volumeBackup.application?.environment?.project?.name || const projectName =
volumeBackup.application?.environment?.project?.name ||
volumeBackup.compose?.environment?.project?.name || volumeBackup.compose?.environment?.project?.name ||
volumeBackup.postgres?.environment?.project?.name || volumeBackup.postgres?.environment?.project?.name ||
volumeBackup.mysql?.environment?.project?.name || volumeBackup.mysql?.environment?.project?.name ||
@@ -139,7 +155,8 @@ export const runVolumeBackup = async (volumeBackupId: string) => {
volumeBackup.redis?.environment?.project?.name || volumeBackup.redis?.environment?.project?.name ||
"Unknown Project"; "Unknown Project";
const organizationId = volumeBackup.application?.environment?.project?.organizationId || const organizationId =
volumeBackup.application?.environment?.project?.organizationId ||
volumeBackup.compose?.environment?.project?.organizationId || volumeBackup.compose?.environment?.project?.organizationId ||
volumeBackup.postgres?.environment?.project?.organizationId || volumeBackup.postgres?.environment?.project?.organizationId ||
volumeBackup.mysql?.environment?.project?.organizationId || volumeBackup.mysql?.environment?.project?.organizationId ||
@@ -149,19 +166,32 @@ export const runVolumeBackup = async (volumeBackupId: string) => {
""; "";
// Map service type to match notification function expectations // Map service type to match notification function expectations
const mappedServiceType = volumeBackup.serviceType === "mongo" ? "mongodb" : volumeBackup.serviceType; const mappedServiceType =
volumeBackup.serviceType === "mongo"
? "mongodb"
: volumeBackup.serviceType;
await sendVolumeBackupNotifications({ await sendVolumeBackupNotifications({
projectName, projectName,
applicationName: volumeBackup.name, applicationName: volumeBackup.name,
volumeName: volumeBackup.volumeName, volumeName: volumeBackup.volumeName,
serviceType: mappedServiceType as "application" | "postgres" | "mysql" | "mongodb" | "mariadb" | "redis" | "compose", serviceType: mappedServiceType as
| "application"
| "postgres"
| "mysql"
| "mongodb"
| "mariadb"
| "redis"
| "compose",
type: "error", type: "error",
organizationId, organizationId,
errorMessage: error instanceof Error ? error.message : String(error), errorMessage: error instanceof Error ? error.message : String(error),
}); });
} catch (notificationError) { } catch (notificationError) {
console.error("Failed to send volume backup error notification:", notificationError); console.error(
"Failed to send volume backup error notification:",
notificationError,
);
} }
console.error(error); console.error(error);