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

Commit

Permalink
fix: use hex formatted ChannelID strings for bridged connections (#709)
Browse files Browse the repository at this point in the history
closes #708
  • Loading branch information
jrconlin authored and bbangert committed Oct 14, 2016
1 parent e564a97 commit 8aa1a7e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
4 changes: 3 additions & 1 deletion autopush/router/apnsrouter.py
Expand Up @@ -109,8 +109,10 @@ def _route(self, notification, router_data):
rel_channel = router_data["rel_channel"]
config = self._config[rel_channel]
apns_client = self.apns[rel_channel]
# chid MUST MATCH THE CHANNELID GENERATED BY THE REGISTRATION SERVICE
# Currently this value is in hex form.
payload = {
"chid": str(notification.channel_id),
"chid": notification.channel_id.hex,
"ver": notification.version,
}
if notification.data:
Expand Down
4 changes: 3 additions & 1 deletion autopush/router/fcm.py
Expand Up @@ -151,7 +151,9 @@ def route_notification(self, notification, uaid_data):

def _route(self, notification, router_data):
"""Blocking FCM call to route the notification"""
data = {"chid": str(notification.channel_id)}
# THIS MUST MATCH THE CHANNELID GENERATED BY THE REGISTRATION SERVICE
# Currently this value is in hex form.
data = {"chid": notification.channel_id.hex}
if not router_data.get("token"):
raise self._error("No registration token found. "
"Rejecting message.",
Expand Down
4 changes: 3 additions & 1 deletion autopush/router/gcm.py
Expand Up @@ -75,7 +75,9 @@ def route_notification(self, notification, uaid_data):
def _route(self, notification, uaid_data):
"""Blocking GCM call to route the notification"""
router_data = uaid_data["router_data"]
data = {"chid": str(notification.channel_id)}
# THIS MUST MATCH THE CHANNELID GENERATED BY THE REGISTRATION SERVICE
# Currently this value is in hex form.
data = {"chid": notification.channel_id.hex}
# Payload data is optional. The endpoint handler validates that the
# correct encryption headers are included with the data.
if notification.data:
Expand Down
4 changes: 3 additions & 1 deletion autopush/tests/test_router.py
Expand Up @@ -65,7 +65,9 @@ def init(self, settings, router_conf):
assert_raises(NotImplementedError, ir.amend_msg, {})


dummy_chid = str(uuid.uuid4())
# FOR LEGACY REASONS, CHANNELID MUST BE IN HEX FORMAT FOR BRIDGE PUBLICATION
# AND REGISTRATION
dummy_chid = uuid.uuid4().hex
dummy_uaid = str(uuid.uuid4())


Expand Down
2 changes: 2 additions & 0 deletions autopush/web/registration.py
Expand Up @@ -139,6 +139,8 @@ def post(self, *args, **kwargs):
params = self.valid_input['params']
# If the client didn't provide a CHID, make one up.
# Note, valid_input may explicitly set "chid" to None
# THIS VALUE MUST MATCH WHAT'S SPECIFIED IN THE BRIDGE CONNECTIONS.
# currently hex formatted.
self.chid = params["channelID"] = (self.valid_input["chid"] or
uuid.uuid4().hex)
self.ap_settings.metrics.increment("updates.client.register",
Expand Down

0 comments on commit 8aa1a7e

Please sign in to comment.