Let automations fire on more CRM events and open the studio from the main nav.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { LoyaltyModule } from '../loyalty/loyalty.module';
|
||||
import { AutomationsModule } from '../automations/automations.module';
|
||||
import { CompaniesController } from './companies.controller';
|
||||
import { CompaniesService } from './companies.service';
|
||||
import { PeopleController } from './people.controller';
|
||||
@@ -7,7 +8,7 @@ import { PeopleService } from './people.service';
|
||||
import { ContactsExcelService } from './contacts-excel.service';
|
||||
|
||||
@Module({
|
||||
imports: [LoyaltyModule],
|
||||
imports: [LoyaltyModule, AutomationsModule],
|
||||
controllers: [PeopleController, CompaniesController],
|
||||
providers: [PeopleService, CompaniesService, ContactsExcelService],
|
||||
exports: [PeopleService, CompaniesService],
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
resolveOwnerId,
|
||||
} from '../common/record-scope';
|
||||
import { LoyaltyService } from '../loyalty/loyalty.service';
|
||||
import { AutomationsService } from '../automations/automations.service';
|
||||
|
||||
const personInclude = {
|
||||
company: { select: { id: true, name: true } },
|
||||
@@ -64,6 +65,7 @@ export class PeopleService {
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly companies: CompaniesService,
|
||||
private readonly loyalty: LoyaltyService,
|
||||
private readonly automations: AutomationsService,
|
||||
) {}
|
||||
|
||||
async list(
|
||||
@@ -149,6 +151,15 @@ export class PeopleService {
|
||||
include: personInclude,
|
||||
});
|
||||
await this.loyalty.applyWelcomePoints(actor.organizationId, row.id);
|
||||
await this.automations.runTrigger('person_created', {
|
||||
organizationId: actor.organizationId,
|
||||
entityType: 'person',
|
||||
entityId: row.id,
|
||||
title: `${row.firstName} ${row.lastName}`.trim(),
|
||||
personId: row.id,
|
||||
companyId: row.companyId,
|
||||
ownerId: row.ownerId,
|
||||
});
|
||||
const fresh = await this.prisma.person.findFirst({
|
||||
where: { id: row.id },
|
||||
include: personInclude,
|
||||
|
||||
Reference in New Issue
Block a user