feat: add per-org SMS wallet with adm panel and header credit
Bill all platform SMS (including OTP), allow negative balance with manual/auto cutoffs, and support own-panel bypass without wallet debit.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AuthModule } from '../auth/auth.module';
|
||||
import { BillingModule } from '../billing/billing.module';
|
||||
import { SmsService } from '../common/sms.service';
|
||||
import { TrackingModule } from '../tracking/tracking.module';
|
||||
import { SmsCampaignsController } from './sms-campaigns.controller';
|
||||
import { SmsCampaignsService } from './sms-campaigns.service';
|
||||
@@ -9,7 +8,7 @@ import { SmsCampaignsService } from './sms-campaigns.service';
|
||||
@Module({
|
||||
imports: [AuthModule, BillingModule, TrackingModule],
|
||||
controllers: [SmsCampaignsController],
|
||||
providers: [SmsCampaignsService, SmsService],
|
||||
providers: [SmsCampaignsService],
|
||||
exports: [SmsCampaignsService],
|
||||
})
|
||||
export class SmsCampaignsModule {}
|
||||
|
||||
@@ -15,7 +15,7 @@ import type {
|
||||
} from '@mento/shared';
|
||||
import { SMS_CAMPAIGN_CHUNK_SIZE } from '@mento/shared';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { SmsService } from '../common/sms.service';
|
||||
import { SmsGatewayService } from '../sms-billing/sms-gateway.service';
|
||||
import { renderSmsText } from '../common/sms-text';
|
||||
import {
|
||||
type Actor,
|
||||
@@ -45,7 +45,7 @@ function leadAccessWhere(baseActor: Actor): Prisma.LeadWhereInput {
|
||||
export class SmsCampaignsService {
|
||||
constructor(
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly sms: SmsService,
|
||||
private readonly sms: SmsGatewayService,
|
||||
private readonly tracking: TrackingService,
|
||||
private readonly outboundSms: OutboundSmsLogService,
|
||||
) {}
|
||||
@@ -583,10 +583,12 @@ export class SmsCampaignsService {
|
||||
body: withTokens,
|
||||
});
|
||||
|
||||
const result = await this.sms.sendSmsDetailed(
|
||||
recipient.mobile,
|
||||
personalized.body,
|
||||
);
|
||||
const result = await this.sms.send({
|
||||
organizationId: campaign.organizationId,
|
||||
phone: recipient.mobile,
|
||||
text: personalized.body,
|
||||
source: 'campaign',
|
||||
});
|
||||
await this.outboundSms.record({
|
||||
organizationId: campaign.organizationId,
|
||||
personId: recipient.personId,
|
||||
|
||||
Reference in New Issue
Block a user