fix(mobile): accept UUIDv5 push channel targets

Signed-off-by: Tom Brow <tomb@block.xyz>
This commit is contained in:
Tom Brow
2026-08-20 13:48:18 -07:00
parent d69b89c43c
commit 6c04960474
4 changed files with 83 additions and 5 deletions

View File

@@ -56,7 +56,6 @@ public struct BuzzPushNavigationTarget: Codable, Equatable, Sendable {
let bytes = Array(value.utf8)
guard bytes.count == 36,
bytes[8] == 45, bytes[13] == 45, bytes[18] == 45, bytes[23] == 45,
bytes[14] == 52,
[56, 57, 97, 98].contains(bytes[19])
else { return false }
return bytes.enumerated().allSatisfy { index, byte in

View File

@@ -3,7 +3,7 @@ import Testing
@testable import BuzzPushKit
@Test func `Round-trip navigation target through notification user info`() {
@Test func `Round-trip UUIDv4 navigation target through notification user info`() {
let target = BuzzPushNavigationTarget(
eventID: String(repeating: "A", count: 64),
communityID: "community-id",
@@ -19,7 +19,22 @@ import Testing
#expect(target.channelID == "123e4567-e89b-42d3-a456-426614174000")
}
@Test func `Reject incomplete navigation target`() {
@Test func `Decode UUIDv5 navigation target`() {
let target = BuzzPushNavigationTarget(
eventID: String(repeating: "B", count: 64),
communityID: "community-id",
channelID: "9A1657AC-F7AA-5DB0-B632-D8BBEB6DFB50"
)
#expect(
BuzzPushNavigationTarget.decodeIfPresent(
from: [BuzzPushNavigationTarget.userInfoKey: target.userInfoValue]
) == target
)
#expect(target.channelID == "9a1657ac-f7aa-5db0-b632-d8bbeb6dfb50")
}
@Test func `Reject incomplete or malformed navigation target`() {
#expect(
BuzzPushNavigationTarget.decodeIfPresent(
from: [
@@ -42,6 +57,18 @@ import Testing
]
) == nil
)
#expect(
BuzzPushNavigationTarget.decodeIfPresent(
from: [
BuzzPushNavigationTarget.userInfoKey: [
"event_id": String(repeating: "a", count: 64),
"community_id": "community-id",
"channel_id": "9a1657ac-f7aa-5db0-7632-d8bbeb6dfb50",
]
]
) == nil
)
}
@Test func `Buffer preserves cold-start target until consumed`() {