Skip to content

[Notifier] add OvhCloud bridge #34540

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

Merged
merged 1 commit into from
Feb 11, 2020

Conversation

antiseptikk
Copy link

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets See #33687
License MIT

This would add OvhCloud sms integration for the Notifier component.
Tested with 'ovh-eu' entrypoint.

Inspiration : https://github.com/ovh/php-ovh

CHANGELOG
=========

5.0.0
Copy link
Contributor

Choose a reason for hiding this comment

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

5.1

/**
* @author Thomas Ferney <thomas.ferney@gmail.com>
*
* @experimental in 5.0
Copy link
Contributor

Choose a reason for hiding this comment

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

5.1

* @throws \Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface
* @throws \Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface
* @throws \Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface
* @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the @throws annotations can be removed

/**
* @author Thomas Ferney <thomas.ferney@gmail.com>
*
* @experimental in 5.0
Copy link
Contributor

Choose a reason for hiding this comment

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

5.1

Copy link
Contributor

@OskarStark OskarStark left a comment

Choose a reason for hiding this comment

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

Thank you

parent::__construct($client, $dispatcher);
}

public function setHostByEndpoint(?string $endpoint): self
Copy link
Member

Choose a reason for hiding this comment

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

I find the method name confusing. What about setEndpointName() instead?

$now = time() + $this->timeDelta;
$headers['X-Ovh-Timestamp'] = $now;

if (isset($this->consumerKey)) {
Copy link
Member

Choose a reason for hiding this comment

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

if (null === $this->consumerKey) {

Copy link
Member

Choose a reason for hiding this comment

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

If my assumption is right above, the condition must be removed and local variables should be used instead.

Copy link
Author

Choose a reason for hiding this comment

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

The "consumerKey" is mandatory, so I think I can remove this condition.

If it's empty, it throws an TransportException with "Missing X-Ovh-Consumer header"
If it's undefined in the dsn, it throws an 500 with null instead of a string in __construct()

What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

indeed, that's always set, so you can remove the condition.


$headers['X-Ovh-Application'] = $this->applicationKey;

if (!isset($this->timeDelta)) {
Copy link
Member

Choose a reason for hiding this comment

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

if (null === $this->timeDelta) {

$response = $this->client->request(
'GET',
$endpoint
);
Copy link
Member

Choose a reason for hiding this comment

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

Should be on one line

}

/**
* Calculate time delta between local machine and API's server.
Copy link
Member

Choose a reason for hiding this comment

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

Calculates

Copy link
Contributor

Choose a reason for hiding this comment

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

Calculates the ...

$headers['X-Ovh-Application'] = $this->applicationKey;

if (!isset($this->timeDelta)) {
$this->calculateTimeDelta();
Copy link
Member

Choose a reason for hiding this comment

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

IIUC, this should be calculated for every email we sent as this class can be used in a long running process.

*/
private function calculateTimeDelta(): int
{
if (!isset($this->timeDelta)) {
Copy link
Member

Choose a reason for hiding this comment

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

Should be removed, if we call this method, it means that we want to compute the value.

);

$serverTimestamp = (int) (string) $response->getContent();
$this->timeDelta = $serverTimestamp - (int) time();
Copy link
Member

Choose a reason for hiding this comment

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

I would not set it here, but just return the value and store it in the calling code.

@@ -0,0 +1,12 @@
OvhCloud Notifier
===============
Copy link
Member

Choose a reason for hiding this comment

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

Missing =

@fabpot fabpot force-pushed the feature/ovhcloudsms-notifier branch from b74f610 to 76bfb85 Compare February 11, 2020 13:51
@fabpot
Copy link
Member

fabpot commented Feb 11, 2020

Thank you @antiseptikk.

fabpot added a commit that referenced this pull request Feb 11, 2020
This PR was squashed before being merged into the 5.1-dev branch.

Discussion
----------

[Notifier] add OvhCloud bridge

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | See #33687
| License       | MIT

This would add OvhCloud sms integration for the Notifier component.
Tested with 'ovh-eu' entrypoint.

Inspiration : https://github.com/ovh/php-ovh

Commits
-------

76bfb85 [Notifier] add OvhCloud bridge
@fabpot fabpot merged commit 76bfb85 into symfony:master Feb 11, 2020
@antiseptikk antiseptikk deleted the feature/ovhcloudsms-notifier branch February 14, 2020 09:10
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.1 May 4, 2020
@fabpot fabpot mentioned this pull request May 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants