Skip to content

Commit b8a0eb6

Browse files
committed
fix(push-gateway): request default notification sound
Signed-off-by: Tom Brow <[email protected]>
1 parent 6f67dcd commit b8a0eb6

5 files changed

Lines changed: 21 additions & 4 deletions

File tree

‎crates/buzz-push-gateway/src/apns.rs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,18 @@ mod tests {
239239
StatusCode::OK
240240
}
241241

242+
#[test]
243+
fn apns_payload_matches_normative_contract_and_models() {
244+
let body = std::str::from_utf8(APNS_RECONNECT_PAYLOAD).unwrap();
245+
for contract in [
246+
include_str!("../../../docs/nips/NIP-PL.md"),
247+
include_str!("../../../docs/formal/nip-pl/delivery.py"),
248+
include_str!("../../../docs/formal/nip-pl/fixed_payload.py"),
249+
] {
250+
assert!(contract.contains(body), "APNs fixed-body contract drift");
251+
}
252+
}
253+
242254
#[tokio::test]
243255
async fn certificate_transport_sends_no_bearer_and_exact_body_for_every_attempt() {
244256
let requests = Arc::new(Mutex::new(Vec::new()));
@@ -274,6 +286,11 @@ mod tests {
274286
}
275287
let captured = requests.lock().unwrap();
276288
assert_eq!(captured.len(), 2);
289+
for request in captured.iter() {
290+
let payload: serde_json::Value = serde_json::from_slice(&request.body).unwrap();
291+
assert_eq!(payload["aps"]["sound"], "default");
292+
assert_eq!(payload["aps"]["mutable-content"], 1);
293+
}
277294
assert!(captured
278295
.iter()
279296
.all(|request| request.body.as_slice() == APNS_RECONNECT_PAYLOAD));

‎crates/buzz-push-gateway/src/model.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub const MAX_ENROLL_REQUEST_BYTES: usize =
1313
pub const MAX_GRANT_BYTES: usize = 4096;
1414
pub const MAX_ENDPOINT_HEX_BYTES: usize = 512;
1515
pub const APNS_RECONNECT_PAYLOAD: &[u8] =
16-
br#"{"aps":{"alert":{"body":"Reconnect to your relay now"},"mutable-content":1}}"#;
16+
br#"{"aps":{"alert":{"body":"Reconnect to your relay now"},"sound":"default","mutable-content":1}}"#;
1717
pub const WIRE_VERSION: u8 = 1;
1818

1919
/// Relay request. It deliberately has no application-payload field:

‎docs/formal/nip-pl/delivery.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88
from itertools import permutations, product
99

10-
FIXED_BODY = b'{"aps":{"alert":{"body":"Reconnect to your relay now"},"mutable-content":1}}'
10+
FIXED_BODY = b'{"aps":{"alert":{"body":"Reconnect to your relay now"},"sound":"default","mutable-content":1}}'
1111

1212
class Gateway:
1313
def __init__(self):

‎docs/formal/nip-pl/fixed_payload.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66
from itertools import product
77

8-
C = b'{"aps":{"alert":{"body":"Reconnect to your relay now"},"mutable-content":1}}'
8+
C = b'{"aps":{"alert":{"body":"Reconnect to your relay now"},"sound":"default","mutable-content":1}}'
99
DOMAINS = [
1010
(b"request-a", b"request-b"), # exact signed body
1111
(b"auth-a", b"auth-b"), # NIP-98 event/header

‎docs/nips/NIP-PL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ Common invariant, all transports: the application payload is a transport-owned r
224224

225225
### APNs
226226

227-
The APNs application body is the exact UTF-8 byte constant `{"aps":{"alert":{"body":"Reconnect to your relay now"},"mutable-content":1}}`. It has no custom member, event identifier, unread count, or relay-supplied byte. The constant mutable-content flag lets the Buzz Notification Service Extension compute a local badge and, when separately authorized data is available, replace the generic text; the gateway does not carry that data. The gateway MUST send that exact body for every accepted APNs attempt; it MUST NOT serialize any relay request, endpoint grant, provider response, or generic JSON value into the body. `apns-topic`, environment, credentials, push type `alert`, and priority `10` come only from gateway configuration. `apns-id` is a canonical UUID and `apns-expiration` is bounded by the endpoint capability and a gateway-local ceiling.
227+
The APNs application body is the exact UTF-8 byte constant `{"aps":{"alert":{"body":"Reconnect to your relay now"},"sound":"default","mutable-content":1}}`. It has no custom member, event identifier, unread count, or relay-supplied byte. The constant sound requests the system default alert sound, subject to notification authorization and user sound, Focus, and haptics settings. It does not select critical alerts or guarantee vibration. Sound is present even when the Notification Service Extension does not run. The constant mutable-content flag lets the Buzz Notification Service Extension compute a local badge and, when separately authorized data is available, replace the generic text; the gateway does not carry that data. The gateway MUST send that exact body for every accepted APNs attempt; it MUST NOT serialize any relay request, endpoint grant, provider response, or generic JSON value into the body. `apns-topic`, environment, credentials, push type `alert`, and priority `10` come only from gateway configuration. `apns-id` is a canonical UUID and `apns-expiration` is bounded by the endpoint capability and a gateway-local ceiling.
228228

229229
### FCM
230230

0 commit comments

Comments
 (0)