/
githubmirror
/
novu
Обзор
Документация
Войти
/
githubmirror
/
novu
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
next
libs/application-generic/src/utils/digest.ts
50 строк
2 KB
Himanshu Garg
feat(api-service, worker, application-generic): implement notification payload deduplication across jobs and messages fixes NV-8320 (#11976)
21 июл 2026, 17:02
Не верифицирован
21 июл 2026, 17:02
8b45746
Код
Авторство
О чём код?
import { JobEntity } from '@novu/dal'; import { DelayTypeEnum, DigestTypeEnum, IDigestBaseMetadata, IDigestRegularMetadata, JobStatusEnum, StepTypeEnum, } from '@novu/shared'; import { getNestedValue } from './object'; export const isRegularDigest = (type: DigestTypeEnum | DelayTypeEnum) => { return type === DigestTypeEnum.REGULAR || type === DigestTypeEnum.BACKOFF; }; export const isRegularDelay = (type: DelayTypeEnum) => { return type === DelayTypeEnum.REGULAR; }; export const isMainDigest = (type: StepTypeEnum | undefined, status: JobStatusEnum) => { return type === StepTypeEnum.DIGEST && status === JobStatusEnum.DELAYED; }; export function isActionStepType(type: StepTypeEnum) { const channels = [StepTypeEnum.DELAY, StepTypeEnum.DIGEST, StepTypeEnum.THROTTLE]; return channels.find((channel) => channel === type); } export function isStepResolverSupportedType(type: StepTypeEnum): boolean { return ![StepTypeEnum.TRIGGER, StepTypeEnum.CUSTOM, StepTypeEnum.HTTP_REQUEST].includes(type); } export function getJobDigest(job: JobEntity): { digestMeta: IDigestBaseMetadata | undefined; digestKey: string | undefined; digestValue: string | undefined; } { const digestMeta = job.digest as IDigestRegularMetadata | undefined; const digestKey = digestMeta?.digestKey; // Prefer the digest value persisted on the job (payload-independent matching), // falling back to the payload for legacy jobs that predate persisted metadata. const digestValue = digestMeta?.digestValue ?? getNestedValue(job.payload, digestKey); return { digestKey, digestMeta, digestValue, }; }