Adding SMS automation
This commit is contained in:
@@ -26,6 +26,7 @@ import {
|
||||
} from '../common/record-scope';
|
||||
import { LoyaltyService } from '../loyalty/loyalty.service';
|
||||
import { AutomationsService } from '../automations/automations.service';
|
||||
import { MessageAutomationsService } from '../message-automations/message-automations.service';
|
||||
|
||||
const personInclude = {
|
||||
company: { select: { id: true, name: true } },
|
||||
@@ -66,6 +67,7 @@ export class PeopleService {
|
||||
private readonly companies: CompaniesService,
|
||||
private readonly loyalty: LoyaltyService,
|
||||
private readonly automations: AutomationsService,
|
||||
private readonly messageAutomations: MessageAutomationsService,
|
||||
) {}
|
||||
|
||||
async list(
|
||||
@@ -151,15 +153,17 @@ export class PeopleService {
|
||||
include: personInclude,
|
||||
});
|
||||
await this.loyalty.applyWelcomePoints(actor.organizationId, row.id);
|
||||
await this.automations.runTrigger('person_created', {
|
||||
const createdCtx = {
|
||||
organizationId: actor.organizationId,
|
||||
entityType: 'person',
|
||||
entityType: 'person' as const,
|
||||
entityId: row.id,
|
||||
title: `${row.firstName} ${row.lastName}`.trim(),
|
||||
personId: row.id,
|
||||
companyId: row.companyId,
|
||||
ownerId: row.ownerId,
|
||||
});
|
||||
};
|
||||
await this.automations.runTrigger('person_created', createdCtx);
|
||||
await this.messageAutomations.onEvent('person_created', createdCtx);
|
||||
const fresh = await this.prisma.person.findFirst({
|
||||
where: { id: row.id },
|
||||
include: personInclude,
|
||||
|
||||
Reference in New Issue
Block a user