Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
user_groups: Allow members of subgroups to manage group.
Sahil Batrab554106e6df7
diff --git a/zerver/lib/user_groups.py b/zerver/lib/user_groups.pyindex df62998bf19..b962643399e 100644--- a/zerver/lib/user_groups.py+++ b/zerver/lib/user_groups.py@@ -120,9 +120,7 @@ def check_permission_for_managing_all_groups(if user_profile.is_realm_admin or user_profile.is_moderator:return True- group_members = get_user_group_direct_member_ids(user_group)- if user_profile.id in group_members:- return True+ return is_user_in_group(user_group, user_profile)return Falsediff --git a/zerver/tests/test_user_groups.py b/zerver/tests/test_user_groups.pyindex 4c62cac9bd1..54f149525c5 100644--- a/zerver/tests/test_user_groups.py+++ b/zerver/tests/test_user_groups.py@@ -1883,6 +1883,17 @@ class UserGroupAPITestCase(UserGroupTestCase):)check_update_user_group("help", "Troubleshooting team", "othello")+ # Check user who is member of a subgroup of the group being updated+ # can also update the group.+ cordelia = self.example_user("cordelia")+ subgroup = check_add_user_group(realm, "leadership", [cordelia], acting_user=cordelia)+ add_subgroups_to_user_group(user_group, [subgroup], acting_user=None)+ check_update_user_group(+ "support",+ "Support team",+ "cordelia",+ )+# Check only full members are allowed to update the user group and only if belong to the# user group.do_set_realm_property(@@ -1897,10 +1908,9 @@ class UserGroupAPITestCase(UserGroupTestCase):cordelia.date_joined = timezone_now() - timedelta(days=11)cordelia.save()check_update_user_group(- "support",- "Support team",+ "help",+ "Troubleshooting team","cordelia",- "Insufficient permission",)check_update_user_group("support", "Support team", "othello", "Insufficient permission")