Use walrus operator for ease of reading

This commit is contained in:
June 2023-08-19 18:35:35 -06:00 committed by GitHub
parent c9664c1ce1
commit 4baff08ce5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -95,8 +95,7 @@ class APNSProxy:
def tamper_lookup_keys(self, payload: apns.APNSPayload) -> apns.APNSPayload: def tamper_lookup_keys(self, payload: apns.APNSPayload) -> apns.APNSPayload:
if payload.id == 0xA: # Notification if payload.id == 0xA: # Notification
if payload.fields_with_id(2)[0].value == sha1(b"com.apple.madrid").digest(): # Topic if payload.fields_with_id(2)[0].value == sha1(b"com.apple.madrid").digest(): # Topic
if payload.fields_with_id(3)[0].value is not None: # Body if body := payload.fields_with_id(3)[0].value is not None:
body = payload.fields_with_id(3)[0].value
body = plistlib.loads(body) body = plistlib.loads(body)
if body['c'] == 97: # Lookup response if body['c'] == 97: # Lookup response
resp = gzip.decompress(body["b"]) # HTTP body resp = gzip.decompress(body["b"]) # HTTP body