mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-26 01:45:18 +00:00
Update FavoritesPersistenceService to use Peer
This commit is contained in:
@@ -179,10 +179,10 @@ final class FavoritesPersistenceService: ObservableObject {
|
||||
|
||||
/// Resolve favorite status by short peer ID (16-hex derived from Noise pubkey)
|
||||
/// Falls back to scanning favorites and matching on derived peer ID.
|
||||
func getFavoriteStatus(forPeerID peerID: String) -> FavoriteRelationship? {
|
||||
// Quick sanity: peerID should be 16 hex chars (8 bytes)
|
||||
guard peerID.count == 16 else { return nil }
|
||||
for (pubkey, rel) in favorites where Peer(publicKey: pubkey).id == peerID {
|
||||
func getFavoriteStatus(for peer: Peer) -> FavoriteRelationship? {
|
||||
// Quick sanity: peer.id should be 16 hex chars (8 bytes)
|
||||
guard peer.isShort else { return nil }
|
||||
for (pubkey, rel) in favorites where Peer(publicKey: pubkey) == peer {
|
||||
return rel
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -94,7 +94,7 @@ final class MessageRouter {
|
||||
return true
|
||||
}
|
||||
} else if peerID.count == 16 {
|
||||
if let fav = FavoritesPersistenceService.shared.getFavoriteStatus(forPeerID: peerID),
|
||||
if let fav = FavoritesPersistenceService.shared.getFavoriteStatus(for: Peer(str: peerID)),
|
||||
fav.peerNostrPublicKey != nil {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ final class NostrTransport: Transport {
|
||||
return npub
|
||||
}
|
||||
if peerID.count == 16,
|
||||
let fav = FavoritesPersistenceService.shared.getFavoriteStatus(forPeerID: peerID),
|
||||
let fav = FavoritesPersistenceService.shared.getFavoriteStatus(for: Peer(str: peerID)),
|
||||
let npub = fav.peerNostrPublicKey {
|
||||
return npub
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user