File tree 3 files changed +35
-5
lines changed 3 files changed +35
-5
lines changed Original file line number Diff line number Diff line change @@ -249,8 +249,8 @@ class ZulipStream {
249
249
final bool historyPublicToSubscribers;
250
250
final int ? messageRetentionDays;
251
251
252
- final int streamPostPolicy; // TODO enum
253
- // final bool isAnnouncementOnly; // deprecated; ignore
252
+ final StreamPostPolicy streamPostPolicy;
253
+ // final bool isAnnouncementOnly; // deprecated for `streamPostPolicy` ; ignore
254
254
255
255
final int ? canRemoveSubscribersGroupId; // TODO(server-6)
256
256
@@ -275,6 +275,27 @@ class ZulipStream {
275
275
Map <String , dynamic > toJson () => _$ZulipStreamToJson (this );
276
276
}
277
277
278
+ /// Policy for which users can post to the stream.
279
+ ///
280
+ /// For docs, search for "stream_post_policy"
281
+ /// in <https://zulip.com/api/get-stream-by-id>
282
+ @JsonEnum (valueField: 'apiValue' )
283
+ enum StreamPostPolicy {
284
+ any (apiValue: 1 ),
285
+ admin (apiValue: 2 ),
286
+ member (apiValue: 3 ),
287
+ moderator (apiValue: 4 ),
288
+ unknown (apiValue: null );
289
+
290
+ const StreamPostPolicy ({
291
+ required this .apiValue,
292
+ });
293
+
294
+ final int ? apiValue;
295
+
296
+ int ? toJson () => apiValue;
297
+ }
298
+
278
299
/// As in `subscriptions` in the initial snapshot.
279
300
///
280
301
/// For docs, search for "subscriptions:"
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ ZulipStream stream({
103
103
bool ? isWebPublic,
104
104
bool ? historyPublicToSubscribers,
105
105
int ? messageRetentionDays,
106
- int ? streamPostPolicy,
106
+ StreamPostPolicy ? streamPostPolicy,
107
107
int ? canRemoveSubscribersGroupId,
108
108
}) {
109
109
return ZulipStream (
@@ -117,7 +117,7 @@ ZulipStream stream({
117
117
isWebPublic: isWebPublic ?? false ,
118
118
historyPublicToSubscribers: historyPublicToSubscribers ?? true ,
119
119
messageRetentionDays: messageRetentionDays,
120
- streamPostPolicy: streamPostPolicy ?? 1 ,
120
+ streamPostPolicy: streamPostPolicy ?? StreamPostPolicy .any ,
121
121
canRemoveSubscribersGroupId: canRemoveSubscribersGroupId ?? 123 ,
122
122
);
123
123
}
You can’t perform that action at this time.
0 commit comments