Fixed rebase oopsie and updated for days instead of cron

This commit is contained in:
Daniel Hougaard
2023-11-28 13:50:33 +04:00
parent aee91a9558
commit 70d1cc0e06
@@ -1039,7 +1039,7 @@ export const updateSecretByName = async (req: Request, res: Response) => {
secretKeyTag, secretKeyTag,
secretKeyCiphertext, secretKeyCiphertext,
skipMultilineEncoding, skipMultilineEncoding,
secretReminderCron, secretReminderRepeatDays,
secretReminderNote secretReminderNote
}, },
params: { secretName } params: { secretName }
@@ -1116,62 +1116,31 @@ export const updateSecretByName = async (req: Request, res: Response) => {
authData: req.authData authData: req.authData
}); });
if (secretReminderCron !== undefined) { if (secretReminderRepeatDays !== undefined) {
if ( if (
(secretReminderCron && existingSecret.secretReminderCron !== secretReminderCron) || (secretReminderRepeatDays &&
existingSecret.secretReminderRepeatDays !== secretReminderRepeatDays) ||
(secretReminderNote && existingSecret.secretReminderNote !== secretReminderNote) (secretReminderNote && existingSecret.secretReminderNote !== secretReminderNote)
) { ) {
await createReminder(existingSecret, { await createReminder(existingSecret, {
_id: existingSecret._id, _id: existingSecret._id,
secretReminderCron, secretReminderRepeatDays,
secretReminderNote, secretReminderNote,
workspace: existingSecret.workspace workspace: existingSecret.workspace
}); });
} else if ( } else if (
secretReminderCron === null && secretReminderRepeatDays === null &&
secretReminderNote === null && secretReminderNote === null &&
existingSecret.secretReminderCron existingSecret.secretReminderRepeatDays
) { ) {
await deleteReminder({ await deleteReminder({
_id: existingSecret._id, _id: existingSecret._id,
secretReminderCron: existingSecret.secretReminderCron secretReminderRepeatDays: existingSecret.secretReminderRepeatDays
}); });
} }
} }
} }
if (type !== "personal") {
const existingSecret = await SecretService.getSecret({
secretName,
workspaceId: new Types.ObjectId(workspaceId),
environment,
type,
secretPath,
authData: req.authData
});
if (
(secretReminderCron && existingSecret.secretReminderCron !== secretReminderCron) ||
(secretReminderNote && existingSecret.secretReminderNote !== secretReminderNote)
) {
await createReminder(existingSecret, {
_id: existingSecret._id,
secretReminderCron,
secretReminderNote,
workspace: existingSecret.workspace
});
} else if (
secretReminderCron === null &&
secretReminderNote === null &&
existingSecret.secretReminderCron
) {
await deleteReminder({
_id: existingSecret._id,
secretReminderCron: existingSecret.secretReminderCron
});
}
}
const secret = await SecretService.updateSecret({ const secret = await SecretService.updateSecret({
secretName, secretName,
workspaceId: new Types.ObjectId(workspaceId), workspaceId: new Types.ObjectId(workspaceId),
@@ -1182,7 +1151,7 @@ export const updateSecretByName = async (req: Request, res: Response) => {
newSecretName, newSecretName,
secretValueCiphertext, secretValueCiphertext,
secretValueIV, secretValueIV,
secretReminderCron, secretReminderRepeatDays,
secretReminderNote, secretReminderNote,
secretValueTag, secretValueTag,
secretPath, secretPath,