Skip to content
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

Do not retry and log warning when push notification was not authorised #18562

Merged
merged 1 commit into from
Aug 22, 2020

Conversation

rodrigok
Copy link
Member

Proposed changes

Issue(s)

How to test or reproduce

Screenshots

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves a current function)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Hotfix (a major bugfix that has to be merged asap)
  • Documentation Update (if none of the other choices apply)

Changelog

Further comments

@rodrigok rodrigok added this to the 3.6.0 milestone Aug 14, 2020
@rodrigok rodrigok requested a review from sampaiodiego August 14, 2020 15:30
@@ -128,6 +128,11 @@ export class PushClass {
return;
}

if (response?.statusCode === 401) {
Copy link
Member

Choose a reason for hiding this comment

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

I guess this is one of the bad habits that optional chaining introduces, with this change the code is now checking twice if response is defined.. IMO we should avoid this and in this case we could use a single if to check if response.statusCode exists:

			if (response?.statusCode) {
				if (response.statusCode === 406) {
					logger.info('removing push token', token);
					appTokensCollection.remove({
						$or: [{
							'token.apn': token,
						}, {
							'token.gcm': token,
						}],
					});
					return;
				}

				if (response.statusCode === 401) {
					logger.warn('Error sending push to gateway (not authorized)', response);
					return;
				}
			}
...

Copy link
Member

Choose a reason for hiding this comment

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

I agree, sometimes this feature leads us not to question if some structures are correct, for example here, why would the respose be empty ?, maybe the error of this being tested first ... I saw it a lot on the coffescript code and I dont like it... try to write using ifs or ternaries before, and maybe these questions would appear 🤔

@sampaiodiego sampaiodiego merged commit b913621 into develop Aug 22, 2020
@sampaiodiego sampaiodiego deleted the push-retry-401 branch August 22, 2020 00:55
@sampaiodiego sampaiodiego mentioned this pull request Aug 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants