Skip to content

Change pushHash with stringified data #2397

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 4 commits into from
Aug 9, 2016

Conversation

alenoir
Copy link
Contributor

@alenoir alenoir commented Jul 26, 2016

Notification with loc-key and loc-args crash because data.alert is not a string.

e.g.

alert: {
  'loc-key': '....',
  'loc-args': '...',
}

@codecov-io
Copy link

codecov-io commented Jul 26, 2016

Current coverage is 92.47% (diff: 100%)

Merging #2397 into master will increase coverage by 0.63%

@@             master      #2397   diff @@
==========================================
  Files            95         93     -2   
  Lines         10708      10622    -86   
  Methods        1309       1311     +2   
  Messages          0          0          
  Branches       1741       1727    -14   
==========================================
- Hits           9835       9823    -12   
+ Misses          873        799    -74   
  Partials          0          0          

Powered by Codecov. Last update 831b29b...7ca6190

@ghost
Copy link

ghost commented Jul 26, 2016

@alenoir updated the pull request.

1 similar comment
@ghost
Copy link

ghost commented Jul 26, 2016

@alenoir updated the pull request.

@ghost
Copy link

ghost commented Jul 26, 2016

@alenoir updated the pull request.

@ghost
Copy link

ghost commented Jul 27, 2016

@alenoir updated the pull request.

@alenoir
Copy link
Contributor Author

alenoir commented Jul 27, 2016

as we said in 676d2e2 i replace payloadstring by stringify data.alert for localization format

@protspace
Copy link

the same for me.
info: warning: error while sending push TypeError: Not a string or buffer
and then

Error: {"code":141,"message":{"code":107,"message":"Received an error with invalid JSON from Parse: <html>\r\n<head><title>502 Bad Gateway</title></head>\r\n<body bgcolor=\"white\">\r\n<center><h1>502 Bad Gateway</h1></center>\r\n<hr><center>nginx/1.6.2</center>\r\n</body>\r\n</html>\r\n"}}

@0xthk
Copy link

0xthk commented Aug 6, 2016

This should be merged soon... All iOS localized push will fail on version 2.2.17!

@@ -36,7 +36,7 @@ export default function pushStatusHandler(config) {
expiry: body.expiration_time,
status: "pending",
numSent: 0,
pushHash: md5Hash(data.alert || ''),
pushHash: md5Hash(JSON.stringify(data.alert) || ''),
Copy link
Contributor

Choose a reason for hiding this comment

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

in the case alert is a string, that will wrap the string into another string, including the quotes...
This should be updated to:

let pushHash;
if (typeof data.alert === 'string') {
  pushHash = md5Hash(data.alert);
} else if (typeof data.alert === 'object') {
  pushHash = md5Hash(JSON.stringify(data.alert));
} else {
   pushHash = "d41d8cd98f00b204e9800998ecf8427e"; // empty string hash
}

@flovilmart
Copy link
Contributor

thanks @alenoir. Tests would have been nice too.

@facebook-github-bot
Copy link

@alenoir updated the pull request.

1 similar comment
@ghost
Copy link

ghost commented Aug 9, 2016

@alenoir updated the pull request.

@flovilmart
Copy link
Contributor

Thanks @alenoir, merging after travis

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.

6 participants