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 /collaboration.cpp | |
| parent | e4db4f0704ea6e6b381e9322a336661dc23c3b5f (diff) | |
Switch collaboration permission checks to using User objects
Diffstat (limited to 'collaboration.cpp')
| -rw-r--r-- | collaboration.cpp | 56 |
1 files changed, 36 insertions, 20 deletions
diff --git a/collaboration.cpp b/collaboration.cpp index 14274164..15000cda 100644 --- a/collaboration.cpp +++ b/collaboration.cpp @@ -878,16 +878,16 @@ void Remote::PullGroups(ProgressFunction progress) } -Ref<CollabGroup> Remote::CreateGroup(const std::string& name, const std::vector<std::string>& usernames) +Ref<CollabGroup> Remote::CreateGroup(const std::string& name, const std::vector<Ref<CollabUser>>& users) { - const char** cstrNames = new const char*[usernames.size()]; - for (size_t i = 0; i < usernames.size(); i++) + BNCollaborationUser** cUsers = new BNCollaborationUser*[users.size()]; + for (size_t i = 0; i < users.size(); i++) { - cstrNames[i] = usernames[i].c_str(); + cUsers[i] = users[i]->m_object; } - BNCollaborationGroup* group = BNRemoteCreateGroup(m_object, name.c_str(), cstrNames, usernames.size()); - delete[] cstrNames; + BNCollaborationGroup* group = BNRemoteCreateGroup(m_object, name.c_str(), cUsers, users.size()); + delete[] cUsers; if (!group) return nullptr; return new CollabGroup(group); @@ -1076,22 +1076,38 @@ void CollabGroup::SetName(const std::string& name) } -void CollabGroup::SetUsernames(const std::vector<std::string>& usernames) +std::vector<Ref<CollabUser>> CollabGroup::GetUsers() { - const char** cNames = new const char*[usernames.size()]; - for (size_t i = 0; i < usernames.size(); i++) + size_t count = 0; + BNCollaborationUser** users = BNCollaborationGroupGetUsers(m_object, &count); + std::vector<Ref<CollabUser>> out; + out.reserve(count); + for (size_t i = 0; i < count; i++) + { + out.push_back(new CollabUser(BNNewCollaborationUserReference(users[i]))); + } + BNFreeCollaborationUserList(users, count); + return out; +} + + +void CollabGroup::SetUsers(const std::vector<Ref<CollabUser>>& users) +{ + size_t count = users.size(); + BNCollaborationUser** cUsers = new BNCollaborationUser*[count]; + for (size_t i = 0; i < count; i++) { - cNames[i] = usernames[i].c_str(); + cUsers[i] = users[i]->m_object; } - BNCollaborationGroupSetUsernames(m_object, cNames, usernames.size()); - delete[] cNames; + BNCollaborationGroupSetUsers(m_object, cUsers, count); + delete[] cUsers; } -bool CollabGroup::ContainsUser(const std::string& username) +bool CollabGroup::ContainsUser(Ref<CollabUser> user) { - return BNCollaborationGroupContainsUser(m_object, username.c_str()); + return BNCollaborationGroupContainsUser(m_object, user->m_object); } @@ -1566,21 +1582,21 @@ void RemoteProject::DeletePermission(Ref<CollabPermission> permission) } -bool RemoteProject::CanUserView(const std::string& username) +bool RemoteProject::CanUserView(Ref<CollabUser> user) { - return BNRemoteProjectCanUserView(m_object, username.c_str()); + return BNRemoteProjectCanUserView(m_object, user->m_object); } -bool RemoteProject::CanUserEdit(const std::string& username) +bool RemoteProject::CanUserEdit(Ref<CollabUser> user) { - return BNRemoteProjectCanUserEdit(m_object, username.c_str()); + return BNRemoteProjectCanUserEdit(m_object, user->m_object); } -bool RemoteProject::CanUserAdmin(const std::string& username) +bool RemoteProject::CanUserAdmin(Ref<CollabUser> user) { - return BNRemoteProjectCanUserAdmin(m_object, username.c_str()); + return BNRemoteProjectCanUserAdmin(m_object, user->m_object); } |
