Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Notifier] Add Orange SMS bridge#44884
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
carsonbot commentedJan 1, 2022
Hey! I see that this is your first PR. That is great! Welcome! Symfony has acontribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
OskarStark commentedJan 1, 2022
Please target 6.1 branch |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Notifier/Bridge/OrangeSms/OrangeSmsTransport.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Notifier/Bridge/OrangeSms/OrangeSmsTransportFactory.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Notifier/Bridge/OrangeSms/OrangeSmsTransportFactory.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Notifier/Bridge/OrangeSms/OrangeSmsTransport.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
| public function toStringProvider(): iterable | ||
| { | ||
| yield ['orangesms://default?from=FROM&sender_name=SENDER_NAME', $this->createTransport()]; |
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.
Test missing, where Sender name is not set
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
| private $clientID; | ||
| private $clientSecret; | ||
| private $from; | ||
| private $senderName; | ||
| public function __construct(string $clientID, string $clientSecret, string $from, ?string $senderName, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null) | ||
| { | ||
| $this->clientID = $clientID; | ||
| $this->clientSecret = $clientSecret; | ||
| $this->from = $from; | ||
| $this->senderName = $senderName; | ||
| parent::__construct($client, $dispatcher); | ||
| } |
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.
Since 6.1 is PHP 8 only, why not just use constructor property promotion?
| private$clientID; | |
| private$clientSecret; | |
| private$from; | |
| private$senderName; | |
| publicfunction __construct(string$clientID,string$clientSecret,string$from, ?string$senderName,HttpClientInterface$client =null,EventDispatcherInterface$dispatcher =null) | |
| { | |
| $this->clientID =$clientID; | |
| $this->clientSecret =$clientSecret; | |
| $this->from =$from; | |
| $this->senderName =$senderName; | |
| parent::__construct($client,$dispatcher); | |
| } | |
| publicfunction __construct(privatestring$clientID,privatestring$clientSecret,privatestring$from,private ?string$senderName,HttpClientInterface$client =null,EventDispatcherInterface$dispatcher =null) | |
| { | |
| parent::__construct($client,$dispatcher); | |
| } |
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 sure Symfony uses it
Cc @symfony/mergers
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 don't see any reason not to use it in new code. But before, we have to be sure that PHP-CS-Fixer/fabbot is compatible.
GromNaN left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
Nice addition.
After a rebase on branch 6.1, you can update the target of this PR.
src/Symfony/Component/Notifier/Bridge/OrangeSms/OrangeSmsTransport.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
| $url = 'https://'.$this->getEndpoint().'/smsmessaging/v1/outbound/'.urlencode('tel:'.$this->from).'/requests'; | ||
| $headers = [ | ||
| 'Authorization' => 'Bearer '.$this->getAccessToken(), |
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.
The access token should be cached and reused if several messages are sent. But that would require some expiration management for long running processes.
This is not blocking and could be handled in a future PR.
| $url = 'https://'.$this->getEndpoint().'/oauth/v3/token'; | ||
| $credentials = $this->clientID.':'.$this->clientSecret; | ||
| $headers = [ | ||
| 'Authorization' => 'Basic '.base64_encode($credentials), |
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.
The HTTP client has theauth_basic option for that.
https://symfony.com/doc/current/http_client.html#authentication
src/Symfony/Component/Notifier/Bridge/OrangeSms/OrangeSmsTransport.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Notifier/Bridge/OrangeSms/OrangeSmsTransport.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
| private string $clientID; | ||
| private string $clientSecret; | ||
| private string $from; | ||
| private string $senderName; |
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.
this is wrong. The constructor will assignstring|null in this property
| $errorMessage = $content['requestError']['serviceException']['messageId'] ?? ''; | ||
| $errorInfo = $content['requestError']['serviceException']['text'] ?? ''; | ||
| throw new TransportException(sprintf('Unable to send the SMS: '.$errorMessage.' (%s).', $errorInfo), $response); |
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.
concatenating the error message into the format string ofsprintf is a no-go, as it would require escaping% in the error message to avoid breaking it.
stof commentedJan 4, 2022
please also check the CI failures |
OskarStark commentedJan 4, 2022
Please rebase on 6.1 branch and target 6.1 afterwards, thanks |
enigma972 commentedJan 5, 2022
By bad handling I deleted the fork, so I had to open another pull request |
This PR was squashed before being merged into the 6.1 branch.Discussion----------[Notifier] Add Orange SMS bridge| Q | A| ------------- | ---| Branch? | 6.1| Bug fix? | no| New feature? | yes| Deprecations? | no| License | MITAdd Orange SMS bridgePreviously [#44884](#44884)Commits-------1aebeaf [Notifier] Add Orange SMS bridge
This PR was squashed before being merged into the 6.1 branch.Discussion----------[Notifier] Add Orange SMS bridge| Q | A| ------------- | ---| Branch? | 6.1| Bug fix? | no| New feature? | yes| Deprecations? | no| License | MITAdd Orange SMS bridgePreviously [#44884](symfony/symfony#44884)Commits-------1aebeaf77c [Notifier] Add Orange SMS bridge
Add Orange SMS bridge