/
githubmirror
/
novu
Обзор
Документация
Войти
/
githubmirror
/
novu
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
next
apps/api/src/app/support/usecases/create-thread.usecase.ts
29 строк
948 B
Paweł Tymczuk
chore(api-service,worker,application-generic): move upsert workflow usecase to application-generic fixes NV-7141 (#10172)
06 мар 2026, 18:09
Не верифицирован
06 мар 2026, 18:09
a3c15fe
Код
Авторство
О чём код?
import { Injectable } from '@nestjs/common'; import { capitalize, SupportService } from '@novu/application-generic'; import { CreateSupportThreadCommand } from './create-thread.command'; @Injectable() export class CreateSupportThreadUsecase { constructor(private supportService: SupportService) {} async execute(command: CreateSupportThreadCommand) { const firstName = capitalize(command.firstName ?? ''); const lastName = capitalize(command.lastName ?? ''); const plainCustomer = await this.supportService.upsertCustomer({ emailAddress: command.email, fullName: `${firstName} ${lastName}`, novuUserId: command.userId, }); const thread = await this.supportService.createThread({ plainCustomerId: plainCustomer.data?.customer?.id, threadText: command.text, }); return { success: true, message: 'Thread created successfully', threadId: thread.data?.id, }; } }