-
Notifications
You must be signed in to change notification settings - Fork 354
api: Add ZulipStream.topicsPolicy #1956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,6 +90,8 @@ class InitialSnapshot { | |
| /// Search for "realm_wildcard_mention_policy" in https://zulip.com/api/register-queue. | ||
| final RealmWildcardMentionPolicy realmWildcardMentionPolicy; | ||
|
|
||
| final RealmTopicsPolicy realmTopicsPolicy; | ||
|
|
||
| final bool realmMandatoryTopics; | ||
|
|
||
| final String realmName; | ||
|
|
@@ -183,6 +185,7 @@ class InitialSnapshot { | |
| required this.realmCanDeleteOwnMessageGroup, | ||
| required this.realmDeleteOwnMessagePolicy, | ||
| required this.realmWildcardMentionPolicy, | ||
| required this.realmTopicsPolicy, | ||
| required this.realmMandatoryTopics, | ||
| required this.realmName, | ||
| required this.realmWaitingPeriodThreshold, | ||
|
|
@@ -207,6 +210,22 @@ class InitialSnapshot { | |
| Map<String, dynamic> toJson() => _$InitialSnapshotToJson(this); | ||
| } | ||
|
|
||
| /// A value of [InitialSnapshot.realmTopicsPolicy]. | ||
| /// | ||
| /// For docs, search for "realm_topics_policy" | ||
| /// in <https://zulip.com/api/register-queue#response>. | ||
| @JsonEnum(fieldRename: FieldRename.snake) | ||
| enum RealmTopicsPolicy { | ||
chungwwei marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| allowEmptyTopic, | ||
| disableEmptyTopic; | ||
|
|
||
| static RealmTopicsPolicy fromApiValue(String apiValue)=> _byApiValue[apiValue] ?? allowEmptyTopic; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of handling unknown values here, let's make an explicit |
||
|
|
||
| static final _byApiValue = _$RealmTopicsPolicyEnumMap.map((key, value) => MapEntry(value, key)); | ||
chungwwei marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| String toJson() => _$RealmTopicsPolicyEnumMap[this]!; | ||
| } | ||
|
|
||
| @JsonEnum(valueField: 'apiValue') | ||
| enum RealmWildcardMentionPolicy { | ||
| everyone(apiValue: 1), | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -659,6 +659,8 @@ class ZulipStream { | |
| bool isWebPublic; // present since 2.1, according to /api/changelog | ||
| bool historyPublicToSubscribers; | ||
| int? messageRetentionDays; | ||
| @JsonKey(defaultValue: TopicsPolicy.inherit) // TODO(server-11) remove default value | ||
| TopicsPolicy topicsPolicy; | ||
| @JsonKey(name: 'stream_post_policy') | ||
| ChannelPostPolicy? channelPostPolicy; // TODO(server-10) remove | ||
| // final bool isAnnouncementOnly; // deprecated for `channelPostPolicy`; ignore | ||
|
|
@@ -684,6 +686,7 @@ class ZulipStream { | |
| required this.isWebPublic, | ||
| required this.historyPublicToSubscribers, | ||
| required this.messageRetentionDays, | ||
| required this.topicsPolicy, | ||
| required this.channelPostPolicy, | ||
| required this.folderId, | ||
| required this.canAddSubscribersGroup, | ||
|
|
@@ -708,6 +711,7 @@ class ZulipStream { | |
| isWebPublic: subscription.isWebPublic, | ||
| historyPublicToSubscribers: subscription.historyPublicToSubscribers, | ||
| messageRetentionDays: subscription.messageRetentionDays, | ||
| topicsPolicy: subscription.topicsPolicy, | ||
| channelPostPolicy: subscription.channelPostPolicy, | ||
| folderId: subscription.folderId, | ||
| canAddSubscribersGroup: subscription.canAddSubscribersGroup, | ||
|
|
@@ -744,6 +748,7 @@ enum ChannelPropertyName { | |
| // isWebPublic is updated via its own [ChannelUpdateEvent] field | ||
| // historyPublicToSubscribers is updated via its own [ChannelUpdateEvent] field | ||
| messageRetentionDays, | ||
| topicsPolicy, | ||
| @JsonValue('stream_post_policy') | ||
| channelPostPolicy, | ||
| folderId, | ||
|
|
@@ -765,6 +770,24 @@ enum ChannelPropertyName { | |
| .map((key, value) => MapEntry(value, key)); | ||
| } | ||
|
|
||
| /// A value of [ZulipStream.topicsPolicy]. | ||
| /// | ||
| /// For docs, search for "topics_policy" | ||
| /// in <https://zulip.com/api/get-stream-by-id>. | ||
| @JsonEnum(fieldRename: FieldRename.snake) | ||
| enum TopicsPolicy { | ||
chungwwei marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| inherit, | ||
| allowEmptyTopic, | ||
| disableEmptyTopic, | ||
| emptyTopicOnly; | ||
|
|
||
| static TopicsPolicy fromApiValue(String apiValue) => _byApiValue[apiValue] ?? inherit; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Similarly here, let's use an explicit |
||
|
|
||
| static final _byApiValue = _$TopicsPolicyEnumMap.map((key, value) => MapEntry(value, key)); | ||
|
|
||
| String toJson() => _$TopicsPolicyEnumMap[this]!; | ||
| } | ||
|
|
||
| /// Policy for which users can post to the stream. | ||
| /// | ||
| /// For docs, search for "stream_post_policy" | ||
|
|
@@ -830,6 +853,7 @@ class Subscription extends ZulipStream { | |
| required super.isWebPublic, | ||
| required super.historyPublicToSubscribers, | ||
| required super.messageRetentionDays, | ||
| required super.topicsPolicy, | ||
| required super.channelPostPolicy, | ||
| required super.folderId, | ||
| required super.canAddSubscribersGroup, | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.