Fixed Watch voice messages encoding

Fixed Siri contacts matching
This commit is contained in:
Ilya Laktyushin 2019-08-13 04:54:53 +03:00
parent b4541f7495
commit dfb61a3267
3 changed files with 24 additions and 14 deletions

View File

@ -31,6 +31,20 @@ private func parseAppSpecificContactReference(_ value: String) -> PeerId? {
return nil
}
private func cleanPhoneNumber(_ text: String) -> String {
var result = ""
for c in text {
if c == "+" {
if result.isEmpty {
result += String(c)
}
} else if c >= "0" && c <= "9" {
result += String(c)
}
}
return result
}
func matchingDeviceContacts(stableIds: [String]) -> Signal<[MatchingDeviceContact], IntentContactsError> {
guard CNContactStore.authorizationStatus(for: .contacts) == .authorized else {
return .fail(.generic)
@ -43,7 +57,7 @@ func matchingDeviceContacts(stableIds: [String]) -> Signal<[MatchingDeviceContac
return .single(contacts.map({ contact in
let phoneNumbers = contact.phoneNumbers.compactMap({ number -> String? in
if !number.value.stringValue.isEmpty {
return number.value.stringValue
return cleanPhoneNumber(number.value.stringValue)
} else {
return nil
}
@ -75,22 +89,18 @@ func matchingCloudContacts(postbox: Postbox, contacts: [MatchingDeviceContact])
var result: [(String, TelegramUser)] = []
outer: for peerId in transaction.getContactPeerIds() {
if let peer = transaction.getPeer(peerId) as? TelegramUser {
if let peerPhoneNumber = peer.phone {
for contact in contacts {
for phoneNumber in contact.phoneNumbers {
if matchPhoneNumbers(phoneNumber, peerPhoneNumber) {
for contact in contacts {
if let contactPeerId = contact.peerId, contactPeerId == peerId {
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))
continue outer
}
}
}
} else {
for contact in contacts {
if let contactPeerId = contact.peerId, contactPeerId == peerId {
result.append((contact.stableId, peer))
continue outer
}
}
}
}
}

View File

@ -121,7 +121,7 @@ typedef enum {
return queue;
}
static const int encoderPacketSizeInBytes = TGBridgeAudioEncoderSampleRate / 1000 * 60 * 2;
static const int encoderPacketSizeInBytes = 16000 / 1000 * 60 * 2;
- (void)startWithCompletion:(void (^)(NSString *, int32_t))completion
{

View File

@ -65,7 +65,7 @@ private enum ResetPasswordEntry: ItemListNodeEntry, Equatable {
func item(_ arguments: ResetPasswordControllerArguments) -> ListViewItem {
switch self {
case let .code(theme, text, value):
return ItemListSingleLineInputItem(theme: theme, title: NSAttributedString(string: text), text: value, placeholder: "", type: .number, spacing: 10.0, tag: ResetPasswordEntryTag.code, sectionId: self.section, textUpdated: { updatedText in
return ItemListSingleLineInputItem(theme: theme, title: NSAttributedString(string: text, textColor: theme.list.itemPrimaryTextColor), text: value, placeholder: "", type: .number, spacing: 10.0, tag: ResetPasswordEntryTag.code, sectionId: self.section, textUpdated: { updatedText in
arguments.updateCodeText(updatedText)
}, action: {
})