Adding SMS automation
This commit is contained in:
@@ -3,9 +3,10 @@ import { ActivitiesController } from './activities.controller';
|
||||
import { ActivitiesService } from './activities.service';
|
||||
import { NotificationsModule } from '../notifications/notifications.module';
|
||||
import { AutomationsModule } from '../automations/automations.module';
|
||||
import { MessageAutomationsModule } from '../message-automations/message-automations.module';
|
||||
|
||||
@Module({
|
||||
imports: [NotificationsModule, AutomationsModule],
|
||||
imports: [NotificationsModule, AutomationsModule, MessageAutomationsModule],
|
||||
controllers: [ActivitiesController],
|
||||
providers: [ActivitiesService],
|
||||
exports: [ActivitiesService],
|
||||
|
||||
@@ -15,6 +15,7 @@ import { Prisma } from '@prisma/client';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { NotificationsService } from '../notifications/notifications.service';
|
||||
import { AutomationsService } from '../automations/automations.service';
|
||||
import { MessageAutomationsService } from '../message-automations/message-automations.service';
|
||||
import { type Actor, assigneeWhere, ownerWhere } from '../common/record-scope';
|
||||
|
||||
type ActivityActor = Pick<Actor, 'userId' | 'role'>;
|
||||
@@ -55,6 +56,7 @@ export class ActivitiesService {
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly notifications: NotificationsService,
|
||||
private readonly automations: AutomationsService,
|
||||
private readonly messageAutomations: MessageAutomationsService,
|
||||
) {}
|
||||
|
||||
async summary(
|
||||
@@ -211,6 +213,18 @@ export class ActivitiesService {
|
||||
});
|
||||
}
|
||||
|
||||
await this.messageAutomations.onEvent('activity_created', {
|
||||
organizationId,
|
||||
entityType: 'activity',
|
||||
entityId: row.id,
|
||||
title: row.title,
|
||||
personId: row.person?.id ?? null,
|
||||
companyId: row.company?.id ?? null,
|
||||
dealId: row.deal?.id ?? null,
|
||||
assigneeId: row.assignee?.id ?? null,
|
||||
ownerId: row.assignee?.id ?? null,
|
||||
});
|
||||
|
||||
return this.toDto(row);
|
||||
}
|
||||
|
||||
@@ -377,9 +391,9 @@ export class ActivitiesService {
|
||||
assignee: { id: string } | null;
|
||||
},
|
||||
) {
|
||||
await this.automations.runTrigger('activity_done', {
|
||||
const ctx = {
|
||||
organizationId,
|
||||
entityType: 'activity',
|
||||
entityType: 'activity' as const,
|
||||
entityId: row.id,
|
||||
title: row.title,
|
||||
personId: row.person?.id ?? null,
|
||||
@@ -387,7 +401,9 @@ export class ActivitiesService {
|
||||
dealId: row.deal?.id ?? null,
|
||||
assigneeId: row.assignee?.id ?? null,
|
||||
ownerId: row.assignee?.id ?? null,
|
||||
});
|
||||
};
|
||||
await this.automations.runTrigger('activity_done', ctx);
|
||||
await this.messageAutomations.onEvent('activity_done', ctx);
|
||||
}
|
||||
|
||||
private async ensureExists(
|
||||
|
||||
Reference in New Issue
Block a user