rakanalh / django-pushy

Your push notifications handled at scale.
MIT License
168 stars 16 forks source link

Rest APIs response on non-unique key & type #37

Closed rakanalh closed 8 years ago

rakanalh commented 8 years ago

Users of Django-Pushy,

Feedback is required about this issue. Would you think it's best if django-pushy returns 201 or 200 responses on non-unique key & type combination?

The current implementation returns a 400 BAD REQUEST response with the following body:

{
    "non_field_errors": [
        "The fields key, type must make a unique set."
    ]
}

Thoughts needed on this one.

wolfhechel commented 8 years ago

No never 200 or 201 when it fails to save, an error has to be indicated when an error is present. For conflicting data though (not invalid data) I prefer using 409 CONFLICT, it's a semi-standard REST convention.

I think however a more interesting approach would be kind of a get_or_create on the token and device_type. Consider an application where a user logs out and logs in with another account, upon authentication the token registration will fail because it's associated with the first user.

Instead I'd prefer the device token being updated to the second user when he/she registers with it, but doing ONLY that has some security implications. Allowing such a method will also require a way to verify the device registering as well, to make sure it's the same device doing both requests.

rakanalh commented 8 years ago

Thank you for the input! I'll see what i will be doing about this one.