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.

refactor: Exclude "active" from API_FIELDS.

Steve Howell79fcf7814393
diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py
index 1d762a7e369..be32163c1c1 100644
--- a/zerver/lib/actions.py
+++ b/zerver/lib/actions.py
@@ -2736,9 +2736,6 @@ def send_subscription_add_events(
subscription = sub_info.sub
sub_dict = stream.to_dict()
for field_name in Subscription.API_FIELDS:
- if field_name == "active":
- # Skip the "active" field, it's implied by context
- continue
sub_dict[field_name] = getattr(subscription, field_name)
sub_dict['in_home_view'] = not subscription.is_muted
@@ -4911,7 +4908,10 @@ def gather_subscriptions_helper(user_profile: UserProfile,
recip_id_to_stream_id = {stream["recipient_id"]: stream["id"] for stream in all_streams}
sub_dicts = get_stream_subscriptions_for_user(user_profile).values(
- *Subscription.API_FIELDS, "recipient_id").order_by("recipient_id")
+ *Subscription.API_FIELDS,
+ "recipient_id",
+ "active",
+ ).order_by("recipient_id")
# We only care about subscriptions for active streams.
sub_dicts = [
@@ -4980,8 +4980,7 @@ def gather_subscriptions_helper(user_profile: UserProfile,
continue
stream_dict[field_name] = stream[field_name]
- # Copy Subscription.API_FIELDS except for "active", which is
- # used to determine where to the put the field.
+ # Copy Subscription.API_FIELDS.
for field_name in Subscription.API_FIELDS:
stream_dict[field_name] = sub[field_name]
@@ -5014,7 +5013,7 @@ def gather_subscriptions_helper(user_profile: UserProfile,
stream_dict['subscribers'] = subscribers
# is_active is represented in this structure by which list we include it in.
- is_active = stream_dict.pop("active")
+ is_active = sub["active"]
if is_active:
subscribed.append(stream_dict)
else:
diff --git a/zerver/models.py b/zerver/models.py
index 836838bfe58..ab00b820261 100644
--- a/zerver/models.py
+++ b/zerver/models.py
@@ -2321,7 +2321,6 @@ class Subscription(models.Model):
# * "is_muted" often needs to be copied to not "in_home_view" for
# backwards-compatibility.
API_FIELDS = [
- "active",
"color",
"is_muted",
"pin_to_top",