mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-13 15:14:49 -06:00
Refactor N8n integration: update schema exports, improve import order, and enhance service logic
- Added export for N8n schema in chatbot.schema.ts. - Improved import order in n8n.dto.ts and n8n.router.ts for better readability. - Refactored variable declarations in n8n.service.ts for consistency and clarity.
This commit is contained in:
parent
38f089f04c
commit
71101807bb
@ -2,6 +2,6 @@ export * from '@api/integrations/chatbot/chatwoot/validate/chatwoot.schema';
|
||||
export * from '@api/integrations/chatbot/dify/validate/dify.schema';
|
||||
export * from '@api/integrations/chatbot/evolutionBot/validate/evolutionBot.schema';
|
||||
export * from '@api/integrations/chatbot/flowise/validate/flowise.schema';
|
||||
export * from '@api/integrations/chatbot/n8n/validate/n8n.schema';
|
||||
export * from '@api/integrations/chatbot/openai/validate/openai.schema';
|
||||
export * from '@api/integrations/chatbot/typebot/validate/typebot.schema';
|
||||
export * from '@api/integrations/chatbot/n8n/validate/n8n.schema';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { TriggerType, TriggerOperator } from '@prisma/client';
|
||||
import { TriggerOperator, TriggerType } from '@prisma/client';
|
||||
|
||||
export class N8nDto {
|
||||
enabled?: boolean;
|
||||
|
@ -1,18 +1,19 @@
|
||||
import { RouterBroker } from '@api/abstract/abstract.router';
|
||||
import { IgnoreJidDto } from '@api/dto/chatbot.dto';
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { N8nDto, N8nSettingDto } from '../dto/n8n.dto';
|
||||
import { HttpStatus } from '@api/routes/index.router';
|
||||
import { n8nController } from '@api/server.module';
|
||||
import {
|
||||
instanceSchema,
|
||||
n8nIgnoreJidSchema,
|
||||
n8nSchema,
|
||||
n8nSettingSchema,
|
||||
n8nStatusSchema,
|
||||
instanceSchema,
|
||||
} from '@validate/validate.schema';
|
||||
import { RequestHandler, Router } from 'express';
|
||||
|
||||
import { N8nDto, N8nSettingDto } from '../dto/n8n.dto';
|
||||
|
||||
export class N8nRouter extends RouterBroker {
|
||||
constructor(...guards: RequestHandler[]) {
|
||||
super();
|
||||
|
@ -1,11 +1,12 @@
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
import { PrismaRepository } from '@api/repository/repository.service';
|
||||
import { WAMonitoringService } from '@api/services/monitor.service';
|
||||
import { Logger } from '@config/logger.config';
|
||||
import { IntegrationSession, N8n, N8nSetting } from '@prisma/client';
|
||||
import { sendTelemetry } from '@utils/sendTelemetry';
|
||||
import axios from 'axios';
|
||||
import { InstanceDto } from '@api/dto/instance.dto';
|
||||
|
||||
import { N8nDto } from '../dto/n8n.dto';
|
||||
import { WAMonitoringService } from '@api/services/monitor.service';
|
||||
|
||||
export class N8nService {
|
||||
private readonly logger = new Logger('N8nService');
|
||||
@ -13,7 +14,7 @@ export class N8nService {
|
||||
|
||||
constructor(
|
||||
waMonitor: WAMonitoringService,
|
||||
private readonly prismaRepository: PrismaRepository
|
||||
private readonly prismaRepository: PrismaRepository,
|
||||
) {
|
||||
this.waMonitor = waMonitor;
|
||||
}
|
||||
@ -164,7 +165,7 @@ export class N8nService {
|
||||
content: string,
|
||||
) {
|
||||
try {
|
||||
let endpoint: string = n8n.webhookUrl;
|
||||
const endpoint: string = n8n.webhookUrl;
|
||||
const payload: any = {
|
||||
chatInput: content,
|
||||
sessionId: session.sessionId,
|
||||
@ -210,7 +211,7 @@ export class N8nService {
|
||||
return null;
|
||||
};
|
||||
while ((match = linkRegex.exec(message)) !== null) {
|
||||
const [fullMatch, exclMark, altText, url] = match;
|
||||
const [altText, url] = match;
|
||||
const mediaType = getMediaType(url);
|
||||
const beforeText = message.slice(lastIndex, match.index);
|
||||
if (beforeText) {
|
||||
|
Loading…
Reference in New Issue
Block a user