Skip to content

feat: add Messenger class for multiple adapter failover + Vonage Messages API adapter#14

Open
deepshekhardas wants to merge 3 commits into
mainfrom
pr-8
Open

feat: add Messenger class for multiple adapter failover + Vonage Messages API adapter#14
deepshekhardas wants to merge 3 commits into
mainfrom
pr-8

Conversation

@deepshekhardas

@deepshekhardas deepshekhardas commented May 14, 2026

Copy link
Copy Markdown
Owner

Summary

This PR introduces the Messenger class for automatic failover across multiple messaging adapters and adds a new Vonage Messages API adapter.

Changes

1. Messenger Class (src/Utopia/Messaging/Messenger.php)

  • New class that orchestrates multiple adapters for failover support
  • Accepts a single Adapter or an array of Adapter[]
  • Tries adapters sequentially when exceptions are thrown
  • Validates all adapters are compatible (same type and message type)
  • Returns the first successful response
  • Throws aggregated exception with detailed error messages if all adapters fail
  • Includes 14 comprehensive test cases

2. VonageMessages Adapter (src/Utopia/Messaging/Adapter/SMS/VonageMessages.php)

  • New SMS adapter using Vonage Messages API (v1)
  • Uses Basic authentication (Base64 encoded API Key:Secret)
  • JSON body with channel: SMS, message_type: text
  • Treats HTTP 202 as successful delivery

3. VonageLegacy (src/Utopia/Messaging/Adapter/SMS/VonageLegacy.php)

  • Renamed from original Vonage adapter (legacy SMS API)
  • Maintains backwards compatibility for existing users

Test Plan

  • ✅ 14 Messenger test cases
  • ✅ VonageMessagesTest (integration tests)
  • ✅ VonageLegacyTest (integration tests)

Related Issues


Summary by cubic

Adds a Messenger for automatic failover across multiple messaging adapters to improve delivery reliability. Also introduces a VonageMessages SMS adapter and an AlibabaCloud SMS adapter, while keeping the legacy Vonage SMS API as VonageLegacy.

  • New Features

    • Messenger supports one or many adapters, tries them in order, returns first success, and aggregates errors.
    • Validates adapter/message types and enforces the minimum getMaxMessagesPerRequest.
    • VonageMessages (v1) adapter with Basic auth; JSON payload; HTTP 202 is treated as success.
    • VonageLegacy adapter for the legacy Vonage SMS API.
    • AlibabaCloud SMS adapter.
  • Bug Fixes

    • Alibaba Cloud SMS: move signature params to the URL query string (required for signature validation).

Written for commit 135a974. Summary will update on new commits.

deepshekhardas added 3 commits March 16, 2026 17:56
Alibaba SMS signature validation requires query parameters, not body.
Moved signature params from request body to URL query string.

Identified by cubic (cubic.dev)
…ages API adapter

- Add Utopia\Messaging\Messenger class for automatic failover across multiple adapters
  - Accepts single Adapter or Adapter[]
  - Tries adapters sequentially on exception
  - Validates adapter compatibility (same type and message type)
  - Returns first successful response or throws aggregated exception

- Add VonageMessages adapter using Vonage Messages API (v1)
  - Uses Basic auth (Base64 encoded API Key:Secret)
  - JSON body with channel: SMS, message_type: text
  - Treats HTTP 202 as delivered

- Rename Vonage to VonageLegacy (legacy SMS API)
  - Keeps backwards compatibility for existing users

- Add tests: MessengerTest (14 cases), VonageMessagesTest, VonageLegacyTest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚀 Feature: Vonage Messages Adapter

1 participant