-
Notifications
You must be signed in to change notification settings - Fork 83
feat: update iransmspanel gateway to support bulk SMS and template #408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
β¦ssaging ## Changes ### Persian Bulk SMS Gateway Updates - Updated gateway to use Persian Bulk SMS API (persianbulk.com, formerly iransmspanel.ir) - Updated API base URL to https://developer.persianbulk.com - Updated documentation and help text to reflect new branding ### Bulk SMS Support - Implemented SendArray endpoint for efficient bulk message delivery - Changed from comma-separated string to array format for recipients - All messages now use bulk endpoint by default for better performance ### Template SMS Support - Added SendTemplateSMS() public method for direct template message sending - Implemented auto-detection for template messages in SendSMS() method - Added support for multiple tokens (token, token2, token3, etc.) - Template format: "template:TEMPLATE_ID|token:VALUE|date:VALUE|token2:VALUE2" - Flexible token passing: string, array, or additional parameters ### Features - Single recipient and multiple recipient support - Optional date parameter for templates - Comprehensive error handling and logging - Backward compatible with existing code - WordPress filters maintained (wp_sms_from, wp_sms_to, wp_sms_msg) ## API Endpoints Used - `/sms/SendArray` - Bulk SMS sending - `/sms/Send/pattern` - Template SMS sending - `/sms/Balance` - Account credit/balance retrieval ## Breaking Changes None. All existing functionality remains compatible. π€ Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
π€ Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
WalkthroughThe PR updates the Iran SMS Panel gateway integration to use Persian Bulk SMS API. This includes remapping the gateway domain from iransmspanel.ir to persianbulk.com in the global gateway registry, and comprehensively refactoring the gateway class to migrate from legacy socket/cURL flows to Persian Bulk's API-based endpoints with template support and API key authentication. Changes
Estimated code review effortπ― 4 (Complex) | β±οΈ ~45 minutes
Possibly related PRs
Pre-merge checks and finishing touchesβ Passed checks (3 passed)
β¨ Finishing touches
π§ͺ Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (2)
includes/class-wpsms-gateway.php(1 hunks)includes/gateways/class-wpsms-gateway-iransmspanel.php(1 hunks)
π§° Additional context used
𧬠Code graph analysis (1)
includes/gateways/class-wpsms-gateway-iransmspanel.php (1)
includes/class-wpsms-gateway.php (7)
help(995-1005)__construct(380-411)from(1010-1016)response(987-990)request(1134-1139)status(925-982)log(546-567)
π Additional comments (1)
includes/class-wpsms-gateway.php (1)
817-817: LGTM: gateway mapping now reflects Persian BulkThe slug now points to persianbulk.com, keeping the registry consistent with the refactored gateway class.
| 'sender' => $receptor, // Recipient number | ||
| 'template' => $template, // Template ID | ||
| ]; | ||
|
|
||
| // Handle token parameter - supports string or array | ||
| if (is_array($token)) { | ||
| // Multiple tokens provided as array | ||
| // Try format 1: token, token2, token3, etc. | ||
| $body['token'] = $token[0] ?? ''; | ||
| for ($i = 1; $i < count($token); $i++) { | ||
| $body['token' . ($i + 1)] = $token[$i]; | ||
| } | ||
| } else { | ||
| // Single token as string | ||
| $body['token'] = $token; | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix template payload: recipient sent as sender
Both SendTemplateSMS() and sendTemplateMessage() populate the request body with 'sender' => $receptor and never send a receptor field. Persian Bulk expects the sender line ID and the recipient number separately; with the current mapping the API receives no recipient and uses the target number as the sender, so template messages will fail. Please swap the assignments so the sender line comes from $this->from and add the missing receptor.
Apply this diff:
- 'sender' => $receptor,
- 'template' => $template,
+ 'sender' => $this->from,
+ 'receptor' => $receptor,
+ 'template' => $template,- 'sender' => $receptor,
- 'template' => $data['template'],
- 'token' => $data['token'],
+ 'sender' => $this->from,
+ 'receptor' => $receptor,
+ 'template' => $data['template'],
+ 'token' => $data['token'],Also applies to: 249-253
π€ Prompt for AI Agents
In includes/gateways/class-wpsms-gateway-iransmspanel.php around lines 153 to
169 (also apply same change to lines ~249-253), the request body maps the
recipient into the 'sender' field and omits 'receptor'; change the payload so
'sender' is set to $this->from (the SMS line ID) and add a 'receptor' =>
$receptor entry to include the recipient number, keeping the existing 'template'
and token handling intact; apply the identical swap/addition for the other
occurrence at lines ~249-253.
Describe your changes
Refactor iransmspanel gateway based on new API https://developer.persianbulk.com
Submission Review Guidelines:
CHANGELOG.md.Type of change
Summary by CodeRabbit
New Features
Chores