PeerID 31/n: Remove String interop to be explicit (#840)

* PeerID 28/n: `ChatViewModel.getShortIDForNoiseKey`

* PeerID 29/n: `BLEService` + remove dupe funcs from #823

* `handleFileTransfer` to use PeerID

* `sendMessage` and `sendPrivateMessage`

* PeerID 30/n: Update some leftovers

* `lowercased()` inside PeerID for normalization

* PeerID 31/n: Remove String interop to be explicit

* MockBLEService: Remove direct target delivery

This causes a delivery even if the sender and receiver are not connected

---------

Co-authored-by: jack <jackjackbits@users.noreply.github.com>
This commit is contained in:
Islam
2025-10-19 20:50:44 +02:00
committed by GitHub
co-authored by jack
parent 0776c9813c
commit b839ce5f6c
8 changed files with 34 additions and 80 deletions
+3 -3
View File
@@ -261,7 +261,7 @@ final class ChatViewModel: ObservableObject, BitchatDelegate {
nickname = trimmed
}
// Update mesh service nickname if it's initialized
if meshService.myPeerID != "" {
if !meshService.myPeerID.isEmpty {
meshService.setNickname(nickname)
}
}
@@ -4103,7 +4103,7 @@ final class ChatViewModel: ObservableObject, BitchatDelegate {
if let spid = message.senderPeerID {
if case .location(let ch) = activeChannel, spid.id.hasPrefix("nostr:") {
if let myGeo = try? idBridge.deriveIdentity(forGeohash: ch.geohash) {
return spid == "nostr:\(myGeo.publicKeyHex.prefix(TransportConfig.nostrShortKeyDisplayLength))"
return spid == PeerID(nostr: myGeo.publicKeyHex)
}
}
return spid == meshService.myPeerID
@@ -5623,7 +5623,7 @@ final class ChatViewModel: ObservableObject, BitchatDelegate {
}
// Validate recipient
if let rid = packet.recipientID, rid.hexEncodedString() != meshService.myPeerID {
if PeerID(hexData: packet.recipientID) != meshService.myPeerID {
return
}