Skip to content
Snippets Groups Projects
Commit e70c992e authored by Bruno Muniz's avatar Bruno Muniz
Browse files

Fixes stringified facts from verification

parent 5fac939e
Branches
Tags
2 merge requests!8Fixing failed verification due to wrong fact passed,!5Hotfix stringified verification
......@@ -70,11 +70,22 @@ extension Session {
let ud = client.userDiscovery!
guard let fact = contact.email ?? contact.phone else {
let hasEmail = contact.email != nil
let hasPhone = contact.phone != nil
guard hasEmail || hasPhone else {
ud.lookup(forUserId: contact.userId, resultClosure)
return
}
var fact: String
if hasEmail {
fact = "\(FactType.email.prefix)\(contact.email!)"
} else {
fact = "\(FactType.phone.prefix)\(contact.phone!)"
}
do {
try ud.search(fact: fact, resultClosure)
} catch {
......
......@@ -18,4 +18,17 @@ public enum FactType: Int {
return "Username"
}
}
public var prefix: String {
switch self {
case .email:
return "E"
case .nickname:
return "N"
case .phone:
return "P"
case .username:
return "U"
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment