mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-13 09:55:29 +02:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user