feat: log outbound SMS and show history in compose modal

Persist manual, campaign, and automation SMS; expose history APIs for people and leads.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-17 21:23:07 +03:30
co-authored by Cursor
parent 9325d879a5
commit 23f8da2c65
16 changed files with 457 additions and 3 deletions
@@ -24,6 +24,7 @@ import {
ownerWhere,
} from '../common/record-scope';
import { TrackingService } from '../tracking/tracking.service';
import { OutboundSmsLogService } from '../outbound-sms/outbound-sms-log.service';
import type { Prisma } from '@prisma/client';
function leadAccessWhere(baseActor: Actor): Prisma.LeadWhereInput {
@@ -46,6 +47,7 @@ export class SmsCampaignsService {
private readonly prisma: PrismaService,
private readonly sms: SmsService,
private readonly tracking: TrackingService,
private readonly outboundSms: OutboundSmsLogService,
) {}
async list(
@@ -585,6 +587,17 @@ export class SmsCampaignsService {
recipient.mobile,
personalized.body,
);
await this.outboundSms.record({
organizationId: campaign.organizationId,
personId: recipient.personId,
leadId: recipient.leadId,
mobile: recipient.mobile,
body: personalized.body,
source: 'campaign',
sourceId: campaign.id,
status: result.ok ? 'sent' : 'failed',
error: result.ok ? null : result.reason,
});
if (result.ok) {
await this.prisma.smsCampaignRecipient.update({
where: { id: recipient.id },