-
- Notifications
You must be signed in to change notification settings - Fork 9.7k
[Notifier] Add support for building SmsEvent by dlr_code and RemoteEvent for other LOX24 webhook event types #61778
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
Conversation
src/Symfony/Component/Notifier/Bridge/Lox24/Tests/Webhook/Lox24RequestParserTest.php Show resolved Hide resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Tests/Webhook/Lox24RequestParserTest.php Show resolved Hide resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Tests/Webhook/Lox24RequestParserTest.php Outdated Show resolved Hide resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Tests/Webhook/Lox24RequestParserTest.php Outdated Show resolved Hide resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Tests/Webhook/Lox24RequestParserTest.php Outdated Show resolved Hide resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Tests/Webhook/Lox24RequestParserTest.php Outdated Show resolved Hide resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Webhook/LOX24RequestParser.php Outdated Show resolved Hide resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Webhook/LOX24RequestParser.php Outdated Show resolved Hide resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Webhook/LOX24RequestParser.php Outdated Show resolved Hide resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Webhook/LOX24RequestParser.php Outdated Show resolved Hide resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Webhook/LOX24RequestParser.php Outdated Show resolved Hide resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Webhook/LOX24RequestParser.php Outdated Show resolved Hide resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Webhook/Lox24RequestParser.php Outdated Show resolved Hide resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Webhook/LOX24RequestParser.php Outdated Show resolved Hide resolved
private function createIncomingSmsEvent(array $data, array $payload): RemoteEvent | ||
{ | ||
if (!isset($data['from'], $data['to'], $data['text'])) { | ||
throw new RejectWebhookException(406, 'Incoming SMS payload is malformed - missing required fields.'); |
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.
Let's mention the missing field.
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.
Not resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Webhook/LOX24RequestParser.php Outdated Show resolved Hide resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Webhook/LOX24RequestParser.php Outdated Show resolved Hide resolved
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.
A lot of my suggestions were marked as resolved but they were not. I'm fine but can you add a small comment about why you don't think my comment was relevant/useful?
src/Symfony/Component/Notifier/Bridge/Lox24/Webhook/LOX24RequestParser.php Outdated Show resolved Hide resolved
private function createIncomingSmsEvent(array $data, array $payload): RemoteEvent | ||
{ | ||
if (!isset($data['from'], $data['to'], $data['text'])) { | ||
throw new RejectWebhookException(406, 'Incoming SMS payload is malformed - missing required fields.'); |
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.
Not resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Webhook/LOX24RequestParser.php Outdated Show resolved Hide resolved
'phone_number' => '+1234567890', | ||
'fraud_score' => 0.5, | ||
], | ||
default => [], // For email parsing events, minimal data is acceptable |
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.
Not resolved
@fabpot please review |
src/Symfony/Component/Notifier/Bridge/Lox24/Webhook/LOX24RequestParser.php Outdated Show resolved Hide resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Webhook/LOX24RequestParser.php Outdated Show resolved Hide resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Webhook/LOX24RequestParser.php Outdated Show resolved Hide resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Webhook/LOX24RequestParser.php Outdated Show resolved Hide resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Webhook/LOX24RequestParser.php Outdated Show resolved Hide resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Webhook/LOX24RequestParser.php Outdated Show resolved Hide resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Webhook/LOX24RequestParser.php Outdated Show resolved Hide resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Webhook/LOX24RequestParser.php Outdated Show resolved Hide resolved
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.
LGTM after some CS changes
@nicolas-grekas thank you! i've committed yours changes. Please check it |
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.
Can you please unify all exception messages? One sentence, no dash, mentioning that the fields are required, ...
src/Symfony/Component/Notifier/Bridge/Lox24/Webhook/LOX24RequestParser.php Outdated Show resolved Hide resolved
Should we really add new events that are specific to the LOX24 bridge instead of having a proper abstraction in the component that can implemented by the different bridges ? You could totally implement a remote event parser as part of a LOX24 SDK supporting all their features (outside Symfony core), but this does not belong to the notifier bridge IMO. |
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.
Please, unify the error messages.
src/Symfony/Component/Notifier/Bridge/Lox24/Webhook/LOX24RequestParser.php Outdated Show resolved Hide resolved
src/Symfony/Component/Notifier/Bridge/Lox24/Webhook/LOX24RequestParser.php Outdated Show resolved Hide resolved
@stof @nicolas-grekas i've removed LOX24 specific webhooks parsing logic. please check |
which conflicts i need to resolve? |
Maybe because the class name has changed from |
the LOX24RequestParser file/class has been renamed to Lox24RequestParser |
@fabpot done. please check this |
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.
As response to my previous comment #61778 (comment), you said you reverted the logic for LOX24-specific webhooks. However, both the code and the changelog entry you added tell me that you are still adding support for the LOX24-specific webhooks that don't match the Symfony abstraction of the notifier webhooks.
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.
I suppose the PR title+description should also be synced now that the scope is reduced. LGTM otherwise, after some minor stuff.
| ||
private function createDeliveryEvent(array $data, array $payload): ?SmsEvent | ||
{ | ||
if (!isset($data['id'])) { |
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.
just for confirmation: we already checked that id is present in payload, and id now also has to be inside payload['data'], is that correct?
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.
I checked the doc, it's correct:
https://doc.lox24.eu/#tag/sms/operation/webhooks.sms-delivery-webhook
…ent for other LOX24 webhook event types
Thank you @alebedev80. |
return new SmsEvent($eventType, $data['id'], $payload); | ||
} | ||
| ||
private function createRemoteEvent(string $eventName, array $payload): RemoteEvent |
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.
Let's inline the code and remove this private method as it's only called once.
Summary
This PR enhances the LOX24RequestParser to provide robust SMS delivery webhook parsing with improved validation, dual status code support (DLR codes and status codes), and better error handling for SMS delivery events.
What it does
Before: The parser had basic SMS delivery webhook handling with limited validation and error handling.
After: The parser provides enhanced SMS delivery webhook processing:
sms.delivery
&sms.delivery.dryrun
- SMS delivery receipts with improved validationExample Usage
Enhanced SMS Delivery Processing:
Key Changes
1. Improved Payload Validation
id
,name
,data
2. Smart Return Types
sms.delivery
,sms.delivery.dryrun
) returnSmsEvent
objects with DELIVERED/FAILED statusRemoteEvent
objects for generic webhook handlingnull
return for pending deliveries (status_code=0 or dlr_code=0/2/4)3. Enhanced SMS Delivery Validation
4. Dual Status Code Support
4. Comprehensive Testing
SmsEvent
vsRemoteEvent
)Backward Compatibility
✅ Fully backward compatible - existing consumers continue working without changes:
sms.delivery
event handling behaviorConsumer Integration Example
Breaking Changes
?SmsEvent
toSmsEvent|RemoteEvent|null
id
field (LOX24 standard)RemoteEvent
instead of being rejectedTechnical Implementation
createDeliveryEvent
,createRemoteEvent
, etc.)Testing
This enhancement improves LOX24 SMS delivery webhook processing with better validation, dual status code support, and robust error handling while maintaining complete backward compatibility.