/
githubmirror
/
novu
Обзор
Документация
Войти
/
githubmirror
/
novu
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
next
packages/stateless/src/lib/handler/sms.handler.ts
41 строка
1 KB
Adam Chmara
chore(root): apply biome formatter & linter fixes NV-6436 (#8838)
31 июл 2025, 14:59
Не верифицирован
31 июл 2025, 14:59
855fb8f
Код
Авторство
О чём код?
import { HandlebarsContentEngine, IContentEngine } from '../content/content.engine'; import { ISmsProvider } from '../provider/provider.interface'; import { ChannelTypeEnum, IMessage, ITriggerPayload } from '../template/template.interface'; export class SmsHandler { private readonly contentEngine: IContentEngine; constructor( private message: IMessage, private provider: ISmsProvider, contentEngine?: IContentEngine ) { this.contentEngine = contentEngine ?? new HandlebarsContentEngine(); } async send(data: ITriggerPayload) { const attachments = data.$attachments?.filter((item) => item.channels?.length ? item.channels?.includes(ChannelTypeEnum.SMS) : true ); let content = ''; if (typeof this.message.template === 'string') { content = this.contentEngine.compileTemplate(this.message.template, data); } else { content = await this.message.template(data); } if (!data.$phone) { throw new Error('$phone is missing in trigger payload. To send an SMS You must specify a $phone property.'); } return await this.provider.sendMessage( { to: data.$phone, content, attachments, }, {} ); } }