diff --git a/Linphone/Contacts/ContactsManager.swift b/Linphone/Contacts/ContactsManager.swift index 73db13146..462621c77 100644 --- a/Linphone/Contacts/ContactsManager.swift +++ b/Linphone/Contacts/ContactsManager.swift @@ -422,21 +422,59 @@ final class ContactsManager: ObservableObject { let sipUri = clonedAddress.asStringUriOnly() var friend: Friend? + let core = CoreContext.shared.mCore + + let normalizedIncoming = core?.defaultAccount?.normalizePhoneNumber(username: address.username ?? "") if let friendList = self.friendList { - friend = friendList.friends.first(where: { $0.addresses.contains(where: { $0.asStringUriOnly() == sipUri }) || $0.phoneNumbers.contains(where: { $0 == address.username }) }) + friend = friendList.friends.first(where: { + $0.addresses.contains(where: { $0.asStringUriOnly() == sipUri }) || + ( + normalizedIncoming != nil && + $0.phoneNumbers.contains(where: { + core?.defaultAccount?.normalizePhoneNumber(username: $0) == normalizedIncoming + }) + ) + }) } if friend == nil, let linphoneFriendList = self.linphoneFriendList { - friend = linphoneFriendList.friends.first(where: { $0.addresses.contains(where: { $0.asStringUriOnly() == sipUri }) || $0.phoneNumbers.contains(where: { $0 == address.username }) }) - } - if friend == nil, let tempRemoteFriendList = self.tempRemoteFriendList { - friend = tempRemoteFriendList.friends.first(where: { $0.addresses.contains(where: { $0.asStringUriOnly() == sipUri }) || $0.phoneNumbers.contains(where: { $0 == address.username }) }) - } + friend = linphoneFriendList.friends.first(where: { + $0.addresses.contains(where: { $0.asStringUriOnly() == sipUri }) || + ( + normalizedIncoming != nil && + $0.phoneNumbers.contains(where: { + core?.defaultAccount?.normalizePhoneNumber(username: $0) == normalizedIncoming + }) + ) + }) + } - CoreContext.shared.mCore.friendsLists.forEach { friendList in - if friendList.type == .CardDAV { - friend = friendList.friends.first(where: { $0.addresses.contains(where: { $0.asStringUriOnly() == sipUri }) || $0.phoneNumbers.contains(where: { $0 == address.username }) }) + if friend == nil, let tempRemoteFriendList = self.tempRemoteFriendList { + friend = tempRemoteFriendList.friends.first(where: { + $0.addresses.contains(where: { $0.asStringUriOnly() == sipUri }) || + ( + normalizedIncoming != nil && + $0.phoneNumbers.contains(where: { + core?.defaultAccount?.normalizePhoneNumber(username: $0) == normalizedIncoming + }) + ) + }) + } + + if let core { + for list in core.friendsLists where list.type == .CardDAV { + if friend == nil { + friend = list.friends.first(where: { + $0.addresses.contains(where: { $0.asStringUriOnly() == sipUri }) || + ( + normalizedIncoming != nil && + $0.phoneNumbers.contains(where: { + core.defaultAccount?.normalizePhoneNumber(username: $0) == normalizedIncoming + }) + ) + }) + } } } diff --git a/Linphone/GeneratedGit.swift b/Linphone/GeneratedGit.swift index c1867309e..119b27c2b 100644 --- a/Linphone/GeneratedGit.swift +++ b/Linphone/GeneratedGit.swift @@ -2,6 +2,6 @@ import Foundation public enum AppGitInfo { public static let branch = "master" - public static let commit = "907211903" + public static let commit = "2fea9d720" public static let tag = "6.1.0-alpha" } diff --git a/LinphoneApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/LinphoneApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 84ef69fff..919d769df 100644 --- a/LinphoneApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/LinphoneApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -123,7 +123,7 @@ "location" : "https://gitlab.linphone.org/BC/public/linphone-sdk-swift-ios.git", "state" : { "branch" : "alpha", - "revision" : "e2c24740b5f3479ae5d80f0eda11165937c448f8" + "revision" : "859ffa75fe7118f861aec8baf0d9696671d349f5" } }, {