Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
fix: simplify Message validation by passing WebPushNotification
Browse files Browse the repository at this point in the history
issue #691
  • Loading branch information
jrconlin committed Oct 13, 2016
1 parent 777dff4 commit 0a3d94d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
2 changes: 1 addition & 1 deletion autopush/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __init__(self,
enable_cors=False,
hello_timeout=0,
bear_hash_key=None,
preflight_uaid="deadbeef00000000deadbeef000000000",
preflight_uaid="deadbeef00000000deadbeef00000000",
ami_id=None,
client_certs=None,
):
Expand Down
18 changes: 3 additions & 15 deletions autopush/web/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@


class MessageSchema(Schema):
uaid = fields.UUID()
channel_id = fields.UUID()
topic = fields.Str(allow_none=True)
message_id = fields.Str()
notification = fields.Raw()

@pre_load
def extract_data(self, req):
Expand All @@ -32,10 +29,7 @@ def extract_data(self, req):
except (InvalidToken, InvalidTokenException):
raise InvalidRequest("Invalid message ID",
status_code=400)
return dict(uaid=notif.uaid,
channel_id=notif.channel_id,
topic=notif.topic,
message_id=message_id)
return dict(notification=notif)


class MessageHandler(BaseWebHandler):
Expand All @@ -52,13 +46,7 @@ def delete(self, *args, **kwargs):
"""
notif = WebPushNotification(
uaid=self.valid_input['uaid'],
channel_id=self.valid_input['channel_id'],
data=None,
ttl=None,
topic=self.valid_input['topic'],
message_id=self.valid_input['message_id'])
notif = self.valid_input['notification']
d = deferToThread(self.ap_settings.message.delete_message,
notif)
d.addCallback(self._delete_completed)
Expand Down

0 comments on commit 0a3d94d

Please sign in to comment.