Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
refactor(reminders): give secret moves one reminder call
Calvin37b0a5c6bc27
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.tsindex 9085fc74d6..b7e2f0119c 100644--- a/backend/src/server/routes/index.ts+++ b/backend/src/server/routes/index.ts@@ -2414,7 +2414,6 @@ export const registerRoutes = async (kmsService,resourceMetadataDAL,reminderService,- reminderDAL,keyStore,secretValidationRuleService,projectFolderGrantDAL,@@ -2509,7 +2508,6 @@ export const registerRoutes = async (secretImportDAL,secretV2BridgeService,secretValidationRuleService,- reminderDAL,reminderService,keyStore});diff --git a/backend/src/services/alert/alert-service.ts b/backend/src/services/alert/alert-service.tsindex 9611b8dddf..7229adccca 100644--- a/backend/src/services/alert/alert-service.ts+++ b/backend/src/services/alert/alert-service.ts@@ -744,7 +744,7 @@ export const alertServiceFactory = ({// For a resource that is recreated under a new id (eg a secret moved between folders), so its alerts// and their history follow it instead of being rebuilt.- const repointAlertsForResource = async (+ const moveAlertsToResource = async ({resourceType,fromResourceId,@@ -755,19 +755,21 @@ export const alertServiceFactory = ({await alertDAL.update({ resourceType, resourceId: fromResourceId }, { resourceId: toResourceId }, tx);};- // For a resource recreated under a new id while the original stays (eg a secret moved out of a folder- // whose approval policy holds the source until the request merges), so both keep working alerts.- // Channel configs are copied still encrypted: both ids belong to the same project and share its cipher,- // so no KMS call is needed and this is safe inside the caller's transaction.- const copyAlertsForResource = async (+ // For a resource recreated under a new id in the same project while the original stays (eg a secret moved+ // out of a folder whose approval policy holds the source until the request merges), so both keep working+ // alerts. Channel configs are copied still encrypted, which is only valid because both ids share the+ // project's cipher, so only that project's alerts are copied. No KMS call, so it is safe in the caller's+ // transaction.+ const copyAlertsToResource = async ({resourceType,+ projectId,fromResourceId,toResourceId- }: { resourceType: string; fromResourceId: string; toResourceId: string },+ }: { resourceType: string; projectId: string; fromResourceId: string; toResourceId: string },tx: Knex): Promise<void> => {- const alerts = await alertDAL.find({ resourceType, resourceId: fromResourceId }, { tx });+ const alerts = await alertDAL.find({ resourceType, resourceId: fromResourceId, projectId }, { tx });if (alerts.length === 0) return;const channels = await alertChannelDAL.findByAlertIds(@@ -871,8 +873,8 @@ export const alertServiceFactory = ({deleteAlertsForResource,deleteAlertsForDeletedResource,deleteAlertsForDeletedResources,- repointAlertsForResource,- copyAlertsForResource,+ moveAlertsToResource,+ copyAlertsToResource,findRecipientsForResources,filterRecipientsInScope};diff --git a/backend/src/services/reminder/reminder-service.test.ts b/backend/src/services/reminder/reminder-service.test.tsindex 9c5af9289c..a2d2b3d9b7 100644--- a/backend/src/services/reminder/reminder-service.test.ts+++ b/backend/src/services/reminder/reminder-service.test.ts@@ -200,6 +200,7 @@ const buildWriteService = (opts: { projectUserIds?: string[]; alertRefusal?: Err// What the reminder asked the alert module to set on its secret.const alertRequests: Array<Record<string, unknown>> = [];const copied: unknown[] = [];+ const insertedReminders: Record<string, unknown>[] = [];const deletedAlerts: Array<{ resourceIds: string[]; tx: unknown }> = [];const repointed: Array<{ fromResourceId: string; toResourceId: string; tx: unknown }> = [];@@ -217,8 +218,16 @@ const buildWriteService = (opts: { projectUserIds?: string[]; alertRefusal?: Err},updateById: async () => ({}),delete: async () => [],+ // A secret id starting "plain-" has no reminder.findSecretReminders: async (secretIds: string[]) =>- secretIds.map((secretId) => ({ id: `rem-${secretId}`, secretId, recipients: ["stale-user"] }))+ secretIds+ .filter((secretId) => !secretId.startsWith("plain-"))+ .map((secretId) => ({ id: `rem-${secretId}`, secretId, repeatDays: 30, message: "rotate it" })),+ insertMany: async (rows: Record<string, unknown>[]) => {+ calls.push("reminder:insert");+ insertedReminders.push(...rows);+ return rows;+ }},eventEmitter: { emit: async () => {} },secretV2BridgeDAL: {@@ -229,7 +238,8 @@ const buildWriteService = (opts: { projectUserIds?: string[]; alertRefusal?: ErrfolderId: "folder-1",tags: []}),- invalidateSecretCacheByProjectId: async () => {}+ invalidateSecretCacheByProjectId: async () => {},+ find: async (filter: { $in: { id: string[] } }) => filter.$in.id.map((id) => ({ id, projectId: "proj-1" }))},folderDAL: {findSecretPathByFolderIds: async () => [{ id: "folder-1", path: "/", environmentSlug: "dev" }]@@ -256,18 +266,18 @@ const buildWriteService = (opts: { projectUserIds?: string[]; alertRefusal?: ErrdeletedAlerts.push({ resourceIds, tx });return resourceIds.length;},- repointAlertsForResource: async (input: { fromResourceId: string; toResourceId: string }, tx: unknown) => {- calls.push("alert:repoint");+ moveAlertsToResource: async (input: { fromResourceId: string; toResourceId: string }, tx: unknown) => {+ calls.push("alert:move");repointed.push({ ...input, tx });},- copyAlertsForResource: async (input: { fromResourceId: string; toResourceId: string }, tx: unknown) => {+ copyAlertsToResource: async (input: { fromResourceId: string; toResourceId: string }, tx: unknown) => {calls.push("alert:copy");copied.push({ ...input, tx });}}} as never);- return { service, calls, alertRequests, deletedAlerts, repointed, copied, reminderTx, writeTxs };+ return { service, calls, alertRequests, deletedAlerts, repointed, copied, insertedReminders, reminderTx, writeTxs };};const caller = { actor: "user", actorId: "user-1", actorOrgId: "org-1", actorAuthMethod: null };@@ -392,30 +402,43 @@ describe("reminder alert sync", () => {expect(deletedAlerts).toEqual([{ resourceIds: ["secret-1"], tx }]);});- test("moving reminders clears the destination's alert, then moves the source alert onto it", async () => {- const { service, calls, deletedAlerts, repointed } = buildWriteService();+ test("moving a reminder replaces the destination's reminder and moves the source alert onto it", async () => {+ const { service, calls, deletedAlerts, repointed, insertedReminders } = buildWriteService();const tx = { tx: true } as never;- await service.moveReminderAlerts([{ fromSecretId: "secret-src", toSecretId: "secret-dst" }], tx);+ await service.moveReminders([{ fromSecretId: "secret-src", toSecretId: "secret-dst" }], tx);- expect(calls).toEqual(["alert:delete", "alert:repoint"]);+ expect(calls).toEqual(["alert:delete", "reminder:insert", "alert:move"]);expect(deletedAlerts).toEqual([{ resourceIds: ["secret-dst"], tx }]);+ expect(insertedReminders).toEqual([expect.objectContaining({ secretId: "secret-dst", repeatDays: 30 })]);expect(repointed).toEqual([{ resourceType: SECRET_REMINDER_RESOURCE_TYPE, fromResourceId: "secret-src", toResourceId: "secret-dst", tx }]);});- test("copying reminder alerts clears the destination's alert, then copies the source alert onto it", async () => {+ test("copying a reminder gives the destination a copy of the source alert in the source's project", async () => {const { service, calls, repointed, copied } = buildWriteService();const tx = { tx: true } as never;- await service.copyReminderAlerts([{ fromSecretId: "secret-src", toSecretId: "secret-dst" }], tx);+ await service.copyReminders([{ fromSecretId: "secret-src", toSecretId: "secret-dst" }], tx);- expect(calls).toEqual(["alert:delete", "alert:copy"]);+ expect(calls).toEqual(["alert:delete", "reminder:insert", "alert:copy"]);expect(repointed).toEqual([]);expect(copied).toEqual([- { resourceType: SECRET_REMINDER_RESOURCE_TYPE, fromResourceId: "secret-src", toResourceId: "secret-dst", tx }+ {+ resourceType: SECRET_REMINDER_RESOURCE_TYPE,+ projectId: "proj-1",+ fromResourceId: "secret-src",+ toResourceId: "secret-dst",+ tx+ }]);});+ test("a moved secret with no reminder leaves the destination's reminder alone", async () => {+ const { service, calls } = buildWriteService();+ await service.moveReminders([{ fromSecretId: "plain-src", toSecretId: "secret-dst" }], { tx: true } as never);+ expect(calls).toEqual([]);+ });+test("dashboard recipients come from the alert, not the old recipients table", async () => {const { service } = buildWriteService();const reminders = await service.getRemindersForDashboard(["secret-1"]);diff --git a/backend/src/services/reminder/reminder-service.ts b/backend/src/services/reminder/reminder-service.tsindex 635ee3a970..adbebe5353 100644--- a/backend/src/services/reminder/reminder-service.ts+++ b/backend/src/services/reminder/reminder-service.ts@@ -20,7 +20,7 @@ import { TSecretV2BridgeDALFactory } from "../secret-v2-bridge/secret-v2-bridge-import { TReminderDALFactory } from "./reminder-dal";import { emitSecretReminderDue, SECRET_REMINDER_DUE_EVENT, SECRET_REMINDER_RESOURCE_TYPE } from "./reminder-events";import { advanceReminderDate, getReminderDueWindow, toUtcDateString } from "./reminder-fns";-import { TBatchCreateReminderDTO, TCreateReminderDTO, TReminderServiceFactory } from "./reminder-types";+import { TCreateReminderDTO, TReminderMove, TReminderServiceFactory } from "./reminder-types";const ORPHAN_REAP_BATCH_SIZE = 500;const MAX_ORPHAN_REAP_BATCHES = 20;@@ -37,12 +37,12 @@ type TReminderServiceFactoryDep = {| "applyPreparedAlert"| "findRecipientsForResources"| "deleteAlertsForDeletedResources"- | "repointAlertsForResource"- | "copyAlertsForResource"+ | "moveAlertsToResource"+ | "copyAlertsToResource"| "filterRecipientsInScope">;permissionService: Pick<TPermissionServiceFactory, "getProjectPermission">;- secretV2BridgeDAL: Pick<TSecretV2BridgeDALFactory, "invalidateSecretCacheByProjectId" | "findOneWithTags">;+ secretV2BridgeDAL: Pick<TSecretV2BridgeDALFactory, "invalidateSecretCacheByProjectId" | "findOneWithTags" | "find">;folderDAL: Pick<TSecretFolderDALFactory, "findSecretPathByFolderIds">;};@@ -387,108 +387,66 @@ export const reminderServiceFactory = ({await secretV2BridgeDAL.invalidateSecretCacheByProjectId(projectId);};- const batchCreateReminders: TReminderServiceFactory["batchCreateReminders"] = async (- remindersData: TBatchCreateReminderDTO,- tx?: Knex- ) => {- if (!remindersData || remindersData.length === 0) {- return { created: 0, reminderIds: [] };- }-- const processedReminders = remindersData.map(- ({- secretId,- message,- repeatDays,- nextReminderDate: nextReminderDateInput,- projectId,- fromDate: fromDateInput- }) => {- let nextReminderDate;- const fromDate = fromDateInput ? new Date(fromDateInput) : undefined;- if (nextReminderDateInput) {- nextReminderDate = new Date(nextReminderDateInput);- }-- if (repeatDays && !nextReminderDate) {- if (fromDate) {- nextReminderDate = fromDate;- } else {- nextReminderDate = $addDays(repeatDays);- }- }-- if (!nextReminderDate) {- throw new BadRequestError({- message: `repeatDays must be a positive number for secretId: ${secretId}`- });- }-- return {- secretId,- message,- repeatDays,- nextReminderDate,- projectId,- fromDate- };- }+ // A moved secret takes its reminder with it, schedule and alert, replacing any reminder the destination+ // secret already had. Returns the moves whose source had a reminder.+ const $carrySchedules = async (moves: TReminderMove[], tx: Knex): Promise<TReminderMove[]> => {+ const sourceReminders = await reminderDAL.findSecretReminders(+ moves.map((move) => move.fromSecretId),+ tx);+ const reminderBySecretId = new Map(sourceReminders.map((reminder) => [reminder.secretId, reminder]));+ const carried = moves.filter((move) => reminderBySecretId.has(move.fromSecretId));+ if (carried.length === 0) return [];- const newReminders = await reminderDAL.insertMany(- processedReminders.map(({ secretId, message, repeatDays, nextReminderDate, fromDate }) => ({- secretId,- message,- repeatDays,- nextReminderDate,- fromDate- })),+ const destinationIds = carried.map((move) => move.toSecretId);+ await reminderDAL.delete({ $in: { secretId: destinationIds } }, tx);+ await alertService.deleteAlertsForDeletedResources(+ { resourceType: SECRET_REMINDER_RESOURCE_TYPE, resourceIds: destinationIds },tx);-- const projectIds = new Set(processedReminders.map((r) => r.projectId).filter((id): id is string => Boolean(id)));- for (const projectId of projectIds) {- await secretV2BridgeDAL.invalidateSecretCacheByProjectId(projectId);- }-- return {- created: newReminders.length,- reminderIds: newReminders.map((r) => r.id)- };- };-- type TReminderAlertMove = { fromSecretId: string; toSecretId: string };-- // A destination secret that already had a reminder loses that reminder in the move, so its alert goes too.- const $clearDestinationReminderAlerts = (moves: TReminderAlertMove[], tx: Knex) =>- alertService.deleteAlertsForDeletedResources(- { resourceType: SECRET_REMINDER_RESOURCE_TYPE, resourceIds: moves.map((move) => move.toSecretId) },+ await reminderDAL.insertMany(+ carried.map((move) => {+ const { message, repeatDays, nextReminderDate, fromDate } = reminderBySecretId.get(move.fromSecretId)!;+ return { secretId: move.toSecretId, message, repeatDays, nextReminderDate, fromDate };+ }),tx);+ return carried;+ };- const $alertResource = (move: TReminderAlertMove) => ({- resourceType: SECRET_REMINDER_RESOURCE_TYPE,- fromResourceId: move.fromSecretId,- toResourceId: move.toSecretId- });-- // For a secret that is deleted at its source. Alerts follow it to its new id rather than being rebuilt,- // so channel secrets (webhook signing keys, PagerDuty integration keys) and send history go with it.- const moveReminderAlerts: TReminderServiceFactory["moveReminderAlerts"] = async (moves, tx) => {- if (moves.length === 0) return;- await $clearDestinationReminderAlerts(moves, tx);- for (const move of moves) {- await alertService.repointAlertsForResource($alertResource(move), tx);+ // For a secret deleted at its source. Its alert follows it to the new id rather than being rebuilt, so+ // channel secrets (webhook signing keys, PagerDuty integration keys) and send history go with it.+ const moveReminders: TReminderServiceFactory["moveReminders"] = async (moves, tx) => {+ const carried = await $carrySchedules(moves, tx);+ for (const move of carried) {+ await alertService.moveAlertsToResource(+ {+ resourceType: SECRET_REMINDER_RESOURCE_TYPE,+ fromResourceId: move.fromSecretId,+ toResourceId: move.toSecretId+ },+ tx+ );}};- // For a secret that stays at its source as well. Its reminder keeps firing there, so it keeps its alert- // and the destination gets its own.- const copyReminderAlerts: TReminderServiceFactory["copyReminderAlerts"] = async (moves, tx) => {- if (moves.length === 0) return;- await $clearDestinationReminderAlerts(moves, tx);- for (const move of moves) {- await alertService.copyAlertsForResource($alertResource(move), tx);+ // For a secret that also stays at its source, whose reminder keeps firing there. The source keeps its+ // alert and the destination gets a copy.+ const copyReminders: TReminderServiceFactory["copyReminders"] = async (moves, tx) => {+ const carried = await $carrySchedules(moves, tx);+ if (carried.length === 0) return;+ const secrets = await secretV2BridgeDAL.find({ $in: { id: carried.map((move) => move.fromSecretId) } }, { tx });+ const projectIdBySecretId = new Map(secrets.map((secret) => [secret.id, secret.projectId]));+ for (const move of carried) {+ await alertService.copyAlertsToResource(+ {+ resourceType: SECRET_REMINDER_RESOURCE_TYPE,+ projectId: projectIdBySecretId.get(move.fromSecretId)!,+ fromResourceId: move.fromSecretId,+ toResourceId: move.toSecretId+ },+ tx+ );}};@@ -521,9 +479,8 @@ export const reminderServiceFactory = ({reapOrphanedReminderAlerts,deleteReminder,deleteReminderBySecretId,- batchCreateReminders,- moveReminderAlerts,- copyReminderAlerts,+ moveReminders,+ copyReminders,getRemindersForDashboard};};diff --git a/backend/src/services/reminder/reminder-types.ts b/backend/src/services/reminder/reminder-types.tsindex 0243ace4d1..42fc057202 100644--- a/backend/src/services/reminder/reminder-types.ts+++ b/backend/src/services/reminder/reminder-types.ts@@ -51,14 +51,8 @@ export type TPreparedReminder = {alert: TPreparedAlert;};-export type TBatchCreateReminderDTO = {- secretId: string;- message?: string | null;- repeatDays?: number | null;- nextReminderDate?: string | Date | null;- fromDate?: Date | null;- projectId?: string;-}[];+// A secret recreated under a new id (eg by a move between folders).+export type TReminderMove = { fromSecretId: string; toSecretId: string };export interface TReminderServiceFactory {prepareReminder: (dto: TPrepareReminderDTO) => Promise<TPreparedReminder>;@@ -104,17 +98,9 @@ export interface TReminderServiceFactory {deleteReminderBySecretId: (secretId: string, projectId: string, tx?: Knex) => Promise<void>;- batchCreateReminders: (- remindersData: TBatchCreateReminderDTO,- tx?: Knex- ) => Promise<{- created: number;- reminderIds: string[];- }>;-- moveReminderAlerts: (moves: { fromSecretId: string; toSecretId: string }[], tx: Knex) => Promise<void>;+ moveReminders: (moves: TReminderMove[], tx: Knex) => Promise<void>;- copyReminderAlerts: (moves: { fromSecretId: string; toSecretId: string }[], tx: Knex) => Promise<void>;+ copyReminders: (moves: TReminderMove[], tx: Knex) => Promise<void>;getRemindersForDashboard: (secretIds: string[]) => Promise<Record<string, TReminder & { recipients: string[] }>>;}diff --git a/backend/src/services/secret-folder/secret-folder-service.ts b/backend/src/services/secret-folder/secret-folder-service.tsindex b3e05e6765..6a649fe473 100644--- a/backend/src/services/secret-folder/secret-folder-service.ts+++ b/backend/src/services/secret-folder/secret-folder-service.ts@@ -42,7 +42,6 @@ import {} from "../folder-commit/folder-commit-service";import { TProjectDALFactory } from "../project/project-dal";import { TProjectEnvDALFactory } from "../project-env/project-env-dal";-import { TReminderDALFactory } from "../reminder/reminder-dal";import { TReminderServiceFactory } from "../reminder/reminder-types";import { TResourceMetadataDALFactory } from "../resource-metadata/resource-metadata-dal";import { TSecretImportDALFactory } from "../secret-import/secret-import-dal";@@ -118,8 +117,7 @@ type TSecretFolderServiceFactoryDep = {secretImportDAL: Pick<TSecretImportDALFactory, "findImportByFolderIds">;secretV2BridgeService: Pick<TSecretV2BridgeServiceFactory, "dispatchSecretMoveSideEffects">;secretValidationRuleService: Pick<TSecretValidationRuleServiceFactory, "validateSecrets">;- reminderDAL: Pick<TReminderDALFactory, "findSecretReminders" | "delete">;- reminderService: Pick<TReminderServiceFactory, "batchCreateReminders" | "moveReminderAlerts" | "copyReminderAlerts">;+ reminderService: Pick<TReminderServiceFactory, "moveReminders" | "copyReminders">;keyStore: Pick<TKeyStoreFactory, "acquireLock">;};@@ -150,7 +148,6 @@ export const secretFolderServiceFactory = ({secretImportDAL,secretV2BridgeService,secretValidationRuleService,- reminderDAL,reminderService,keyStore}: TSecretFolderServiceFactoryDep) => {@@ -2005,7 +2002,6 @@ export const secretFolderServiceFactory = ({secretApprovalRequestDAL,secretApprovalRequestSecretDAL,secretQueueService,- reminderDAL,reminderService,secretValidationRuleService})diff --git a/backend/src/services/secret-v2-bridge/secret-v2-bridge-fns.ts b/backend/src/services/secret-v2-bridge/secret-v2-bridge-fns.tsindex 26352cc941..b3c100e725 100644--- a/backend/src/services/secret-v2-bridge/secret-v2-bridge-fns.ts+++ b/backend/src/services/secret-v2-bridge/secret-v2-bridge-fns.ts@@ -29,6 +29,7 @@ import { ActorType } from "../auth/auth-type";import { CommitType, TFolderCommitServiceFactory } from "../folder-commit/folder-commit-service";import { KmsDataKey } from "../kms/kms-types";import { TProjectEnvDALFactory } from "../project-env/project-env-dal";+import { TReminderMove } from "../reminder/reminder-types";import { ResourceMetadataWithEncryptionDTO } from "../resource-metadata/resource-metadata-schema";import { INFISICAL_SECRET_VALUE_HIDDEN_MASK } from "../secret/secret-fns";import { TSecretQueueFactory } from "../secret/secret-queue";@@ -1629,7 +1630,6 @@ export const fnSecretMove = async (dto: TFnSecretMove): Promise<TFnSecretMoveRessecretApprovalRequestDAL,secretApprovalRequestSecretDAL,secretQueueService,- reminderDAL,reminderService,secretValidationRuleService} = dto;@@ -1723,9 +1723,6 @@ export const fnSecretMove = async (dto: TFnSecretMove): Promise<TFnSecretMoveRes: undefined}));- const sourceReminders = await reminderDAL.findSecretReminders(secretIds, tx);- const sourceSecretIdToKey = Object.fromEntries(decryptedSourceSecrets.map((s) => [s.id, s.key]));-// Looked up before the destination is written, because how the reminders' alerts are carried over// depends on whether the source keeps its secrets.const sourceFolderPolicy = await secretApprovalPolicyService.getSecretApprovalPolicy(@@ -2033,42 +2030,15 @@ export const fnSecretMove = async (dto: TFnSecretMove): Promise<TFnSecretMoveRes}));- // carry the source secrets' reminders over to the destination secrets so the schedule- // (message, repeatDays, nextReminderDate, fromDate) survives the move, and the reminder's alert- // (who gets notified and how) follows it.- const remindersToCreate = sourceReminders- .map((rem) => {- const key = rem.secretId ? sourceSecretIdToKey[rem.secretId] : undefined;- const destinationSecretId = key ? destinationSecretIdByKey[key] : undefined;- if (!rem.secretId || !destinationSecretId) return null;- return {- sourceSecretId: rem.secretId,- secretId: destinationSecretId,- message: rem.message,- repeatDays: rem.repeatDays,- nextReminderDate: rem.nextReminderDate,- fromDate: rem.fromDate,- projectId- };- })- .filter((r): r is NonNullable<typeof r> => Boolean(r));-- if (remindersToCreate.length) {- // we can delete the reminders in this case, because if it gets in this step,- // it means that the move is a overwrite move or there is no existing reminder for the secret.- await reminderDAL.delete({ $in: { secretId: remindersToCreate.map((r) => r.secretId) } }, tx);- await reminderService.batchCreateReminders(- remindersToCreate.map(({ sourceSecretId, ...reminder }) => reminder),- tx- );- const alertMoves = remindersToCreate.map((r) => ({ fromSecretId: r.sourceSecretId, toSecretId: r.secretId }));- // A source held by an approval policy keeps its secrets, and their reminders, until the request merges,- // so those reminders keep their alerts and the destination gets copies.- if (shouldApplyPolicy(sourceFolderPolicy, actor)) {- await reminderService.copyReminderAlerts(alertMoves, tx);- } else {- await reminderService.moveReminderAlerts(alertMoves, tx);- }+ // Each moved secret is recreated under a new id and takes its reminder with it. A source held by an+ // approval policy keeps its secrets, and their reminders, until the request merges, so those are copied.+ const reminderMoves = decryptedSourceSecrets+ .map((s) => ({ fromSecretId: s.id, toSecretId: destinationSecretIdByKey[s.key] }))+ .filter((move): move is TReminderMove => Boolean(move.toSecretId));+ if (shouldApplyPolicy(sourceFolderPolicy, actor)) {+ await reminderService.copyReminders(reminderMoves, tx);+ } else {+ await reminderService.moveReminders(reminderMoves, tx);}isDestinationUpdated = true;diff --git a/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts b/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.tsindex ea442c22dd..267067e398 100644--- a/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts+++ b/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts@@ -55,7 +55,6 @@ import { TOrgDALFactory } from "../org/org-dal";import { TProjectDALFactory } from "../project/project-dal";import { TProjectEnvDALFactory } from "../project-env/project-env-dal";import { TProjectFolderGrantDALFactory } from "../project-folder-grant/project-folder-grant-dal";-import { TReminderDALFactory } from "../reminder/reminder-dal";import { TReminderServiceFactory } from "../reminder/reminder-types";import { TResourceMetadataDALFactory } from "../resource-metadata/resource-metadata-dal";import { ResourceMetadataWithEncryptionDTO } from "../resource-metadata/resource-metadata-schema";@@ -189,15 +188,8 @@ type TSecretV2BridgeServiceFactoryDep = {>;reminderService: Pick<TReminderServiceFactory,- | "prepareReminder"- | "applyReminder"- | "createReminder"- | "getReminder"- | "batchCreateReminders"- | "moveReminderAlerts"- | "copyReminderAlerts"+ "prepareReminder" | "applyReminder" | "createReminder" | "getReminder" | "moveReminders" | "copyReminders">;- reminderDAL: Pick<TReminderDALFactory, "findSecretReminders" | "delete">;secretValidationRuleService: Pick<TSecretValidationRuleServiceFactory, "validateSecrets">;projectFolderGrantDAL: Pick<TProjectFolderGrantDALFactory, "find">;orgDAL: Pick<TOrgDALFactory, "findOrgById">;@@ -227,7 +219,6 @@ export const secretV2BridgeServiceFactory = ({resourceMetadataDAL,keyStore,reminderService,- reminderDAL,secretValidationRuleService,projectFolderGrantDAL,orgDAL@@ -3285,7 +3276,6 @@ export const secretV2BridgeServiceFactory = ({secretApprovalRequestDAL,secretApprovalRequestSecretDAL,secretQueueService,- reminderDAL,reminderService,secretValidationRuleService})diff --git a/backend/src/services/secret-v2-bridge/secret-v2-bridge-types.ts b/backend/src/services/secret-v2-bridge/secret-v2-bridge-types.tsindex 2345f3d772..cb3c61ff09 100644--- a/backend/src/services/secret-v2-bridge/secret-v2-bridge-types.ts+++ b/backend/src/services/secret-v2-bridge/secret-v2-bridge-types.ts@@ -22,7 +22,6 @@ import { TSecretFolderDALFactory } from "@app/services/secret-folder/secret-foldimport { TSecretTagDALFactory } from "@app/services/secret-tag/secret-tag-dal";import { TCommitResourceChangeDTO, TFolderCommitServiceFactory } from "../folder-commit/folder-commit-service";-import { TReminderDALFactory } from "../reminder/reminder-dal";import { TReminderServiceFactory } from "../reminder/reminder-types";import { TResourceMetadataDALFactory } from "../resource-metadata/resource-metadata-dal";import { ResourceMetadataWithEncryptionDTO } from "../resource-metadata/resource-metadata-schema";@@ -314,8 +313,7 @@ export type TFnSecretMove = {"insertV2Bridge" | "insertApprovalSecretV2Tags">;secretQueueService: Pick<TSecretQueueFactory, "syncSecrets">;- reminderDAL: Pick<TReminderDALFactory, "findSecretReminders" | "delete">;- reminderService: Pick<TReminderServiceFactory, "batchCreateReminders" | "moveReminderAlerts" | "copyReminderAlerts">;+ reminderService: Pick<TReminderServiceFactory, "moveReminders" | "copyReminders">;secretValidationRuleService: Pick<TSecretValidationRuleServiceFactory, "validateSecrets">;};