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
bound smtp send
Thiago Araujo da Silva9e113152722b
diff --git a/backend/src/services/alert/alert-channel-service.ts b/backend/src/services/alert/alert-channel-service.tsindex 19a679bef7..67d785fac2 100644--- a/backend/src/services/alert/alert-channel-service.ts+++ b/backend/src/services/alert/alert-channel-service.ts@@ -247,7 +247,8 @@ export const alertChannelServiceFactory = ({return merged;};- const $countUsage = (channelId: string): Promise<number> => alertChannelMembershipDAL.countByChannelId(channelId);+ const $countUsage = (channelId: string, tx?: Knex): Promise<number> =>+ alertChannelMembershipDAL.countByChannelId(channelId, tx);const $buildDetail = (channel: {@@ -467,26 +468,25 @@ export const alertChannelServiceFactory = ({}const cipher = await getAlertChannelCipher(kmsService, scope);- const finalConfig = await alertChannelDAL.transaction((tx) =>- updateChannelInTx(+ return alertChannelDAL.transaction(async (tx) => {+ const finalConfig = await updateChannelInTx({ channelId: channel.id, name: dto.name, config: dto.config, enabled: dto.enabled, recipients: dto.recipients },channel,cipher,tx- )- );+ );- const [updated, recipients, usageCount] = await Promise.all([- alertChannelDAL.findById(channel.id),- alertChannelRecipientDAL.findByChannelId(channel.id),- $countUsage(channel.id)- ]);- return $buildDetail(- updated,- finalConfig,- recipients.map((r) => ({ principalType: r.principalType, principalId: r.principalId })),- usageCount- );+ const updated = await alertChannelDAL.findById(channel.id, tx);+ const recipients = await alertChannelRecipientDAL.findByChannelId(channel.id, tx);+ const usageCount = await $countUsage(channel.id, tx);++ return $buildDetail(+ updated,+ finalConfig,+ recipients.map((r) => ({ principalType: r.principalType, principalId: r.principalId })),+ usageCount+ );+ });};const deleteChannel = async (dto: TDeleteAlertChannelDTO): Promise<{ id: string }> => {diff --git a/backend/src/services/alert/alert-engine.ts b/backend/src/services/alert/alert-engine.tsindex 43b8a78608..4c623691de 100644--- a/backend/src/services/alert/alert-engine.ts+++ b/backend/src/services/alert/alert-engine.ts@@ -1,3 +1,5 @@+import pLimit from "p-limit";+import { OrgMembershipRole, OrgMembershipStatus, TAlerts } from "@app/db/schemas";import { logger } from "@app/lib/logger";import { TKmsServiceFactory } from "@app/services/kms/kms-service";@@ -18,6 +20,8 @@ import { ALERT_CHANNEL_REGISTRY } from "./channels/alert-channel-registry";const FAILURE_NOTIFICATION_MAX_ERROR_LENGTH = 200;+const RECIPIENT_SEND_CONCURRENCY = 10;+export type TAlertEngineDep = {alertChannelDAL: Pick<TAlertChannelDALFactory, "findByAlertId">;alertChannelRecipientDAL: Pick<TAlertChannelRecipientDALFactory, "findByChannelIds">;@@ -172,9 +176,10 @@ export const alertEngineFactory = ({if (recipients.length === 0) {return { ...base, success: false, error: "No recipients could be resolved for this channel" };}+ const sendLimit = pLimit(RECIPIENT_SEND_CONCURRENCY);const results = await Promise.all(recipients.map((recipient) =>- definition.send({ channelId: channel.id, config, payload, recipient, deps })+ sendLimit(() => definition.send({ channelId: channel.id, config, payload, recipient, deps }))));const failures = results.filter((result) => !result.success);