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

Commit

Permalink
fix: ensure simplepush messages log message_id as str
Browse files Browse the repository at this point in the history
For logging consistency on the backend we should use the same type
for logging values for the same key. Simplepush was logging its
version as an int however.

Closes #925
  • Loading branch information
bbangert committed Jun 19, 2017
1 parent 2294cf7 commit dabfb6d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions autopush/tests/test_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,8 @@ def test_ack(self):
assert_called_included(self.proto.log.info,
format="Ack",
router_key="simplepush",
message_source="direct")
message_source="direct",
message_id=str(12))

def test_ack_with_bad_input(self):
self._connect()
Expand All @@ -1445,7 +1446,8 @@ def test_ack_with_webpush_direct(self):
assert_called_included(self.proto.log.info,
format="Ack",
router_key="webpush",
message_source="direct")
message_source="direct",
message_id=dummy_version)

def test_ack_with_webpush_from_storage(self):
self._connect()
Expand Down
2 changes: 1 addition & 1 deletion autopush/web/simplepush.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def put(self, subscription, version, data):
self._client_info.update(
uaid_hash=hasher(user_data.get("uaid")),
channel_id=user_data.get("chid"),
message_id=version,
message_id=str(version),
router_key=user_data["router_type"]
)
notification = Notification(
Expand Down
6 changes: 3 additions & 3 deletions autopush/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -1445,15 +1445,15 @@ def _handle_simple_ack(self, chid, version, code):
self.ps.direct_updates[chid] <= version:
del self.ps.direct_updates[chid]
self.log.info(format="Ack", router_key="simplepush",
channel_id=chid, message_id=version,
channel_id=chid, message_id=str(version),
message_source="direct",
uaid_hash=self.ps.uaid_hash,
user_agent=self.ps.user_agent, code=code,
**self.ps.raw_agent)
self.ps.stats.direct_acked += 1
return
self.log.info(format="Ack", router_key="simplepush", channel_id=chid,
message_id=version, message_source="stored",
message_id=str(version), message_source="stored",
uaid_hash=self.ps.uaid_hash,
user_agent=self.ps.user_agent, code=code,
**self.ps.raw_agent)
Expand Down Expand Up @@ -1491,7 +1491,7 @@ def process_nack(self, data):
return

self.log.info(format="Nack", uaid_hash=self.ps.uaid_hash,
user_agent=self.ps.user_agent, message_id=version,
user_agent=self.ps.user_agent, message_id=str(version),
code=code, **self.ps.raw_agent)
self.ps.stats.nacks += 1

Expand Down

0 comments on commit dabfb6d

Please sign in to comment.