Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
xx messenger iOS
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
xx messenger iOS
Commits
d330881d
Commit
d330881d
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
Add ProcessBannedList functor
parent
fd9ae729
No related branches found
No related tags found
3 merge requests
!71
Releasing v1.1.5 (214)
,
!69
Implemented filtering for banned/blocked users and reporting
,
!67
v1.1.5 b(203)
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Package.swift
+1
-0
1 addition, 0 deletions
Package.swift
Sources/ReportingFeature/ProcessBannedList.swift
+64
-0
64 additions, 0 deletions
Sources/ReportingFeature/ProcessBannedList.swift
with
65 additions
and
0 deletions
Package.swift
+
1
−
0
View file @
d330881d
...
...
@@ -749,6 +749,7 @@ let package = Package(
.
target
(
name
:
"ReportingFeature"
,
dependencies
:
[
.
product
(
name
:
"SwiftCSV"
,
package
:
"SwiftCSV"
),
.
product
(
name
:
"XCTestDynamicOverlay"
,
package
:
"xctest-dynamic-overlay"
),
],
resources
:
[
...
...
This diff is collapsed.
Click to expand it.
Sources/ReportingFeature/ProcessBannedList.swift
0 → 100644
+
64
−
0
View file @
d330881d
import
Foundation
import
SwiftCSV
import
XCTestDynamicOverlay
public
struct
ProcessBannedList
{
public
enum
ElementError
:
Swift
.
Error
{
case
missingUserId
case
invalidUserId
(
String
)
}
public
enum
Error
:
Swift
.
Error
{
case
invalidData
case
csv
(
Swift
.
Error
)
}
public
typealias
ForEach
=
(
Result
<
Data
,
ElementError
>
)
->
Void
public
typealias
Completion
=
(
Result
<
Void
,
Error
>
)
->
Void
public
var
run
:
(
Data
,
ForEach
,
Completion
)
->
Void
public
func
callAsFunction
(
data
:
Data
,
forEach
:
ForEach
,
completion
:
Completion
)
{
run
(
data
,
forEach
,
completion
)
}
}
extension
ProcessBannedList
{
public
static
let
live
=
ProcessBannedList
{
data
,
forEach
,
completion
in
guard
let
csvString
=
String
(
data
:
data
,
encoding
:
.
utf8
)
else
{
completion
(
.
failure
(
.
invalidData
))
return
}
let
csv
:
EnumeratedCSV
do
{
csv
=
try
EnumeratedCSV
(
string
:
csvString
)
}
catch
{
completion
(
.
failure
(
.
csv
(
error
)))
return
}
csv
.
rows
.
forEach
{
row
in
guard
let
userIdString
=
row
.
first
else
{
forEach
(
.
failure
(
.
missingUserId
))
return
}
guard
let
userId
=
Data
(
base64Encoded
:
userIdString
)
else
{
forEach
(
.
failure
(
.
invalidUserId
(
userIdString
)))
return
}
forEach
(
.
success
(
userId
))
}
completion
(
.
success
(()))
}
}
extension
ProcessBannedList
{
public
static
let
unimplemented
=
ProcessBannedList
{
_
,
_
,
_
in
let
run
:
()
->
Void
=
XCTUnimplemented
(
"
\(
Self
.
self
)
"
)
run
()
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment