Skip to content

IAV-959/feat: integration deletion with fake credential replacement and rollback support

salaheddine zidani a demandé de fusionner feature/IAV-959 vers develop

Summary

Implements the agent-side integration deletion flow called by the orchestration service when a user disconnects a channel/ticketing integration.

Supported credential types

Currently supported: Telegram, Instagram, Facebook Messenger, WooCommerce

Not yet supported:

  • Shopify — Requires new account creation flow (OAuth re-authentication)
  • WhatsApp — Requires handling of existing account expiration/renewal
  • Freshdesk — N8N workflow integration not yet implemented

These will be addressed in follow-up tickets once their respective creation flows are ready.

What it does

When an integration is deleted, the workflow must remain valid in N8N. This MR:

  1. Validates business rules before deletion:

    • E-commerce integrations (Shopify) cannot be deleted
    • At least one communication channel must remain active
    • Ticketing (Freshdesk) deletion auto-enables IAVIA internal ticketing
  2. Creates a fake credential in N8N with placeholder data so the workflow node doesn't break

  3. Replaces the old credential in all matching workflow nodes and pushes the updated workflow back to N8N

  4. Updates agent flags (credential source → SYSTEM_GENERATED)

  5. Full rollback on any failure: restores the original workflow, deletes the fake credential, and reverts agent DB flags

Key components

Component Role
IntegrationDeletionServiceImpl Orchestrates the full deletion + rollback flow
FakeCredentialServiceImpl Creates/deletes placeholder credentials in N8N + DB
WorkflowCredentialReplacer Swaps credential IDs inside workflow nodes
AgentIntegrationManagementController REST endpoint for orchestration-service
N8nServiceImpl (extended) getWorkflowById, updateWorkflow, deleteCredential

Testing

  • Unit tests for business rule validation
  • Integration test for full deletion + rollback scenario
  • Verify existing BusinessErrorCodeTest passes with new ranges

Closes IAV-959

Rapports de requête de fusion