Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Elixxir dApps SDK Swift
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile
iOS
Elixxir dApps SDK Swift
Merge requests
!80
Add MessengerVerifyContact function
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add MessengerVerifyContact function
feature/messenger-verify-contact
into
development
Overview
0
Commits
1
Pipelines
0
Changes
4
Merged
Dariusz Rybicki
requested to merge
feature/messenger-verify-contact
into
development
2 years ago
Overview
0
Commits
1
Pipelines
0
Changes
4
Expand
0
0
Merge request reports
Viewing commit
83576e09
Show latest version
4 files
+
435
−
2
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
83576e09
Add MessengerVerifyContact function
· 83576e09
Dariusz Rybicki
authored
2 years ago
Sources/XXMessengerClient/Messenger/Functions/MessengerVerifyContact.swift
0 → 100644
+
78
−
0
Options
import
Foundation
import
XCTestDynamicOverlay
import
XXClient
public
struct
MessengerVerifyContact
{
public
enum
Error
:
Swift
.
Error
,
Equatable
{
case
notConnected
case
notLoggedIn
}
public
var
run
:
(
Contact
)
throws
->
Bool
public
func
callAsFunction
(
_
contact
:
Contact
)
throws
->
Bool
{
try
run
(
contact
)
}
}
extension
MessengerVerifyContact
{
public
static
func
live
(
_
env
:
MessengerEnvironment
)
->
MessengerVerifyContact
{
MessengerVerifyContact
{
contact
in
guard
let
e2e
=
env
.
e2e
()
else
{
throw
Error
.
notConnected
}
guard
let
ud
=
env
.
ud
()
else
{
throw
Error
.
notLoggedIn
}
let
facts
=
try
contact
.
getFacts
()
let
verifiedContact
:
Contact
?
if
facts
.
isEmpty
{
var
lookupResult
:
Result
<
Contact
,
NSError
>!
let
semaphore
=
DispatchSemaphore
(
value
:
0
)
_
=
try
env
.
lookupUD
(
e2eId
:
e2e
.
getId
(),
udContact
:
try
ud
.
getContact
(),
lookupId
:
try
contact
.
getId
(),
singleRequestParamsJSON
:
env
.
getSingleUseParams
(),
callback
:
.
init
{
result
in
lookupResult
=
result
semaphore
.
signal
()
}
)
semaphore
.
wait
()
verifiedContact
=
try
lookupResult
.
get
()
}
else
{
var
searchResult
:
Result
<
[
Contact
],
NSError
>!
let
semaphore
=
DispatchSemaphore
(
value
:
0
)
_
=
try
env
.
searchUD
(
e2eId
:
e2e
.
getId
(),
udContact
:
try
ud
.
getContact
(),
facts
:
facts
,
singleRequestParamsJSON
:
env
.
getSingleUseParams
(),
callback
:
.
init
{
result
in
searchResult
=
result
semaphore
.
signal
()
}
)
semaphore
.
wait
()
verifiedContact
=
try
searchResult
.
get
()
.
first
}
guard
let
verifiedContact
=
verifiedContact
else
{
return
false
}
return
try
e2e
.
verifyOwnership
(
received
:
contact
,
verified
:
verifiedContact
,
e2eId
:
e2e
.
getId
()
)
}
}
}
extension
MessengerVerifyContact
{
public
static
let
unimplemented
=
MessengerVerifyContact
(
run
:
XCTUnimplemented
(
"
\(
Self
.
self
)
"
)
)
}
Loading