From 4d60b071629155649c5f4dd5e13da8659e12d1d1 Mon Sep 17 00:00:00 2001 From: jr conlin Date: Fri, 5 May 2017 09:56:51 -0700 Subject: [PATCH] feat: temporarily allow aps data via registration message closes #887 --- autopush/router/apnsrouter.py | 2 +- autopush/tests/test_router.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/autopush/router/apnsrouter.py b/autopush/router/apnsrouter.py index ba3d09d6..3ec3e00c 100644 --- a/autopush/router/apnsrouter.py +++ b/autopush/router/apnsrouter.py @@ -133,7 +133,7 @@ def _route(self, notification, router_data): payload["cryptokey"] = notification.headers["crypto_key"] elif "encryption_key" in notification.headers: payload["enckey"] = notification.headers["encryption_key"] - payload['aps'] = {"content-available": 1} + payload['aps'] = router_data.get('aps', {"content-available": 1}) apns_id = str(uuid.uuid4()).lower() try: apns_client.send(router_token=router_token, payload=payload, diff --git a/autopush/tests/test_router.py b/autopush/tests/test_router.py index 315c4a1f..e7b13680 100644 --- a/autopush/tests/test_router.py +++ b/autopush/tests/test_router.py @@ -133,6 +133,14 @@ def test_register(self): self.router.register("uaid", router_data=router_data, app_id="firefox") eq_(router_data, {"rel_channel": "firefox", "token": "connect_data"}) + def test_extended_register(self): + router_data = {"token": "connect_data", + "aps": {"foo": "bar", + "gorp": "baz"}} + self.router.register("uaid", router_data=router_data, app_id="firefox") + eq_(router_data, {"rel_channel": "firefox", "token": "connect_data", + "aps": {"foo": "bar", "gorp": "baz"}}) + def test_register_bad(self): with assert_raises(RouterException): self.router.register("uaid", router_data={}, app_id="firefox")