Remove refresh-license-validity API endpoint and integrate enterprise backup cron job initialization: Deleted the cron endpoint for refreshing license validity and added the initialization of enterprise backup cron jobs in the server setup. Updated the enterprise cron job logic to filter users based on license key and enterprise feature status.

This commit is contained in:
Mauricio Siu
2026-01-29 22:42:59 -06:00
parent 12a87f9f8b
commit 82c06a487a
3 changed files with 23 additions and 59 deletions

View File

@@ -1,22 +1,28 @@
import { member } from "@dokploy/server/db/schema";
import { getPublicIpWithFallback } from "@dokploy/server/wss/utils";
import { eq } from "drizzle-orm";
import { and, eq, isNotNull } from "drizzle-orm";
import { scheduleJob } from "node-schedule";
import { db } from "../../db/index";
import { user as userSchema } from "../../db/schema/user";
export const initEnterpriseBackupCronJobs = async () => {
console.log("Setting up enterprise backup cron jobs....");
const admins = await db.query.member.findMany({
where: eq(member.role, "owner"),
with: {
user: true,
},
const users = await db.query.user.findMany({
where: and(
isNotNull(userSchema.licenseKey),
isNotNull(userSchema.enableEnterpriseFeatures),
eq(userSchema.isValidEnterpriseLicense, true),
),
});
for (const admin of admins) {
const { user } = admin;
if (users.length === 0) {
return;
}
console.log(
"Setting up enterprise backup cron jobs for users....",
users.length,
);
for (const user of users) {
if (user.isValidEnterpriseLicense) {
scheduleJob(`enterprise-backup-${user.id}`, "0 0 */14 * *", async () => {
try {