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.

models: Remove "role" field from Subscription.

Sahil Batra093a74bd5438
diff --git a/frontend_tests/node_tests/lib/events.js b/frontend_tests/node_tests/lib/events.js
index e76ff0b656c..ec53f52c199 100644
--- a/frontend_tests/node_tests/lib/events.js
+++ b/frontend_tests/node_tests/lib/events.js
@@ -634,7 +634,6 @@ exports.fixtures = {
push_notifications: false,
stream_weekly_traffic: 40,
wildcard_mentions_notify: false,
- role: 20,
subscribers: [5, 8, 13, 21],
},
],
diff --git a/templates/zerver/api/changelog.md b/templates/zerver/api/changelog.md
index 0e5b389cfe5..e9814642739 100644
--- a/templates/zerver/api/changelog.md
+++ b/templates/zerver/api/changelog.md
@@ -24,6 +24,9 @@ format used by the Zulip server that they are interacting with.
* [`POST /register`](/api/register-queue), `PATCH /realm`: Removed
stream administrators option from `wildcard_mention_policy` setting.
+* [`POST /register`](/api/register-queue), [`GET /events`](/api/get-events),
+ [`GET /users/me/subscriptions`](/api/get-subscriptions): Removed
+ `role` field from subscription objects.
**Feature level 132**
diff --git a/version.py b/version.py
index 5669db703aa..d58ea178fab 100644
--- a/version.py
+++ b/version.py
@@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.4.3"
# Changes should be accompanied by documentation explaining what the
# new level means in templates/zerver/api/changelog.md, as well as
# "**Changes**" entries in the endpoint's documentation in `zulip.yaml`.
-API_FEATURE_LEVEL = 132
+API_FEATURE_LEVEL = 133
# Bump the minor PROVISION_VERSION to indicate that folks should provision
# only when going from an old version of the code to a newer version. Bump
diff --git a/zerver/actions/streams.py b/zerver/actions/streams.py
index 030115b3047..deaf602b1ee 100644
--- a/zerver/actions/streams.py
+++ b/zerver/actions/streams.py
@@ -281,7 +281,6 @@ def send_subscription_add_events(
is_muted=subscription.is_muted,
pin_to_top=subscription.pin_to_top,
push_notifications=subscription.push_notifications,
- role=subscription.role,
wildcard_mentions_notify=subscription.wildcard_mentions_notify,
# Computed fields not present in Subscription.API_FIELDS
email_address=stream_info.email_address,
diff --git a/zerver/lib/event_schema.py b/zerver/lib/event_schema.py
index 579d51bb9dd..65002ab157c 100644
--- a/zerver/lib/event_schema.py
+++ b/zerver/lib/event_schema.py
@@ -45,7 +45,7 @@ from zerver.lib.data_types import (
make_checker,
)
from zerver.lib.topic import ORIG_TOPIC, TOPIC_LINKS, TOPIC_NAME
-from zerver.models import Realm, RealmUserDefault, Stream, Subscription, UserProfile
+from zerver.models import Realm, RealmUserDefault, Stream, UserProfile
# These fields are used for "stream" events, and are included in the
# larger "subscription" events that also contain personal settings.
@@ -75,7 +75,6 @@ subscription_fields: Sequence[Tuple[str, object]] = [
("is_muted", bool),
("pin_to_top", bool),
("push_notifications", OptionalType(bool)),
- ("role", EnumType(Subscription.ROLE_TYPES)),
("stream_weekly_traffic", OptionalType(int)),
# We may try to remove subscribers from some events in
# the future for clients that don't want subscriber
diff --git a/zerver/lib/subscription_info.py b/zerver/lib/subscription_info.py
index 3f70083b9fb..c01e7520919 100644
--- a/zerver/lib/subscription_info.py
+++ b/zerver/lib/subscription_info.py
@@ -64,7 +64,6 @@ def get_web_public_subs(realm: Realm) -> SubscriptionInfo:
is_muted = False
pin_to_top = False
push_notifications = True
- role = Subscription.ROLE_MEMBER
stream_weekly_traffic = get_average_weekly_stream_traffic(
stream.id, stream.date_created, {}
)
@@ -90,7 +89,6 @@ def get_web_public_subs(realm: Realm) -> SubscriptionInfo:
pin_to_top=pin_to_top,
push_notifications=push_notifications,
rendered_description=rendered_description,
- role=role,
stream_id=stream_id,
stream_post_policy=stream_post_policy,
stream_weekly_traffic=stream_weekly_traffic,
@@ -133,7 +131,6 @@ def build_stream_dict_for_sub(
email_notifications = sub_dict["email_notifications"]
push_notifications = sub_dict["push_notifications"]
wildcard_mentions_notify = sub_dict["wildcard_mentions_notify"]
- role = sub_dict["role"]
# Backwards-compatibility for clients that haven't been
# updated for the in_home_view => is_muted API migration.
@@ -174,7 +171,6 @@ def build_stream_dict_for_sub(
pin_to_top=pin_to_top,
push_notifications=push_notifications,
rendered_description=rendered_description,
- role=role,
stream_id=stream_id,
stream_post_policy=stream_post_policy,
stream_weekly_traffic=stream_weekly_traffic,
diff --git a/zerver/lib/types.py b/zerver/lib/types.py
index 38931fa694f..381950bd208 100644
--- a/zerver/lib/types.py
+++ b/zerver/lib/types.py
@@ -166,7 +166,6 @@ class RawSubscriptionDict(TypedDict):
pin_to_top: bool
push_notifications: Optional[bool]
recipient_id: int
- role: int
wildcard_mentions_notify: Optional[bool]
@@ -196,7 +195,6 @@ class SubscriptionStreamDict(TypedDict):
pin_to_top: bool
push_notifications: Optional[bool]
rendered_description: str
- role: int
stream_id: int
stream_post_policy: int
stream_weekly_traffic: Optional[int]
@@ -255,7 +253,6 @@ class APISubscriptionDict(APIStreamDict):
is_muted: bool
pin_to_top: bool
push_notifications: Optional[bool]
- role: int
wildcard_mentions_notify: Optional[bool]
# Computed fields not specified in `Subscription.API_FIELDS`
email_address: str
diff --git a/zerver/migrations/0396_remove_subscription_role.py b/zerver/migrations/0396_remove_subscription_role.py
new file mode 100644
index 00000000000..d313f4061d8
--- /dev/null
+++ b/zerver/migrations/0396_remove_subscription_role.py
@@ -0,0 +1,17 @@
+# Generated by Django 3.2.13 on 2022-07-05 12:44
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("zerver", "0395_alter_realm_wildcard_mention_policy"),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name="subscription",
+ name="role",
+ ),
+ ]
diff --git a/zerver/models.py b/zerver/models.py
index dae0a7bafde..ac6207a7c14 100644
--- a/zerver/models.py
+++ b/zerver/models.py
@@ -3562,16 +3562,6 @@ class Subscription(models.Model):
# we may be creating Subscription objects for a user that's deactivated.
is_user_active: bool = models.BooleanField()
- ROLE_STREAM_ADMINISTRATOR = 20
- ROLE_MEMBER = 50
-
- ROLE_TYPES = [
- ROLE_STREAM_ADMINISTRATOR,
- ROLE_MEMBER,
- ]
-
- role: int = models.PositiveSmallIntegerField(default=ROLE_MEMBER, db_index=True)
-
# Whether this user had muted this stream.
is_muted: bool = models.BooleanField(default=False)
@@ -3623,7 +3613,6 @@ class Subscription(models.Model):
"is_muted",
"pin_to_top",
"push_notifications",
- "role",
"wildcard_mentions_notify",
]
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index 00475b1111c..efaa0c2c6d7 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -608,6 +608,9 @@ paths:
description: |
A list of dictionaries where each dictionary contains
information about one of the subscribed streams.
+
+ **Changes**: Removed `role` field from the dictionary
+ in Zulip 6.0 (feature level 133).
items:
$ref: "#/components/schemas/Subscriptions"
additionalProperties: false
@@ -6966,6 +6969,9 @@ paths:
description: |
A list of dictionaries where each dictionary contains
information about one of the subscribed streams.
+
+ **Changes**: Removed `role` field from the dictionary
+ in Zulip 6.0 (feature level 133).
items:
$ref: "#/components/schemas/Subscriptions"
example:
@@ -6985,7 +6991,6 @@ paths:
"name": "Denmark",
"pin_to_top": false,
"push_notifications": false,
- "role": 20,
"stream_id": 1,
"subscribers": [7, 10, 11, 12, 14],
},
@@ -7000,7 +7005,6 @@ paths:
"name": "Scotland",
"pin_to_top": false,
"push_notifications": false,
- "role": 50,
"stream_id": 3,
"subscribers": [7, 11, 12, 14],
},
@@ -9557,6 +9561,9 @@ paths:
A array of dictionaries where each dictionary describes the properties
of a stream the user is subscribed to (as well as that user's
personal per-stream settings).
+
+ **Changes**: Removed `role` field from the dictionary
+ in Zulip 6.0 (feature level 133).
unsubscribed:
type: array
items:
@@ -9570,6 +9577,9 @@ paths:
Unlike `never_subscribed`, the user might have messages in their personal
message history that were sent to these streams.
+
+ **Changes**: Removed `role` field from the dictionary
+ in Zulip 6.0 (feature level 133).
never_subscribed:
type: array
items:
@@ -15102,20 +15112,6 @@ components:
description: |
Whether the stream has been configured to allow unauthenticated
access to its message history from the web.
- role:
- type: integer
- enum:
- - 20
- - 50
- description: |
- The user's role within the stream (distinct from the user's
- [organization-level role](/help/roles-and-permissions)).
- Valid values are:
-
- - 20 => Stream administrator.
- - 50 => Subscriber.
-
- **Changes**: New in Zulip 4.0 (feature level 31).
color:
type: string
description: |
diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py
index a3e6013471e..be21433f9fb 100644
--- a/zerver/tests/test_subs.py
+++ b/zerver/tests/test_subs.py
@@ -29,7 +29,6 @@ from zerver.actions.streams import (
bulk_add_subscriptions,
bulk_remove_subscriptions,
do_change_stream_post_policy,
- do_change_subscription_property,
do_deactivate_stream,
)
from zerver.actions.users import do_change_user_role, do_deactivate_user
@@ -1601,13 +1600,8 @@ class StreamAdminTest(ZulipTestCase):
user_profile = self.example_user("hamlet")
self.login_user(user_profile)
- stream = self.subscribe(user_profile, "stream_name1")
- sub = get_subscription("stream_name1", user_profile)
-
+ self.subscribe(user_profile, "stream_name1")
do_change_user_role(user_profile, UserProfile.ROLE_MEMBER, acting_user=None)
- do_change_subscription_property(
- user_profile, sub, stream, "role", Subscription.ROLE_MEMBER, acting_user=None
- )
stream_id = get_stream("stream_name1", user_profile.realm).id
result = self.client_patch(
@@ -1658,12 +1652,8 @@ class StreamAdminTest(ZulipTestCase):
self.login_user(user_profile)
stream = self.subscribe(user_profile, "stream_name1")
- sub = get_subscription("stream_name1", user_profile)
do_change_user_role(user_profile, UserProfile.ROLE_MEMBER, acting_user=None)
- do_change_subscription_property(
- user_profile, sub, stream, "role", Subscription.ROLE_MEMBER, acting_user=None
- )
do_set_realm_property(user_profile.realm, "waiting_period_threshold", 10, acting_user=None)