mirror of https://github.com/zulip/zulip.git
streams: Add role field to Subscription objects passed to clients.
This commit adds "role" field to the Subscription objects passed to clients. This is important preparation for being able to work on the frontend for this feature.
This commit is contained in:
parent
88821b960a
commit
f046c9c58a
|
@ -513,6 +513,7 @@ exports.fixtures = {
|
||||||
push_notifications: false,
|
push_notifications: false,
|
||||||
stream_weekly_traffic: 40,
|
stream_weekly_traffic: 40,
|
||||||
wildcard_mentions_notify: false,
|
wildcard_mentions_notify: false,
|
||||||
|
role: 20,
|
||||||
subscribers: [5, 8, 13, 21],
|
subscribers: [5, 8, 13, 21],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -10,6 +10,19 @@ below features are supported.
|
||||||
|
|
||||||
## Changes in Zulip 4.0
|
## 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**
|
**Feature Level 30**
|
||||||
|
|
||||||
* [`GET users/me/subscriptions`](/api/get-subscriptions), [`GET
|
* [`GET users/me/subscriptions`](/api/get-subscriptions), [`GET
|
||||||
|
|
|
@ -29,7 +29,7 @@ DESKTOP_WARNING_VERSION = "5.2.0"
|
||||||
#
|
#
|
||||||
# Changes should be accompanied by documentation explaining what the
|
# Changes should be accompanied by documentation explaining what the
|
||||||
# new level means in templates/zerver/api/changelog.md.
|
# 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
|
# 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
|
# only when going from an old version of the code to a newer version. Bump
|
||||||
|
|
|
@ -22,7 +22,7 @@ from zerver.lib.validator import (
|
||||||
check_url,
|
check_url,
|
||||||
equals,
|
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
|
# These fields are used for "stream" events, and are included in the
|
||||||
# larger "subscription" events that also contain personal settings.
|
# 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)),
|
("email_notifications", check_none_or(check_bool)),
|
||||||
("in_home_view", check_bool),
|
("in_home_view", check_bool),
|
||||||
("is_muted", check_bool),
|
("is_muted", check_bool),
|
||||||
|
("role", check_int_in(Subscription.ROLE_TYPES)),
|
||||||
("pin_to_top", check_bool),
|
("pin_to_top", check_bool),
|
||||||
("push_notifications", check_none_or(check_bool)),
|
("push_notifications", check_none_or(check_bool)),
|
||||||
("stream_weekly_traffic", check_none_or(check_int)),
|
("stream_weekly_traffic", check_none_or(check_int)),
|
||||||
|
|
|
@ -2252,6 +2252,11 @@ class Subscription(models.Model):
|
||||||
ROLE_STREAM_ADMINISTRATOR = 20
|
ROLE_STREAM_ADMINISTRATOR = 20
|
||||||
ROLE_MEMBER = 50
|
ROLE_MEMBER = 50
|
||||||
|
|
||||||
|
ROLE_TYPES = [
|
||||||
|
ROLE_STREAM_ADMINISTRATOR,
|
||||||
|
ROLE_MEMBER,
|
||||||
|
]
|
||||||
|
|
||||||
role: int = models.PositiveSmallIntegerField(default=ROLE_MEMBER, db_index=True)
|
role: int = models.PositiveSmallIntegerField(default=ROLE_MEMBER, db_index=True)
|
||||||
|
|
||||||
# Whether this user had muted this stream.
|
# Whether this user had muted this stream.
|
||||||
|
@ -2304,6 +2309,7 @@ class Subscription(models.Model):
|
||||||
"email_notifications",
|
"email_notifications",
|
||||||
"push_notifications",
|
"push_notifications",
|
||||||
"wildcard_mentions_notify",
|
"wildcard_mentions_notify",
|
||||||
|
"role",
|
||||||
]
|
]
|
||||||
|
|
||||||
@cache_with_key(user_profile_by_id_cache_key, timeout=3600*24*7)
|
@cache_with_key(user_profile_by_id_cache_key, timeout=3600*24*7)
|
||||||
|
|
|
@ -4513,6 +4513,7 @@ paths:
|
||||||
"name": "Denmark",
|
"name": "Denmark",
|
||||||
"pin_to_top": false,
|
"pin_to_top": false,
|
||||||
"push_notifications": false,
|
"push_notifications": false,
|
||||||
|
"role": 20,
|
||||||
"stream_id": 1,
|
"stream_id": 1,
|
||||||
"subscribers": [7, 10, 11, 12, 14],
|
"subscribers": [7, 10, 11, 12, 14],
|
||||||
},
|
},
|
||||||
|
@ -4527,6 +4528,7 @@ paths:
|
||||||
"name": "Scotland",
|
"name": "Scotland",
|
||||||
"pin_to_top": false,
|
"pin_to_top": false,
|
||||||
"push_notifications": false,
|
"push_notifications": false,
|
||||||
|
"role": 50,
|
||||||
"stream_id": 3,
|
"stream_id": 3,
|
||||||
"subscribers": [7, 11, 12, 14],
|
"subscribers": [7, 11, 12, 14],
|
||||||
},
|
},
|
||||||
|
@ -8751,6 +8753,17 @@ components:
|
||||||
description: |
|
description: |
|
||||||
Whether the stream has been configured to allow unauthenticated
|
Whether the stream has been configured to allow unauthenticated
|
||||||
access to its message history from the web.
|
access 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:
|
color:
|
||||||
type: string
|
type: string
|
||||||
description: |
|
description: |
|
||||||
|
|
Loading…
Reference in New Issue