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

Commit

Permalink
feature: allow channels to register with public key
Browse files Browse the repository at this point in the history
Channels can include a public key when registering a new subscription
channel. This public key should match the public key used to send
subscription updates later.

NOTE: this patch changes the format of the endpoint URLs, & the content
of the endpoint URL token. This change also requires that ChannelIDs be
normalized to dashed format, (e.g. a lower case, dash delimited string
"deadbeef-0000-0000-deca-fbad11112222") This is the default mechanism
used by Firefox for UUID generation. It is STRONGLY urged that clients
normalize UUIDs used for ChannelIDs and User Agent IDs. While this
should not break existing clients, additional testing may be required.

Closes: #326
  • Loading branch information
jrconlin committed Feb 29, 2016
1 parent af88ab9 commit c75ca15
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
7 changes: 6 additions & 1 deletion autopush/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ def stdout(message):
else:
msg["Severity"] = 5

for key in ["Type", "Severity", "type", "severity"]:
# 'message_type' is used by twisted logging. Preserve this to the
# 'Type' tag.
if "message_type" in message:
msg["Type"] = message.pop("message_type")

for key in ["Severity", "type", "severity"]:
if key in message:
msg[key.title()] = message.pop(key)

Expand Down
6 changes: 3 additions & 3 deletions autopush/tests/test_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ def check_hello_result(msg):
args, kwargs = mock_log.msg.call_args
eq_(args[0], "Ack")
eq_(kwargs["router_key"], "simplepush")
eq_(kwargs["message_type"], "direct")
eq_(kwargs["message_source"], "direct")

d.callback(True)

Expand Down Expand Up @@ -1153,7 +1153,7 @@ def test_ack_with_webpush_direct(self, mock_log):
args, kwargs = mock_log.msg.call_args
eq_(args[0], "Ack")
eq_(kwargs["router_key"], "webpush")
eq_(kwargs["message_type"], "direct")
eq_(kwargs["message_source"], "direct")

@patch('autopush.websocket.log', spec=True)
def test_ack_with_webpush_from_storage(self, mock_log):
Expand All @@ -1178,7 +1178,7 @@ def test_ack_with_webpush_from_storage(self, mock_log):
args, kwargs = mock_log.msg.call_args
eq_(args[0], "Ack")
eq_(kwargs["router_key"], "webpush")
eq_(kwargs["message_type"], "stored")
eq_(kwargs["message_source"], "stored")

def test_ack_remove(self):
self._connect()
Expand Down
8 changes: 4 additions & 4 deletions autopush/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ def ver_filter(update):
msg = found[0]
size = len(msg.data) if msg.data else 0
log.msg("Ack", router_key="webpush", channelID=chid,
message_id=version, message_type="direct",
message_id=version, message_source="direct",
message_size=size, uaid_hash=self.ps.uaid_hash,
user_agent=self.ps.user_agent)
self.ps.direct_updates[chid].remove(msg)
Expand All @@ -1104,7 +1104,7 @@ def ver_filter(update):
msg = found[0]
size = len(msg.data) if msg.data else 0
log.msg("Ack", router_key="webpush", channelID=chid,
message_id=version, message_type="stored",
message_id=version, message_source="stored",
message_size=size, uaid_hash=self.ps.uaid_hash,
user_agent=self.ps.user_agent)
d = self.force_retry(self.ps.message.delete_message,
Expand Down Expand Up @@ -1137,12 +1137,12 @@ def _handle_simple_ack(self, chid, version):
self.ps.direct_updates[chid] <= version:
del self.ps.direct_updates[chid]
log.msg("Ack", router_key="simplepush", channelID=chid,
message_id=version, message_type="direct",
message_id=version, message_source="direct",
uaid_hash=self.ps.uaid_hash,
user_agent=self.ps.user_agent)
return
log.msg("Ack", router_key="simplepush", channelID=chid,
message_id=version, message_type="stored",
message_id=version, message_source="stored",
uaid_hash=self.ps.uaid_hash,
user_agent=self.ps.user_agent)
if chid in self.ps.updates_sent and \
Expand Down

0 comments on commit c75ca15

Please sign in to comment.