Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix(secrets-api): deletion of secret reminders on secret delete

Daniel Hougaardc00f6601bde7
diff --git a/backend/src/services/secret/secret-service.ts b/backend/src/services/secret/secret-service.ts
index 6f058e0238..fbf90a7f87 100644
--- a/backend/src/services/secret/secret-service.ts
+++ b/backend/src/services/secret/secret-service.ts
@@ -491,8 +491,8 @@ export const secretServiceFactory = ({
secretDAL
});
- const deletedSecret = await secretDAL.transaction(async (tx) =>
- fnSecretBulkDelete({
+ const deletedSecret = await secretDAL.transaction(async (tx) => {
+ const secrets = await fnSecretBulkDelete({
projectId,
folderId,
actorId,
@@ -505,8 +505,19 @@ export const secretServiceFactory = ({
}
],
tx
- })
- );
+ });
+
+ for await (const secret of secrets) {
+ if (secret.secretReminderRepeatDays !== null && secret.secretReminderRepeatDays !== undefined) {
+ await secretQueueService.removeSecretReminder({
+ repeatDays: secret.secretReminderRepeatDays,
+ secretId: secret.id
+ });
+ }
+ }
+
+ return secrets;
+ });
if (inputSecret.type === SecretType.Shared) {
await snapshotService.performSnapshot(folderId);
@@ -971,8 +982,8 @@ export const secretServiceFactory = ({
secretDAL
});
- const secretsDeleted = await secretDAL.transaction(async (tx) =>
- fnSecretBulkDelete({
+ const secretsDeleted = await secretDAL.transaction(async (tx) => {
+ const secrets = await fnSecretBulkDelete({
secretDAL,
secretQueueService,
inputSecrets: inputSecrets.map(({ type, secretName }) => ({
@@ -983,8 +994,19 @@ export const secretServiceFactory = ({
folderId,
actorId,
tx
- })
- );
+ });
+
+ for await (const secret of secrets) {
+ if (secret.secretReminderRepeatDays !== null && secret.secretReminderRepeatDays !== undefined) {
+ await secretQueueService.removeSecretReminder({
+ repeatDays: secret.secretReminderRepeatDays,
+ secretId: secret.id
+ });
+ }
+ }
+
+ return secrets;
+ });
await snapshotService.performSnapshot(folderId);
await secretQueueService.syncSecrets({