mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Some linting
This commit is contained in:
@@ -1,33 +1,36 @@
|
||||
import { ISecret } from "../models";
|
||||
import {
|
||||
createSecretReminderCron,
|
||||
deleteSecretReminderCron,
|
||||
updateSecretReminderCron
|
||||
} from "../queues/reminders/sendSecretReminders";
|
||||
|
||||
import { ISecret } from "../models"
|
||||
import { createSecretReminderCron, deleteSecretReminderCron, updateSecretReminderCron } from "../queues/reminders/sendSecretReminders"
|
||||
|
||||
|
||||
type TPartialSecret = Pick<ISecret, "_id" | "secretReminderCron" | "secretReminderNote" | "workspace">
|
||||
type TPartialSecretDeleteReminder = Pick<ISecret, | "_id" | "secretReminderCron">
|
||||
|
||||
|
||||
type TPartialSecret = Pick<
|
||||
ISecret,
|
||||
"_id" | "secretReminderCron" | "secretReminderNote" | "workspace"
|
||||
>;
|
||||
type TPartialSecretDeleteReminder = Pick<ISecret, "_id" | "secretReminderCron">;
|
||||
|
||||
export const createReminder = async (oldSecret: TPartialSecret, newSecret: TPartialSecret) => {
|
||||
if(oldSecret._id !== newSecret._id) {
|
||||
throw new Error("Secret id's don't match")
|
||||
if (oldSecret._id !== newSecret._id) {
|
||||
throw new Error("Secret id's don't match");
|
||||
}
|
||||
|
||||
if(!newSecret.secretReminderCron) {
|
||||
throw new Error("No cron provided")
|
||||
if (!newSecret.secretReminderCron) {
|
||||
throw new Error("No cron provided");
|
||||
}
|
||||
|
||||
const secretId = oldSecret._id.toString()
|
||||
const workspaceId = oldSecret.workspace.toString()
|
||||
const secretId = oldSecret._id.toString();
|
||||
const workspaceId = oldSecret.workspace.toString();
|
||||
|
||||
if(oldSecret.secretReminderCron) {
|
||||
if (oldSecret.secretReminderCron) {
|
||||
// This will first delete the existing cron job, and then create a new one.
|
||||
await updateSecretReminderCron({
|
||||
workspaceId,
|
||||
secretId,
|
||||
cron: newSecret.secretReminderCron,
|
||||
note: newSecret.secretReminderNote
|
||||
})
|
||||
});
|
||||
} else {
|
||||
// This will create a new cron job.
|
||||
await createSecretReminderCron({
|
||||
@@ -35,21 +38,21 @@ export const createReminder = async (oldSecret: TPartialSecret, newSecret: TPart
|
||||
secretId,
|
||||
cron: newSecret.secretReminderCron,
|
||||
note: newSecret.secretReminderNote
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const deleteReminder = async (secret: TPartialSecretDeleteReminder) => {
|
||||
if(!secret._id) {
|
||||
throw new Error("No secret id provided")
|
||||
if (!secret._id) {
|
||||
throw new Error("No secret id provided");
|
||||
}
|
||||
|
||||
if(!secret.secretReminderCron) {
|
||||
throw new Error("No cron provided")
|
||||
if (!secret.secretReminderCron) {
|
||||
throw new Error("No cron provided");
|
||||
}
|
||||
|
||||
await deleteSecretReminderCron({
|
||||
secretId: secret._id.toString(),
|
||||
cron: secret.secretReminderCron,
|
||||
})
|
||||
}
|
||||
cron: secret.secretReminderCron
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user