Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add Notifier SentMessage#36611

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

Merged

Conversation

jeremyFreeAgent
Copy link
Contributor

@jeremyFreeAgentjeremyFreeAgent commentedApr 28, 2020
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
Deprecations?no
Tickets
LicenseMIT
Doc PRsymfony/symfony-docs#13624

Like Mailer, Notifier returns now a SentMessage that contains the messageId (returned by the provider in the response). It contains also the body of the response as array to have more info about price, number of sms sent, status and so on.

  • apply to bridges

wouterj, odolbeau, noniagriconomie, and auipga reacted with thumbs up emoji
@fabpot
Copy link
Member

Sounds good to me.@jeremyFreeAgent Can you finish the PR?

jeremyFreeAgent reacted with thumbs up emoji

@jeremyFreeAgent
Copy link
ContributorAuthor

I have setuniqid() for transports that do not give back an identifier.

@@ -75,5 +76,9 @@ protected function doSend(MessageInterface $message): void

throw new TransportException(sprintf('Unable to send the SMS: error %d: ', $response->getStatusCode()).($errors[$response->getStatusCode()] ?? ''), $response);
}

$message = new SentMessage($message, uniqid());
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 allow the id to be null instead of generating a random one.

jeremyFreeAgent reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I removed it from __construct then.

@@ -79,10 +80,18 @@ protected function doSend(MessageInterface $message): void
if (200 !== $response->getStatusCode()) {
$errorMessage = $jsonContents ? $jsonContents['results']['error'] : $response->getContent(false);

throw new TransportException(sprintf('Unable to post the Firebase message:%s.', $errorMessage), $response);
throw new TransportException(sprintf('Unable to post the Firebase message:"%s".', $errorMessage), $response);
Copy link
Member

Choose a reason for hiding this comment

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

These changes should be reverted

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Ok! (That was asked by fabbot.io)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Done!


$message = new SentMessage($message);

return $message;
Copy link
Member

Choose a reason for hiding this comment

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

You can remove the $message object and return it directly.

jeremyFreeAgent reacted with laugh emoji

$message = new SentMessage($message);
$message->setMessageId($success['messages'][0]['message-id']);
$message->setTransportResponseData($success);
Copy link
Member

Choose a reason for hiding this comment

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

Passing the returned result as is means that it is not standardized.
I would instead make it a bit more useful by defining a format with things that are common (including the transport name so that one can know how to parse the extra information) and add an entry with the original message.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Yes, you are right.

The only real common thing is the message-id. The other data parts depend on :

  • the kind of message (chat or SMS)
  • the service (some returns cost for SMS, number of SMS sent for the message)

I think we can start with:

  • original message (in the construct)
  • transport __toString() (in the construct)
  • message-id (with setter if returned)

Copy link
Member

Choose a reason for hiding this comment

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

Yes, let's not add anything "special" at first. For 5.1, let's be very generic. And I suppose that with me message-id and the transport, you have all the information you need to get more if needed.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Yes exactly. Most of the services have webhook or API to get the other information parts.

Thanks.

@jeremyFreeAgent
Copy link
ContributorAuthor

jeremyFreeAgent commentedMay 6, 2020
edited
Loading

Is it still relevant for 5.1?

@fabpot
Copy link
Member

Still relevant, but not for 5.1, I think we need more time to validate what we want.

jeremyFreeAgent reacted with thumbs up emoji

@fabpot
Copy link
Member

@jeremyFreeAgent Can you update this PR with the latest discussion from the comments?

jeremyFreeAgent reacted with thumbs up emoji

@jeremyFreeAgentjeremyFreeAgentforce-pushed thenotifier-sent-message branch 2 times, most recently fromb6bd5bf to048994cCompareJune 13, 2020 09:00
@jeremyFreeAgent
Copy link
ContributorAuthor

rebased!

5.2.0
-----

* [BC BREAK] The `TransportExceptionInterface::send()` and `AbstractTransport::doSend()` methods changed to return a `SentMessage` instance instead of `void`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
*[BC BREAK] The`TransportExceptionInterface::send()` and`AbstractTransport::doSend()` methods changed to return a`SentMessage` instance instead of`void`.
*[BC BREAK] The`TransportInterface::send()` and`AbstractTransport::doSend()` methods changed to return a`SentMessage` instance instead of`void`.

I guess that was a typo?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Thanks@apfelbox ! Sorry I pushed the fix because in the GitHub iOS app I didn't saw that you use the suggestion feature.

Copy link
Contributor

Choose a reason for hiding this comment

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

haha thx, don't worry 😄

Copy link
Member

@fabpotfabpot left a comment

Choose a reason for hiding this comment

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

LGTM, minor comments to be fixed before merge. Thank you.

*
* @experimental in 5.2
*/
class SentMessage
Copy link
Member

Choose a reason for hiding this comment

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

Should befinal.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

My bad 🤦
Fixed.

{
private $original;
private $transport;
private $messageId = null;
Copy link
Member

Choose a reason for hiding this comment

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

= null is the default, so it can be removed

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Fixed

@@ -71,8 +69,8 @@ public function send(MessageInterface $message): void

if (!$this->transports[$transport]->supports($message)) {
throw new LogicException(sprintf('The "%s" transport does not support the given message.', $transport));
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Looks like it's a wrong change here.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Yes this is strange. It is a tab (I may have changed the file with another editor). I fix it. Good catch!

@fabpot
Copy link
Member

@jeremyFreeAgent Next step would be to fix the tests :)

jeremyFreeAgent reacted with laugh emoji

@jeremyFreeAgent
Copy link
ContributorAuthor

Sorry I was working on something else at the same time.:trollface:

@fabpot
Copy link
Member

@jeremyFreeAgent Do you have time to have a look for the failing tests?

@jeremyFreeAgent
Copy link
ContributorAuthor

The tests are failing because the bridges require the 5.2 version of notifier which is not yet merged. What is the solution to make them pass?

@fabpot
Copy link
Member

The deps=low should pass. It looks like you forgot to update the composer.json file for FreeMobile.

@jeremyFreeAgent
Copy link
ContributorAuthor

OMG thanks@fabpot♥️

@fabpotfabpotforce-pushed thenotifier-sent-message branch from616a60f to5a6f053CompareJune 23, 2020 07:04
@fabpot
Copy link
Member

Thank you@jeremyFreeAgent.

@fabpotfabpot merged commitce8f8a5 intosymfony:masterJun 23, 2020
@mbabker
Copy link
Contributor

Can the Messenger handler be made to return theSentMessage, similar to the Mailer's handler (#36424)?

@fabpot
Copy link
Member

@mbabker Sure, see#37403

fabpot added a commit that referenced this pull requestJun 24, 2020
…e handler (fabpot)This PR was merged into the 5.2-dev branch.Discussion----------[Notifier] Return SentMessage from the Notifier message handler| Q             | A| ------------- | ---| Branch?       | master <!-- see below -->| Bug fix?      | no| New feature?  | yes <!-- please update src/**/CHANGELOG.md files -->| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tickets       | see#36611 (comment) <!-- prefix each issue number with "Fix #", if any -->| License       | MIT| Doc PR        |Commits-------5855d11 [Notifier] Return SentMessage from the Notifier message handler
@mbabker
Copy link
Contributor

Thank you!

nicolas-grekas added a commit that referenced this pull requestJun 28, 2020
… (derrabus)This PR was merged into the 5.1 branch.Discussion----------[Notifier] Notifier 5.2 is incompatible with 5.1 bridges| Q             | A| ------------- | ---| Branch?       | 5.1| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       | N/A| License       | MIT| Doc PR        | N/A#36611 introduced a breaking change that made the Notifier 5.2 incompatible with all Notifier bridges 5.0-5.1. Because of this, the tests are currently failing on Travis. This PR attempts to fix this.Commits-------1b6bbc2 [Notifier] Notifier 5.2 is incompatible with 5.1 bridges.
fabpot added a commit that referenced this pull requestAug 6, 2020
This PR was merged into the 5.2-dev branch.Discussion----------[Notifier] Fix SentMessage implementation| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | yes| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tickets       | n/a <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->| License       | MIT| Doc PR        | n/a#36611 broke the Notifier when used with Messenger./cc@jeremyFreeAgentCommits-------92c28de [Notifier] Fix SentMessage implementation
@nicolas-grekasnicolas-grekas modified the milestones:next,5.2Oct 5, 2020
@fabpotfabpot mentioned this pull requestOct 5, 2020
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@fabpotfabpotfabpot approved these changes

@KocKocKoc left review comments

@apfelboxapfelboxapfelbox left review comments

Assignees
No one assigned
Projects
None yet
Milestone
5.2
Development

Successfully merging this pull request may close these issues.

7 participants
@jeremyFreeAgent@fabpot@mbabker@Koc@apfelbox@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp