Automattic / php-push

Work-in-progress on Push Notifications v2
5 stars 1 forks source link

Add support for userdata #47

Closed jkmassel closed 4 years ago

jkmassel commented 4 years ago

Adds support for passing a $userdata object into an APNSRequest, which the network layer will ensure is passed to the corresponding APNSResponse object. By default, the object will always contain the apns_uuid and apns_token fields, which are useful for associating the response with a given notification or device token. If instead of a UUID the developer is using an integer-based primary key, they can pass their own key in $userdata that allows for later retrieval.

To Test:

codeclimate[bot] commented 4 years ago

Code Climate has analyzed commit 8fc0bc11 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 99.0% (0.0% change).

View more on Code Climate.

jkmassel commented 4 years ago

I'm curious to know why you chose to use an object instead of an array used as a dictionary for the user data.

This is a good question – originally I had it as an object because it used serialize, which meant that when the object comes out it would have the same type as when it went in. However, serialize can have security implications – while it mostly doesn't matter here (the serialization isn't persisted anywhere, so object substitution attacks are basically impossible) I changed it to just marshal it to JSON and back instead, but I didn't update the types.

I agree with you, so I've changed it back to an array. I don't think it required another whole review, so I'll merge it at this point – thanks for bringing this up!

mokagio commented 4 years ago

Thank you for the explanation 👍 .