Skip to content

Feat 7714 adding semaphore messaging adapter - #144

Closed
deepshekhardas wants to merge 2 commits into
utopia-php:mainfrom
deepshekhardas:fix/pr-80-semaphore
Closed

Feat 7714 adding semaphore messaging adapter#144
deepshekhardas wants to merge 2 commits into
utopia-php:mainfrom
deepshekhardas:fix/pr-80-semaphore

Conversation

@deepshekhardas

Copy link
Copy Markdown

Rebased on latest main with conflict resolution.

Changes:

  • Added Semaphore SMS adapter
  • Added SEMAPHORE_* env variables to .env.dev
  • Added parent::__construct() call for compatibility

Conflicts resolved:

  • .env.dev: merged upstream (DISCORD_WEBHOOK_URL) with PR (SEMAPHORE_*) variables

@github-actions

Copy link
Copy Markdown

Thanks for contributing! This repository is a read-only mirror; development for this library happens in packages/messaging in the utopia-php monorepo. Please open this pull request there instead.

@github-actions github-actions Bot closed this Jul 25, 2026
@greptile-apps

greptile-apps Bot commented Jul 25, 2026

Copy link
Copy Markdown

Greptile Summary

Adds a Semaphore SMS provider integration.

  • Adds Semaphore API credentials and test-recipient variables to the development environment template.
  • Implements the Semaphore request and response adapter.
  • Adds an integration-style SMS send test for the new provider.

Confidence Score: 2/5

This PR is not safe to merge until Semaphore correctly handles all accepted recipients, reports successful delivery counts, preserves request failures, and safely parses validation errors.

The new adapter silently drops recipients after the first, returns deliveredTo as zero on success, produces an empty response for common HTTP and transport failures, and reads a missing numeric index from documented validation-error responses.

Files Needing Attention: src/Utopia/Messaging/Adapter/SMS/Semaphore.php

Important Files Changed

Filename Overview
src/Utopia/Messaging/Adapter/SMS/Semaphore.php Adds the Semaphore adapter, but bulk sends omit recipients, successful sends report zero deliveries, common HTTP failures return no recipient result, and documented validation errors trigger an undefined-key warning.
tests/Messaging/Adapter/SMS/SemaphoreTest.php Adds a single-recipient integration test whose shared success assertion exposes the adapter's missing deliveredTo update.
.env.dev Adds the API key, recipient, and sender-name variables required by the Semaphore integration test.

Fix All in Claude Code Fix All in Codex

Prompt To Fix All With AI
Fix the following 4 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 4
src/Utopia/Messaging/Adapter/SMS/Semaphore.php:51
**Bulk sends drop recipients**

When a message contains 2–1000 recipients, the adapter accepts the message but submits and records only `getTo()[0]`, causing every remaining recipient to be silently omitted from delivery and results.

### Issue 2 of 4
src/Utopia/Messaging/Adapter/SMS/Semaphore.php:59
**Successful delivery count stays zero**

When Semaphore returns a successful response, this branch adds a result without updating `deliveredTo`, causing successful sends to report zero deliveries and fail the shared adapter response assertion.

### Issue 3 of 4
src/Utopia/Messaging/Adapter/SMS/Semaphore.php:70-73
**Non-500 failures lose results**

When Semaphore returns an authentication, validation, rate-limit, service, or transport failure with a status other than 500, neither branch adds a result, causing the adapter to return an empty result set with no recipient or error details.

### Issue 4 of 4
src/Utopia/Messaging/Adapter/SMS/Semaphore.php:58
**Validation errors access missing index**

When Semaphore returns its documented 200 validation-error object keyed by fields such as `sendername`, this condition reads the nonexistent numeric key `0`, causing an undefined-array-key warning before error handling continues.

Reviews (1): Last reviewed commit: "Added: Semaphore SMS adapter" | Re-trigger Greptile

],
body: [
'apikey' => $this->apikey,
'number' => $message->getTo()[0],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Bulk sends drop recipients

When a message contains 2–1000 recipients, the adapter accepts the message but submits and records only getTo()[0], causing every remaining recipient to be silently omitted from delivery and results.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Utopia/Messaging/Adapter/SMS/Semaphore.php
Line: 51

Comment:
**Bulk sends drop recipients**

When a message contains 2–1000 recipients, the adapter accepts the message but submits and records only `getTo()[0]`, causing every remaining recipient to be silently omitted from delivery and results.

How can I resolve this? If you propose a fix, please make it concise.

Fix in Claude Code Fix in Codex


if ($result['statusCode'] === 200) {
if ($result['response'][0] && count($result['response'][0]) > 1) {
$response->addResult($message->getTo()[0]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Successful delivery count stays zero

When Semaphore returns a successful response, this branch adds a result without updating deliveredTo, causing successful sends to report zero deliveries and fail the shared adapter response assertion.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Utopia/Messaging/Adapter/SMS/Semaphore.php
Line: 59

Comment:
**Successful delivery count stays zero**

When Semaphore returns a successful response, this branch adds a result without updating `deliveredTo`, causing successful sends to report zero deliveries and fail the shared adapter response assertion.

How can I resolve this? If you propose a fix, please make it concise.

Fix in Claude Code Fix in Codex

Comment on lines +70 to +73
}
if ($result['statusCode'] === 500) {
$response->addResult($message->getTo()[0], $result['response'][0]);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Non-500 failures lose results

When Semaphore returns an authentication, validation, rate-limit, service, or transport failure with a status other than 500, neither branch adds a result, causing the adapter to return an empty result set with no recipient or error details.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Utopia/Messaging/Adapter/SMS/Semaphore.php
Line: 70-73

Comment:
**Non-500 failures lose results**

When Semaphore returns an authentication, validation, rate-limit, service, or transport failure with a status other than 500, neither branch adds a result, causing the adapter to return an empty result set with no recipient or error details.

How can I resolve this? If you propose a fix, please make it concise.

Fix in Claude Code Fix in Codex

);

if ($result['statusCode'] === 200) {
if ($result['response'][0] && count($result['response'][0]) > 1) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Validation errors access missing index

When Semaphore returns its documented 200 validation-error object keyed by fields such as sendername, this condition reads the nonexistent numeric key 0, causing an undefined-array-key warning before error handling continues.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Utopia/Messaging/Adapter/SMS/Semaphore.php
Line: 58

Comment:
**Validation errors access missing index**

When Semaphore returns its documented 200 validation-error object keyed by fields such as `sendername`, this condition reads the nonexistent numeric key `0`, causing an undefined-array-key warning before error handling continues.

How can I resolve this? If you propose a fix, please make it concise.

Fix in Claude Code Fix in Codex

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.

2 participants