mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-20 12:22:21 -06:00
refactor: improve session handling and validation in N8n integration
This commit enhances the N8n integration by refining session management and validation logic. Key changes include: - Added error handling for session creation failures in the BaseChatbotService. - Removed unused methods and properties in N8nService and N8nDto to streamline the codebase. - Updated N8n schema to enforce required fields and improve validation checks. - Simplified message processing logic to utilize base class methods, enhancing maintainability. These improvements contribute to a more robust and efficient N8n integration.
This commit is contained in:
@@ -353,20 +353,25 @@ export abstract class BaseChatbotService<BotType = any, SettingsType = any> {
|
||||
? pushName
|
||||
: null;
|
||||
|
||||
session = (
|
||||
await this.createNewSession(
|
||||
{
|
||||
instanceName: instance.instanceName,
|
||||
instanceId: instance.instanceId,
|
||||
},
|
||||
{
|
||||
remoteJid,
|
||||
pushName: pushNameValue,
|
||||
botId: (bot as any).id,
|
||||
},
|
||||
this.getBotType(),
|
||||
)
|
||||
)?.session;
|
||||
const sessionResult = await this.createNewSession(
|
||||
{
|
||||
instanceName: instance.instanceName,
|
||||
instanceId: instance.instanceId,
|
||||
},
|
||||
{
|
||||
remoteJid,
|
||||
pushName: pushNameValue,
|
||||
botId: (bot as any).id,
|
||||
},
|
||||
this.getBotType(),
|
||||
);
|
||||
|
||||
if (!sessionResult || !sessionResult.session) {
|
||||
this.logger.error('Failed to create new session');
|
||||
return;
|
||||
}
|
||||
|
||||
session = sessionResult.session;
|
||||
}
|
||||
|
||||
// Update session status to opened
|
||||
|
||||
Reference in New Issue
Block a user