diff --git a/backend/canisters/group/CHANGELOG.md b/backend/canisters/group/CHANGELOG.md index e821937e79..0569af60d7 100644 --- a/backend/canisters/group/CHANGELOG.md +++ b/backend/canisters/group/CHANGELOG.md @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed - Disable mentions for messages sent by the ProposalsBot ([#4424](https://github.com/open-chat-labs/open-chat/pull/4424)) +- Simplify `inspect_message` ([#4436](https://github.com/open-chat-labs/open-chat/pull/4436)) ### Fixed diff --git a/backend/canisters/group/impl/src/lifecycle/inspect_message.rs b/backend/canisters/group/impl/src/lifecycle/inspect_message.rs index 04babe22cd..1b8346fcc5 100644 --- a/backend/canisters/group/impl/src/lifecycle/inspect_message.rs +++ b/backend/canisters/group/impl/src/lifecycle/inspect_message.rs @@ -18,39 +18,8 @@ fn accept_if_valid(state: &RuntimeState) { } let caller = state.env.caller(); - let permissions = &state.data.chat.permissions; - let is_valid = if let Some(role) = state.data.get_member(caller).map(|p| p.role) { - match method_name.as_str() { - "add_reaction" | "remove_reaction" => role.can_react_to_messages(permissions), - "block_user" => role.can_block_users(permissions), - "convert_into_community" => role.is_owner(), - "delete_group" => role.can_delete_group(), - "enable_invite_code" | "disable_invite_code" | "reset_invite_code" => role.can_invite_users(permissions), - "make_private" => role.can_change_group_visibility(), - "pin_message" | "pin_message_v2" => role.can_pin_messages(permissions), - "remove_participant" => role.can_remove_members(permissions), - "send_message_v2" => role.can_send_messages(permissions) || role.can_reply_in_thread(permissions), - "unblock_user" => role.can_unblock_users(permissions), - "unpin_message" => role.can_pin_messages(permissions), - "update_group_v2" => role.can_update_group(permissions), - "update_permissions" => role.can_change_permissions(), - "delete_messages" - | "undelete_messages" - | "change_role" - | "claim_prize" - | "edit_message_v2" - | "follow_thread" - | "unfollow_thread" - | "put_chunk" - | "register_poll_vote" - | "register_proposal_vote" - | "register_proposal_vote_v2" - | "toggle_mute_notifications" => true, - _ => false, - } - } else { - state.data.get_invitation(caller).is_some() && method_name == "decline_invitation" - }; + let is_valid = state.data.get_member(caller).is_some() + || state.data.get_invitation(caller).is_some() && method_name == "decline_invitation"; if is_valid { ic_cdk::api::call::accept_message();