Skip to content

Commit 2642639

Browse files
committed
Fix metadata encoding of too-big notification messages
If a message body is too large, we omit it from the notification, but we were not encoding that as json and so the metadata would end up as a (bt-encoded) dict within the notification rather than a bt-encoded string containing the json. This fixes it to use the same json encoding as we use when sending a message that doesn't exceed the limit.
1 parent 856f53c commit 2642639

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

spns/notifiers/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def encrypt_notify_payload(data: dict, max_msg_size: int = 2500):
4848
metadata["B"] = True
4949
body = None
5050

51-
payload = bt_serialize([json.dumps(metadata), body] if body else [metadata])
51+
metadata_json = json.dumps(metadata)
52+
payload = bt_serialize([metadata_json, body] if body else [metadata_json])
5253
over = len(payload) % 256
5354
if over:
5455
payload += b"\0" * (256 - over)

0 commit comments

Comments
 (0)