mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Update
This commit is contained in:
parent
22e58eb5e4
commit
911ebd07ab
50 changed files with 5096 additions and 5079 deletions
|
|
@ -96,16 +96,23 @@ private func matchPhoneNumbers(_ lhs: String, _ rhs: String) -> Bool {
|
|||
func matchingCloudContacts(postbox: Postbox, contacts: [MatchingDeviceContact]) -> Signal<[(String, TelegramUser)], NoError> {
|
||||
return postbox.transaction { transaction -> [(String, TelegramUser)] in
|
||||
var result: [(String, TelegramUser)] = []
|
||||
var matchingIds = Set<EnginePeer.Id>()
|
||||
outer: for peerId in transaction.getContactPeerIds() {
|
||||
if let peer = transaction.getPeer(peerId) as? TelegramUser {
|
||||
for contact in contacts {
|
||||
if let contactPeerId = contact.peerId, contactPeerId == peerId {
|
||||
result.append((contact.stableId, peer))
|
||||
if !matchingIds.contains(peer.id) {
|
||||
matchingIds.insert(peer.id)
|
||||
result.append((contact.stableId, peer))
|
||||
}
|
||||
continue outer
|
||||
} else if let peerPhoneNumber = peer.phone {
|
||||
for contactPhoneNumber in contact.phoneNumbers {
|
||||
if matchPhoneNumbers(contactPhoneNumber, peerPhoneNumber) {
|
||||
result.append((contact.stableId, peer))
|
||||
if !matchingIds.contains(peer.id) {
|
||||
matchingIds.insert(peer.id)
|
||||
result.append((contact.stableId, peer))
|
||||
}
|
||||
continue outer
|
||||
}
|
||||
}
|
||||
|
|
@ -113,6 +120,15 @@ func matchingCloudContacts(postbox: Postbox, contacts: [MatchingDeviceContact])
|
|||
}
|
||||
}
|
||||
}
|
||||
for contact in contacts {
|
||||
if let peerId = contact.peerId, let peer = transaction.getPeer(peerId) as? TelegramUser {
|
||||
if !matchingIds.contains(peer.id) {
|
||||
matchingIds.insert(peer.id)
|
||||
result.append((contact.stableId, peer))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue