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
No related branches found
No related tags found
2 merge requests!8Fixing failed verification due to wrong fact passed,!5Hotfix stringified verification
...@@ -70,11 +70,22 @@ extension Session { ...@@ -70,11 +70,22 @@ extension Session {
let ud = client.userDiscovery! 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) ud.lookup(forUserId: contact.userId, resultClosure)
return return
} }
var fact: String
if hasEmail {
fact = "\(FactType.email.prefix)\(contact.email!)"
} else {
fact = "\(FactType.phone.prefix)\(contact.phone!)"
}
do { do {
try ud.search(fact: fact, resultClosure) try ud.search(fact: fact, resultClosure)
} catch { } catch {
......
...@@ -18,4 +18,17 @@ public enum FactType: Int { ...@@ -18,4 +18,17 @@ public enum FactType: Int {
return "Username" 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.
Finish editing this message first!
Please register or to comment