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

[Notifier] [Expo] Throw exception on error-response from expo api#47626

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

@sdrewergutland
Copy link
Contributor

@sdrewergutlandsdrewergutland commentedSep 20, 2022
edited
Loading

QA
Branch?5.4
Bug fix?yes
New feature?no
Deprecations?no
Tickets-
LicenseMIT
Doc PR-

Throw an actualTransportExceptionin the case that an error is returned in the response from expo api.

@carsonbot
Copy link

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:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 6.2 branch.

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!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@carsonbotcarsonbot changed the title[Notifier][Expo-Notifier] Set messageId only if an id is returned in Expo API Response[Notifier] [Expo-Notifier] Set messageId only if an id is returned in Expo API ResponseSep 20, 2022
@OskarStarkOskarStark changed the title[Notifier] [Expo-Notifier] Set messageId only if an id is returned in Expo API Response[Notifier][Expo] Set messageId only if an id is returned in Expo API ResponseSep 20, 2022
@OskarStarkOskarStark changed the title[Notifier][Expo] Set messageId only if an id is returned in Expo API Response[Notifier][Expo] SetmessageId only if an id is returnedSep 20, 2022
@fabpot
Copy link
Member

Does it mean that the current way to deal with errors is wrong? Can we fix that instead?

@sdrewergutland
Copy link
ContributorAuthor

Yes, I suppose that would be another option; that would make it more consistent with how other transports handle errors that are not Connection/Authorization based. So a solution in the manner of

if (false ===isset($success['smsId'])) {
thrownewTransportException(sprintf('Unable to send the SMS: "%s" (%s).',$success['description'],$success['code']),$response);
}

But that would cause a BC break I assume since now receiving an Exception when a device is not registered is very different behaviour. But if that is acceptable I would close this PR and open one with the correct description and implementation of the solution then.

@fabpot
Copy link
Member

But IIUC, right now, the message is not sent and you don't get any error. So, that's a bug that should be fixed.

@sdrewergutlandsdrewergutlandforce-pushed theexpo-transport-message-id-optional branch from62966bb toc31dfd2CompareSeptember 22, 2022 05:04
@sdrewergutland
Copy link
ContributorAuthor

Alright, thanks for the feedback & PR is updated.

@sdrewergutlandsdrewergutland changed the title[Notifier][Expo] SetmessageId only if an id is returned[Notifier][Expo] Throw exception on error-response from expo apiSep 25, 2022

$isError ='error' ===$success['data']['status'];
if ($isError) {
thrownewTransportException(sprintf('Unable to post the Expo message: "%s" (%s)',$success['data']['message'],$success['data']['details']['error']),$response);

Choose a reason for hiding this comment

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

Would you have an example of a resulting message?
Maybe a link to the doc about this structure also?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Added a link to the API docs in the transport;

And as for an response for an error case:

{"data": {"status":"error","message":"\"ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]\" is not a registered push notification recipient","details": {"error":"DeviceNotRegistered","expoPushToken":"ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]"    }  }}

This can be reproduced with

curl -H"Content-Type: application/json" -X POST"https://exp.host/--/api/v2/push/send" -d'{  "to": "ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]",  "title":"hello",  "body": "world"}'

Any other possible error like invalid auth tokens etc. would be handled by a non 200 http status. AFAIK this is the only case that is still an error but would come back as HTTP/200

Copy link
Contributor

@OskarStarkOskarStark left a comment

Choose a reason for hiding this comment

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

Looks good to me, after my comment

@carsonbotcarsonbot changed the title[Notifier][Expo] Throw exception on error-response from expo api[Notifier] [Expo] Throw exception on error-response from expo apiSep 29, 2022
@fabpotfabpotforce-pushed theexpo-transport-message-id-optional branch from74dde0e to90638acCompareSeptember 30, 2022 08:22
@fabpot
Copy link
Member

Thank you@sdrewergutland.

@fabpotfabpot merged commitef3df52 intosymfony:5.4Sep 30, 2022
@sdrewergutlandsdrewergutland deleted the expo-transport-message-id-optional branchSeptember 30, 2022 08:45
This was referencedOct 12, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@fabpotfabpotfabpot approved these changes

@OskarStarkOskarStarkOskarStark approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

5 participants

@sdrewergutland@carsonbot@fabpot@nicolas-grekas@OskarStark

[8]ページ先頭

©2009-2025 Movatter.jp