Skip to content

Optimizations of the validation process#4

Merged
tsutomi merged 2 commits into
mainfrom
validation-optimizations
Aug 7, 2025
Merged

Optimizations of the validation process#4
tsutomi merged 2 commits into
mainfrom
validation-optimizations

Conversation

@tsutomi

@tsutomi tsutomi commented Aug 7, 2025

Copy link
Copy Markdown
Member

This pull request focuses on eliminating duplicate message validation logic across all major connectors (Twilio SMS, Twilio WhatsApp, SendGrid Email) and centralizing validation in the base connector class. It also updates the MediaContent type to use a more appropriate content type and adjusts related tests. These changes improve performance, maintainability, and consistency in message validation, while cleaning up redundant code in connector implementations.

Validation Centralization and Connector Refactoring

  • Removed duplicate message validation logic from SendMessageCoreAsync in TwilioSmsConnector, TwilioWhatsAppConnector, and SendGridEmailConnector, ensuring validation is only performed once in the base class (ChannelConnectorBase.SendMessageAsync). [1] [2] [3]
  • Updated the validation flow in ChannelConnectorBase.ValidateMessageCoreAsync to delegate all validation to the schema, covering message ID, endpoints, content type, and properties.
  • Removed the obsolete ValidateMessageProperties extension method from ChannelSchemaExtensions, further enforcing centralized validation.
  • Added a detailed action plan in VALIDATION_DUPLICATION_FIX_ACTION_PLAN.md outlining the rationale, steps, testing, risks, and success criteria for the validation refactor.

Media Content Type Update

  • Changed the ContentType of MediaContent from Binary to Media for better semantic accuracy.
  • Updated all related unit tests to expect MessageContentType.Media instead of Binary for media content. [1] [2] [3] [4] [5] [6] [7]

Minor Enhancements

  • Added a static factory method Endpoint.Create(IEndpoint? endpoint) to simplify endpoint conversions.

@tsutomi tsutomi requested a review from Copilot August 7, 2025 07:20
@tsutomi tsutomi self-assigned this Aug 7, 2025
@tsutomi tsutomi added the enhancement New feature or request label Aug 7, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request focuses on eliminating duplicate message validation logic across all major connectors (Twilio SMS, Twilio WhatsApp, SendGrid Email) and centralizing validation in the base connector class. It also updates the MediaContent type to use a more appropriate content type and adjusts related tests to use actual framework classes instead of test helpers.

  • Removed duplicate validation calls from concrete connector implementations, relying on centralized validation in ChannelConnectorBase
  • Changed MediaContent.ContentType from Binary to Media for better semantic accuracy
  • Replaced custom test helper classes with actual framework classes (Message, Endpoint, TextContent, etc.) across all test files

Reviewed Changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
TwilioWhatsAppConnector.cs Removed duplicate validation logic from SendMessageCoreAsync method
TwilioSmsConnector.cs Removed duplicate validation logic from SendMessageCoreAsync method
SendGridEmailConnector.cs Removed duplicate validation logic from SendMessageCoreAsync method
MediaContent.cs Changed ContentType from Binary to Media
Test files Replaced test helper classes with actual framework classes and updated assertions
ChannelSchemaExtensions.cs Removed obsolete ValidateMessageProperties method
ChannelConnectorBase.cs Updated ValidateMessageCoreAsync to use centralized schema validation
Documentation files Added comprehensive action plan and architecture documentation

…hatsAppConnectorExtendedMockTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@tsutomi tsutomi merged commit 1dae15d into main Aug 7, 2025
6 checks passed
@tsutomi tsutomi deleted the validation-optimizations branch August 7, 2025 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants