Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

events: Fix updating subscribers list when deactivating user.

Sahil Batraa7c534b1b840
diff --git a/zerver/lib/events.py b/zerver/lib/events.py
index 144f742c1e6..fb0b5eb382a 100644
--- a/zerver/lib/events.py
+++ b/zerver/lib/events.py
@@ -1093,10 +1093,17 @@ def apply_event(
p["email"] = person["new_email"]
if "is_active" in person and not person["is_active"] and include_subscribers:
- for sub in state["subscriptions"]:
- sub["subscribers"] = [
- user_id for user_id in sub["subscribers"] if user_id != person_user_id
- ]
+ for sub_dict in [
+ state["subscriptions"],
+ state["unsubscribed"],
+ state["never_subscribed"],
+ ]:
+ for sub in sub_dict:
+ sub["subscribers"] = [
+ user_id
+ for user_id in sub["subscribers"]
+ if user_id != person_user_id
+ ]
elif event["op"] == "remove":
if person_user_id in state["raw_users"]:
if user_list_incomplete:
@@ -1108,10 +1115,15 @@ def apply_event(
state["raw_users"][person_user_id] = inaccessible_user_dict
if include_subscribers:
- for sub in state["subscriptions"]:
- sub["subscribers"] = [
- user_id for user_id in sub["subscribers"] if user_id != person_user_id
- ]
+ for sub_dict in [
+ state["subscriptions"],
+ state["unsubscribed"],
+ state["never_subscribed"],
+ ]:
+ for sub in sub_dict:
+ sub["subscribers"] = [
+ user_id for user_id in sub["subscribers"] if user_id != person_user_id
+ ]
else:
raise AssertionError("Unexpected event type {type}/{op}".format(**event))
elif event["type"] == "realm_bot":