Fix fast addr book : callback can be called with tel number or sip uri containing tel number

This commit is contained in:
Paul Cartier 2020-05-07 16:15:44 +02:00
parent 05608ae8fb
commit a952f7724f

View file

@ -579,9 +579,20 @@
- (void)onPresenceChanged:(NSNotification *)k {
NSString *uri = [NSString stringWithUTF8String:[[k.userInfo valueForKey:@"uri"] pointerValue]];
if (![FastAddressBook isSipURI:uri]) {
LOGD(@"presence changed for tel [%s]", uri.UTF8String);
NSString *telAddr = [FastAddressBook normalizeSipURI:uri];
NSString *telAddr;
if ([FastAddressBook isSipURI:uri]) {
LinphoneAddress *addr = linphone_address_new(uri.UTF8String);
if (linphone_proxy_config_is_phone_number(linphone_core_get_default_proxy_config(LC), linphone_address_get_username(addr))) {
telAddr = uri;
}
linphone_address_unref(addr);
} else {
telAddr = [FastAddressBook normalizeSipURI:uri];
}
if (telAddr) {
LOGD(@"presence changed for tel [%s]", telAddr.UTF8String);
NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:kLinphoneMsgNotificationAppGroupId];
NSMutableDictionary *displayNames = [[NSMutableDictionary alloc] initWithDictionary:[defaults dictionaryForKey:@"addressBook"]];