Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
streams: Add role field to Subscription objects passed to clients.
sahil839f046c9c58a24
diff --git a/frontend_tests/node_tests/lib/events.js b/frontend_tests/node_tests/lib/events.jsindex 5149a817555..95755a17f4d 100644--- a/frontend_tests/node_tests/lib/events.js+++ b/frontend_tests/node_tests/lib/events.js@@ -513,6 +513,7 @@ 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.mdindex 727af3f2919..b4fd13ecf92 100644--- a/templates/zerver/api/changelog.md+++ b/templates/zerver/api/changelog.md@@ -10,6 +10,19 @@ below features are supported.## Changes in Zulip 4.0+**Feature level 31**++* [`GET users/me/subscriptions`](/api/get-subscriptions): Added a+ `role` field to Subscription objects representing whether the user+ is a stream administrator.++* [`GET /events`](/api/get-events): Added `role` field to+ Subscription objects sent in `subscriptions` events.++Note that as of this feature level, stream administrators are a+partially completed feature. In particular, it is impossible for a+user to be a stream administrator at this feature level.+**Feature Level 30*** [`GET users/me/subscriptions`](/api/get-subscriptions), [`GETdiff --git a/version.py b/version.pyindex 2caf75048cf..f49ea4a08c4 100644--- a/version.py+++ b/version.py@@ -29,7 +29,7 @@ DESKTOP_WARNING_VERSION = "5.2.0"## Changes should be accompanied by documentation explaining what the# new level means in templates/zerver/api/changelog.md.-API_FEATURE_LEVEL = 30+API_FEATURE_LEVEL = 31# 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. Bumpdiff --git a/zerver/lib/event_schema.py b/zerver/lib/event_schema.pyindex 9a68f8338d5..414f97648ce 100644--- a/zerver/lib/event_schema.py+++ b/zerver/lib/event_schema.py@@ -22,7 +22,7 @@ from zerver.lib.validator import (check_url,equals,)-from zerver.models import Realm, Stream, UserProfile+from zerver.models import Realm, Stream, Subscription, UserProfile# These fields are used for "stream" events, and are included in the# larger "subscription" events that also contain personal settings.@@ -50,6 +50,7 @@ subscription_fields: Sequence[Tuple[str, Validator[object]]] = [("email_notifications", check_none_or(check_bool)),("in_home_view", check_bool),("is_muted", check_bool),+ ("role", check_int_in(Subscription.ROLE_TYPES)),("pin_to_top", check_bool),("push_notifications", check_none_or(check_bool)),("stream_weekly_traffic", check_none_or(check_int)),diff --git a/zerver/models.py b/zerver/models.pyindex 3da326e1f38..57452c0f9e7 100644--- a/zerver/models.py+++ b/zerver/models.py@@ -2252,6 +2252,11 @@ class Subscription(models.Model):ROLE_STREAM_ADMINISTRATOR = 20ROLE_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.@@ -2304,6 +2309,7 @@ class Subscription(models.Model):"email_notifications","push_notifications","wildcard_mentions_notify",+ "role",]@cache_with_key(user_profile_by_id_cache_key, timeout=3600*24*7)diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yamlindex 7687234f20c..42e5e0658ed 100644--- a/zerver/openapi/zulip.yaml+++ b/zerver/openapi/zulip.yaml@@ -4513,6 +4513,7 @@ paths:"name": "Denmark","pin_to_top": false,"push_notifications": false,+ "role": 20,"stream_id": 1,"subscribers": [7, 10, 11, 12, 14],},@@ -4527,6 +4528,7 @@ paths:"name": "Scotland","pin_to_top": false,"push_notifications": false,+ "role": 50,"stream_id": 3,"subscribers": [7, 11, 12, 14],},@@ -8751,6 +8753,17 @@ components:description: |Whether the stream has been configured to allow unauthenticatedaccess to its message history from the web.+ role:+ type: integer+ 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: stringdescription: |