From aab6bfbd3bb88685eade1ddf57c5c5e03122565f Mon Sep 17 00:00:00 2001 From: Matt Grogan Date: Mon, 12 Aug 2024 11:28:24 +0100 Subject: [PATCH] Support updating add members permission (#6194) --- backend/canisters/community/CHANGELOG.md | 4 ++++ backend/libraries/group_chat_core/src/lib.rs | 15 +++++++-------- backend/libraries/types/can.did | 3 ++- backend/libraries/types/src/group_roles.rs | 1 + 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/backend/canisters/community/CHANGELOG.md b/backend/canisters/community/CHANGELOG.md index ae6b4f066d..afe8c11e87 100644 --- a/backend/canisters/community/CHANGELOG.md +++ b/backend/canisters/community/CHANGELOG.md @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [unreleased] +### Added + +- Support updating add members permission ([#6194](https://github.com/open-chat-labs/open-chat/pull/6194)) + ### Changed - Members of private communities can be added to channels skipping gate checks ([#6159](https://github.com/open-chat-labs/open-chat/pull/6159)) diff --git a/backend/libraries/group_chat_core/src/lib.rs b/backend/libraries/group_chat_core/src/lib.rs index e070d1ba79..5db3f98d0b 100644 --- a/backend/libraries/group_chat_core/src/lib.rs +++ b/backend/libraries/group_chat_core/src/lib.rs @@ -12,13 +12,12 @@ use std::collections::{BTreeSet, HashSet}; use types::{ AccessGate, AvatarChanged, ContentValidationError, CustomPermission, Document, EventIndex, EventOrExpiredRange, EventWrapper, EventsResponse, FieldTooLongResult, FieldTooShortResult, GroupDescriptionChanged, GroupGateUpdated, - GroupNameChanged, GroupPermissionRole, GroupPermissions, GroupReplyContext, GroupRole, GroupRulesChanged, GroupSubtype, - GroupVisibilityChanged, HydratedMention, InvalidPollReason, MemberLeft, MembersRemoved, Message, MessageContent, - MessageContentInitial, MessageId, MessageIndex, MessageMatch, MessagePermissions, MessagePinned, MessageUnpinned, - MessagesResponse, Milliseconds, MultiUserChat, OptionUpdate, OptionalGroupPermissions, OptionalMessagePermissions, - PermissionsChanged, PushEventResult, PushIfNotContains, Reaction, RoleChanged, Rules, SelectedGroupUpdates, ThreadPreview, - TimestampMillis, Timestamped, UpdatedRules, UserId, UserType, UsersBlocked, UsersInvited, Version, Versioned, - VersionedRules, VideoCall, + GroupNameChanged, GroupPermissions, GroupReplyContext, GroupRole, GroupRulesChanged, GroupSubtype, GroupVisibilityChanged, + HydratedMention, InvalidPollReason, MemberLeft, MembersRemoved, Message, MessageContent, MessageContentInitial, MessageId, + MessageIndex, MessageMatch, MessagePermissions, MessagePinned, MessageUnpinned, MessagesResponse, Milliseconds, + MultiUserChat, OptionUpdate, OptionalGroupPermissions, OptionalMessagePermissions, PermissionsChanged, PushEventResult, + PushIfNotContains, Reaction, RoleChanged, Rules, SelectedGroupUpdates, ThreadPreview, TimestampMillis, Timestamped, + UpdatedRules, UserId, UserType, UsersBlocked, UsersInvited, Version, Versioned, VersionedRules, VideoCall, }; use utils::document_validation::validate_avatar; use utils::text_validation::{ @@ -1710,7 +1709,7 @@ impl GroupChatCore { delete_messages: new.delete_messages.unwrap_or(old.delete_messages), update_group: new.update_group.unwrap_or(old.update_group), pin_messages: new.pin_messages.unwrap_or(old.pin_messages), - add_members: GroupPermissionRole::Owner, + add_members: new.add_members.unwrap_or(old.add_members), invite_users: new.invite_users.unwrap_or(old.invite_users), react_to_messages: new.react_to_messages.unwrap_or(old.react_to_messages), mention_all_members: new.mention_all_members.unwrap_or(old.mention_all_members), diff --git a/backend/libraries/types/can.did b/backend/libraries/types/can.did index 6b1ce69e44..5494edd218 100644 --- a/backend/libraries/types/can.did +++ b/backend/libraries/types/can.did @@ -1273,12 +1273,12 @@ type User = record { type GroupPermissions = record { change_roles : PermissionRole; - add_members : PermissionRole; remove_members : PermissionRole; delete_messages : PermissionRole; update_group : PermissionRole; pin_messages : PermissionRole; invite_users : PermissionRole; + add_members : PermissionRole; react_to_messages : PermissionRole; mention_all_members : PermissionRole; start_video_call : PermissionRole; @@ -1314,6 +1314,7 @@ type OptionalGroupPermissions = record { update_group : opt PermissionRole; pin_messages : opt PermissionRole; invite_users : opt PermissionRole; + add_members : opt PermissionRole; react_to_messages : opt PermissionRole; mention_all_members : opt PermissionRole; start_video_call : opt PermissionRole; diff --git a/backend/libraries/types/src/group_roles.rs b/backend/libraries/types/src/group_roles.rs index 0d982dd056..d6d7d856dd 100644 --- a/backend/libraries/types/src/group_roles.rs +++ b/backend/libraries/types/src/group_roles.rs @@ -61,6 +61,7 @@ pub struct OptionalGroupPermissions { pub change_roles: Option, pub update_group: Option, pub invite_users: Option, + pub add_members: Option, pub remove_members: Option, pub delete_messages: Option, pub pin_messages: Option,