mirror of https://github.com/zulip/zulip.git
parent
cc76f7deac
commit
98be0cc502
|
@ -4362,6 +4362,13 @@ def remove_members_from_user_group(user_group, user_profiles):
|
||||||
user_ids = [up.id for up in user_profiles]
|
user_ids = [up.id for up in user_profiles]
|
||||||
do_send_user_group_members_update_event('remove_members', user_group, user_ids)
|
do_send_user_group_members_update_event('remove_members', user_group, user_ids)
|
||||||
|
|
||||||
|
def do_send_delete_user_group_event(user_group_id: int, realm_id: int) -> None:
|
||||||
|
event = dict(type="user_group",
|
||||||
|
op="remove",
|
||||||
|
group_id=user_group_id)
|
||||||
|
send_event(event, active_user_ids(realm_id))
|
||||||
|
|
||||||
def check_delete_user_group(user_group_id: int, realm: Realm) -> None:
|
def check_delete_user_group(user_group_id: int, realm: Realm) -> None:
|
||||||
user_group = access_user_group_by_id(user_group_id, realm)
|
user_group = access_user_group_by_id(user_group_id, realm)
|
||||||
user_group.delete()
|
user_group.delete()
|
||||||
|
do_send_delete_user_group_event(user_group_id, realm.id)
|
||||||
|
|
|
@ -571,6 +571,9 @@ def apply_event(state, event, user_profile, client_gravatar, include_subscribers
|
||||||
members = set(user_group['members'])
|
members = set(user_group['members'])
|
||||||
user_group['members'] = list(members - set(event['user_ids']))
|
user_group['members'] = list(members - set(event['user_ids']))
|
||||||
user_group['members'].sort()
|
user_group['members'].sort()
|
||||||
|
elif event['op'] == 'remove':
|
||||||
|
state['realm_user_groups'] = [ug for ug in state['realm_user_groups']
|
||||||
|
if ug['id'] != event['group_id']]
|
||||||
else:
|
else:
|
||||||
raise AssertionError("Unexpected event type %s" % (event['type'],))
|
raise AssertionError("Unexpected event type %s" % (event['type'],))
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,7 @@ from zerver.lib.actions import (
|
||||||
do_update_user_group_description,
|
do_update_user_group_description,
|
||||||
bulk_add_members_to_user_group,
|
bulk_add_members_to_user_group,
|
||||||
remove_members_from_user_group,
|
remove_members_from_user_group,
|
||||||
|
check_delete_user_group,
|
||||||
)
|
)
|
||||||
from zerver.lib.events import (
|
from zerver.lib.events import (
|
||||||
apply_events,
|
apply_events,
|
||||||
|
@ -1061,6 +1062,16 @@ class EventsRegisterTest(ZulipTestCase):
|
||||||
error = user_group_remove_member_checker('events[0]', events[0])
|
error = user_group_remove_member_checker('events[0]', events[0])
|
||||||
self.assert_on_error(error)
|
self.assert_on_error(error)
|
||||||
|
|
||||||
|
# Test delete event
|
||||||
|
user_group_remove_checker = self.check_events_dict([
|
||||||
|
('type', equals('user_group')),
|
||||||
|
('op', equals('remove')),
|
||||||
|
('group_id', check_int),
|
||||||
|
])
|
||||||
|
events = self.do_test(lambda: check_delete_user_group(backend.id, backend.realm))
|
||||||
|
error = user_group_remove_checker('events[0]', events[0])
|
||||||
|
self.assert_on_error(error)
|
||||||
|
|
||||||
def test_default_stream_groups_events(self):
|
def test_default_stream_groups_events(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
default_stream_groups_checker = self.check_events_dict([
|
default_stream_groups_checker = self.check_events_dict([
|
||||||
|
|
Loading…
Reference in New Issue