Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
circles-android
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Circles
circles-android
Commits
611a1cc5
Commit
611a1cc5
authored
1 year ago
by
Taras
Browse files
Options
Downloads
Patches
Plain Diff
Remove child to parent relations for shared circles space
parent
1fd7adc7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
auth/src/main/java/org/futo/circles/auth/feature/workspace/data_source/ConfigureWorkspaceDataSource.kt
+12
-4
12 additions, 4 deletions
...ure/workspace/data_source/ConfigureWorkspaceDataSource.kt
with
12 additions
and
4 deletions
auth/src/main/java/org/futo/circles/auth/feature/workspace/data_source/ConfigureWorkspaceDataSource.kt
+
12
−
4
View file @
611a1cc5
...
...
@@ -5,6 +5,7 @@ import org.futo.circles.core.feature.room.create.CreateRoomDataSource
import
org.futo.circles.core.feature.workspace.SpacesTreeAccountDataSource
import
org.futo.circles.core.model.CIRCLES_SPACE_ACCOUNT_DATA_KEY
import
org.futo.circles.core.model.CirclesRoom
import
org.futo.circles.core.model.PROFILE_SPACE_ACCOUNT_DATA_KEY
import
org.futo.circles.core.model.SharedCirclesSpace
import
org.futo.circles.core.provider.MatrixSessionProvider
import
org.futo.circles.core.utils.getAllJoinedCirclesRoomsAndSpaces
...
...
@@ -27,7 +28,9 @@ class ConfigureWorkspaceDataSource @Inject constructor(
private
suspend
fun
validateAndFixRelationInNeeded
(
roomId
:
String
,
room
:
CirclesRoom
)
{
try
{
getJoinedRoomById
(
roomId
)
?.
let
{
validateRelations
(
room
.
parentAccountDataKey
,
it
)
}
getJoinedRoomById
(
roomId
)
?.
let
{
validateRelations
(
room
.
parentAccountDataKey
,
it
,
room
.
accountDataKey
)
}
}
catch
(
_
:
Exception
)
{
val
parentRoomId
=
room
.
parentAccountDataKey
?.
let
{
spacesTreeAccountDataSource
.
getRoomIdByKey
(
it
)
}
...
...
@@ -42,10 +45,14 @@ class ConfigureWorkspaceDataSource @Inject constructor(
?:
throw
IllegalArgumentException
(
"No account data record for key $accountDataKey"
)
val
joinedRoom
=
getJoinedRoomById
(
roomId
)
?:
throw
IllegalArgumentException
(
"No joined room for id $roomId found"
)
validateRelations
(
room
.
parentAccountDataKey
,
joinedRoom
)
validateRelations
(
room
.
parentAccountDataKey
,
joinedRoom
,
accountDataKey
)
}
private
fun
validateRelations
(
parentAccountDataKey
:
String
?,
joinedRoom
:
Room
)
{
private
fun
validateRelations
(
parentAccountDataKey
:
String
?,
joinedRoom
:
Room
,
accountDataKey
:
String
?
)
{
val
parentKey
=
parentAccountDataKey
?:
return
val
parentRoomId
=
spacesTreeAccountDataSource
.
getRoomIdByKey
(
parentKey
)
?:
throw
IllegalArgumentException
(
...
...
@@ -58,7 +65,8 @@ class ConfigureWorkspaceDataSource @Inject constructor(
?.
spaceSummary
()
?.
spaceParents
?.
mapNotNull
{
it
.
parentId
}
?.
contains
(
parentRoomId
)
==
true
if
(!
childHasRelationToParent
)
//iOS app do not set this relation
if
(!
childHasRelationToParent
&&
accountDataKey
!=
PROFILE_SPACE_ACCOUNT_DATA_KEY
)
throw
IllegalArgumentException
(
"Missing child to parent relations"
)
val
parentHasRelationToChild
=
joinedParentRoom
.
asSpace
()
...
...
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