Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat_: light, no-network versions of permission checking functions #5168

Merged
merged 1 commit into from
May 20, 2024

Conversation

endulab
Copy link
Contributor

@endulab endulab commented May 15, 2024

For all permissions-check functions, corresponding light versions are added: CheckAllChannelsPermissionsLight, CheckChannelPermissionsLight, CheckPermissionToJoinLight (we can discuss naming convention).
Light functions are based on the fact that permissions are met if the user is on community/channel member list. If the user is not on the list, permissions will not be met and the client is responsible to use regular permissions-check functions.

Issue #14220

@status-im-auto
Copy link
Member

status-im-auto commented May 15, 2024

Jenkins Builds

Click to see older builds (12)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 8dd311d #1 2024-05-15 12:40:04 ~4 min linux 📦zip
✔️ 8dd311d #1 2024-05-15 12:40:36 ~4 min ios 📦zip
✔️ 8dd311d #1 2024-05-15 12:41:34 ~5 min android 📦aar
✔️ 8dd311d #1 2024-05-15 13:18:26 ~42 min tests 📄log
✔️ faa06a3 #2 2024-05-16 12:50:34 ~4 min ios 📦zip
✔️ faa06a3 #2 2024-05-16 12:50:40 ~4 min linux 📦zip
✔️ faa06a3 #2 2024-05-16 12:52:27 ~5 min android 📦aar
✔️ faa06a3 #2 2024-05-16 13:28:41 ~42 min tests 📄log
✔️ 3b0135b #3 2024-05-17 12:31:49 ~3 min linux 📦zip
✔️ 3b0135b #3 2024-05-17 12:32:04 ~3 min android 📦aar
✔️ 3b0135b #3 2024-05-17 12:32:18 ~3 min ios 📦zip
✔️ 3b0135b #3 2024-05-17 13:12:17 ~43 min tests 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ d55e177 #4 2024-05-20 10:24:14 ~2 min android 📦aar
✔️ d55e177 #4 2024-05-20 10:25:04 ~3 min ios 📦zip
✔️ d55e177 #4 2024-05-20 10:25:39 ~4 min linux 📦zip
✔️ d55e177 #4 2024-05-20 11:05:45 ~44 min tests 📄log

Copy link
Member

@jrainville jrainville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job. Just some questions and aesthetic suggestions

Comment on lines 2957 to 2962
viewSatisfied := false
if !hasViewOnlyPermissions {
viewSatisfied = true
} else {
viewSatisfied = (meAsMember != nil && meAsMember.GetChannelRole() == protobuf.CommunityMember_CHANNEL_ROLE_VIEWER)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
viewSatisfied := false
if !hasViewOnlyPermissions {
viewSatisfied = true
} else {
viewSatisfied = (meAsMember != nil && meAsMember.GetChannelRole() == protobuf.CommunityMember_CHANNEL_ROLE_VIEWER)
}
viewSatisfied := !hasViewOnlyPermissions || (meAsMember != nil && meAsMember.GetChannelRole() == protobuf.CommunityMember_CHANNEL_ROLE_VIEWER)

Comment on lines 2964 to 2969
postSatisfied := false
if !hasViewAndPostPermissions {
postSatisfied = true
} else {
postSatisfied = (meAsMember != nil && meAsMember.GetChannelRole() == protobuf.CommunityMember_CHANNEL_ROLE_POSTER)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
postSatisfied := false
if !hasViewAndPostPermissions {
postSatisfied = true
} else {
postSatisfied = (meAsMember != nil && meAsMember.GetChannelRole() == protobuf.CommunityMember_CHANNEL_ROLE_POSTER)
}
postSatisfied := !hasViewAndPostPermissions || (meAsMember != nil && meAsMember.GetChannelRole() == protobuf.CommunityMember_CHANNEL_ROLE_POSTER)

protocol/communities/manager.go Show resolved Hide resolved
protocol/communities/manager.go Show resolved Hide resolved
Copy link
Contributor

@MishkaRogachev MishkaRogachev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Jo's comments, but otherwise things look good!

@endulab endulab force-pushed the 14220-check-permissions-light-mode branch from 8dd311d to faa06a3 Compare May 16, 2024 12:46
@@ -3026,6 +3098,27 @@ func (m *Manager) CheckAllChannelsPermissions(communityID types.HexBytes, addres
return response, nil
}

// Light version of CheckAllChannelsPermissionsLight, which does not use network requests.
// Instead of checking wallet balances it checks if there is an access to a member list of chats.
func (m *Manager) CheckAllChannelsPermissionsLight(communityID types.HexBytes) (*CheckAllChannelsPermissionsResponse, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: maybe rename it CheckAllChannelsPermissionsOffline?

@endulab endulab force-pushed the 14220-check-permissions-light-mode branch from faa06a3 to 3b0135b Compare May 17, 2024 12:28
Light functions are based on the fact that permissions are met if the user is on community/channel member list.
If the user is not on the list, permissions will not be met and the client is responsible to use regular permissions-check functions.
For all permissions-check functions, corresponding light versions are added: CheckAllChannelsPermissionsLight,
CheckChannelPermissionsLight, CheckPermissionToJoinLight.

Issue #14220
@endulab endulab force-pushed the 14220-check-permissions-light-mode branch from 3b0135b to d55e177 Compare May 20, 2024 10:21
@endulab endulab merged commit 6f1b829 into develop May 20, 2024
10 of 12 checks passed
@endulab endulab deleted the 14220-check-permissions-light-mode branch May 20, 2024 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No need to check permissions ourselves as member when a community updates permisisons
5 participants