Skip to content

Commit 6d5d7c2

Browse files
committed
"broken nobody hack" to fix APNS Session client compat
1 parent 1517c5d commit 6d5d7c2

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

spns/notifiers/apns.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ async def apns_notify(self, request: aioapns.NotificationRequest):
165165
def push_notification(self, msg: Message):
166166
data = oxenc.bt_deserialize(msg.data()[0])
167167

168-
enc_payload = encrypt_notify_payload(data, max_msg_size=MAX_MSG_SIZE)
168+
enc_payload = encrypt_notify_payload(data, max_msg_size=MAX_MSG_SIZE,
169+
broken_nobody_hack=True)
169170

170171
device_token = data[b"&"].decode() # unique service id, as we returned from validate
171172

spns/notifiers/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def encrypt_payload(msg: bytes, enc_key: bytes):
3636
return nonce + ciphertext
3737

3838

39-
def encrypt_notify_payload(data: dict, max_msg_size: int = 2500):
39+
def encrypt_notify_payload(data: dict, max_msg_size: int = 2500, broken_nobody_hack: bool = False):
4040
enc_key = data[b"^"]
4141

4242
metadata = {"@": data[b"@"].hex(), "#": data[b"#"].decode(), "n": data[b"n"], "t": data[b"t"], "z": data[b"z"]}
@@ -49,7 +49,7 @@ def encrypt_notify_payload(data: dict, max_msg_size: int = 2500):
4949
body = None
5050

5151
metadata_json = json.dumps(metadata)
52-
payload = bt_serialize([metadata_json, body] if body else [metadata_json])
52+
payload = bt_serialize([metadata_json, body] if body else [metadata if broken_nobody_hack else metadata_json])
5353
over = len(payload) % 256
5454
if over:
5555
payload += b"\0" * (256 - over)

0 commit comments

Comments
 (0)