Skip to content

IAV-252/feat(custom-instructions): Add FAQ category support and refactor service layer

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

Summary

This MR introduces FAQ category association for custom instructions and refactors the service layer for improved consistency and maintainability.

Changes

New Features

  • FAQ Category Support: Custom instructions can now be linked to FAQ categories
    • Required for SUGGESTIONS category instructions
    • Forbidden for RESTRICTIONS category instructions
  • Bulk Deactivation: New deactivateInstructionsByFaqCategory() method allows deactivating all instructions associated with a specific FAQ category (useful when a FAQ category is deleted or disabled)

Refactoring

  • Unified agent lookup using AgentValidationHelper.findAgentByUidOrThrow() across all methods
  • Extracted getAgentCustomInstructionByUidOrThrow() helper to eliminate duplicated instruction lookup code
  • Added resolveFaqCategory() helper for centralized FAQ category validation logic
  • Removed unused CustomerCareAgentRepository dependency

DTOs & Mapper Updates

  • Added faqCategoryUid to request DTO
  • Added faqCategoryUid and faqCategoryName to response DTO
  • Updated mapper to use ModelMapper with manual field overrides for related entities

New Validations

Error Code Condition
FAQ_CATEGORY_REQUIRED SUGGESTIONS instruction without FAQ category
FAQ_CATEGORY_NOT_ALLOWED RESTRICTIONS instruction with FAQ category
FAQ_CATEGORY_NOT_FOUND Provided FAQ category UID doesn't exist

Testing

  • Create SUGGESTIONS instruction with valid FAQ category
  • Create SUGGESTIONS instruction without FAQ category → Error
  • Create RESTRICTIONS instruction without FAQ category
  • Create RESTRICTIONS instruction with FAQ category → Error
  • Update instruction with FAQ category change
  • Bulk deactivate instructions by FAQ category

Related Issues

Closes IAV-252

Rapports de requête de fusion