diff options
| author | Josh Ferrell <josh@vector35.com> | 2026-04-14 16:22:40 -0400 |
|---|---|---|
| committer | Josh Ferrell <josh@vector35.com> | 2026-05-05 14:46:15 -0400 |
| commit | af50b06082044fcbbf730deda985d0133ca98b88 (patch) | |
| tree | 6b1ae5a4678d8a39a88af4de2cd150663e1a9c8e /rust/src/collaboration/project.rs | |
| parent | e4db4f0704ea6e6b381e9322a336661dc23c3b5f (diff) | |
Switch collaboration permission checks to using User objects
Diffstat (limited to 'rust/src/collaboration/project.rs')
| -rw-r--r-- | rust/src/collaboration/project.rs | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/rust/src/collaboration/project.rs b/rust/src/collaboration/project.rs index cfcc1db4..3a24ea8b 100644 --- a/rust/src/collaboration/project.rs +++ b/rust/src/collaboration/project.rs @@ -12,6 +12,7 @@ use super::{ }; use crate::binary_view::{BinaryView, BinaryViewExt}; +use crate::collaboration::RemoteUser; use crate::database::Database; use crate::file_metadata::FileMetadata; use crate::progress::{NoProgressCallback, ProgressCallback}; @@ -761,34 +762,31 @@ impl RemoteProject { success.then_some(()).ok_or(()) } - /// Determine if a user is in any of the view/edit/admin groups. + /// Determine if a user has view permission (either directly or from a group) /// /// # Arguments /// - /// * `username` - Username of user to check - pub fn can_user_view(&self, username: &str) -> bool { - let username = username.to_cstr(); - unsafe { BNRemoteProjectCanUserView(self.handle.as_ptr(), username.as_ptr()) } + /// * `user` - User to check + pub fn can_user_view(&self, user: Ref<RemoteUser>) -> bool { + unsafe { BNRemoteProjectCanUserView(self.handle.as_ptr(), user.handle.as_ptr()) } } - /// Determine if a user is in any of the edit/admin groups. + /// Determine if a user has edit permission (either directly or from a group) /// /// # Arguments /// - /// * `username` - Username of user to check - pub fn can_user_edit(&self, username: &str) -> bool { - let username = username.to_cstr(); - unsafe { BNRemoteProjectCanUserEdit(self.handle.as_ptr(), username.as_ptr()) } + /// * `user` - User to check + pub fn can_user_edit(&self, user: Ref<RemoteUser>) -> bool { + unsafe { BNRemoteProjectCanUserEdit(self.handle.as_ptr(), user.handle.as_ptr()) } } - /// Determine if a user is in the admin group. + /// Determine if a user has admin permission (either directly or from a group) /// /// # Arguments /// - /// * `username` - Username of user to check - pub fn can_user_admin(&self, username: &str) -> bool { - let username = username.to_cstr(); - unsafe { BNRemoteProjectCanUserAdmin(self.handle.as_ptr(), username.as_ptr()) } + /// * `user` - User to check + pub fn can_user_admin(&self, user: Ref<RemoteUser>) -> bool { + unsafe { BNRemoteProjectCanUserAdmin(self.handle.as_ptr(), user.handle.as_ptr()) } } /// Get the default directory path for a remote Project. This is based off |
