Skip to content

Commit a147f52

Browse files
committed
api: Add streams list in initial snapshot
1 parent ddbb34d commit a147f52

5 files changed

Lines changed: 90 additions & 0 deletions

File tree

lib/api/model/initial_snapshot.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ part 'initial_snapshot.g.dart';
77
// https://zulip.com/api/register-queue#response
88
@JsonSerializable(fieldRename: FieldRename.snake)
99
class InitialSnapshot {
10+
// Keep these fields in the order they appear in the API docs.
11+
// (For many API types we choose a more logical order than the docs.
12+
// But this one is so long that that'd make it become impossible to
13+
// compare the lists by hand.)
14+
1015
final String? queueId;
1116
final int lastEventId;
1217
final int zulipFeatureLevel;
@@ -21,6 +26,8 @@ class InitialSnapshot {
2126

2227
final List<Subscription> subscriptions;
2328

29+
final List<ZulipStream> streams;
30+
2431
final int maxFileUploadSizeMib;
2532

2633
@JsonKey(readValue: _readUsersIsActiveFallbackTrue)
@@ -31,6 +38,7 @@ class InitialSnapshot {
3138
final List<User> crossRealmBots;
3239

3340
// TODO etc., etc.
41+
// If adding fields, keep them all in the order they appear in the API docs.
3442

3543
// `is_active` is sometimes absent:
3644
// https://chat.zulip.org/#narrow/stream/412-api-documentation/topic/.60is_active.60.20in.20.60.2Fregister.60.20response/near/1371603
@@ -59,6 +67,7 @@ class InitialSnapshot {
5967
required this.alertWords,
6068
required this.customProfileFields,
6169
required this.subscriptions,
70+
required this.streams,
6271
required this.maxFileUploadSizeMib,
6372
required this.realmUsers,
6473
required this.realmNonActiveUsers,

lib/api/model/initial_snapshot.g.dart

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/api/model/model.dart

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,50 @@ class User {
118118
Map<String, dynamic> toJson() => _$UserToJson(this);
119119
}
120120

121+
/// As in `streams` in the initial snapshot.
122+
///
123+
/// Not called `Stream` because dart:async uses that name.
124+
@JsonSerializable(fieldRename: FieldRename.snake)
125+
class ZulipStream {
126+
final int streamId;
127+
final String name;
128+
final String description;
129+
final String renderedDescription;
130+
131+
final int dateCreated;
132+
final int? firstMessageId;
133+
134+
final bool inviteOnly;
135+
final bool isWebPublic;
136+
final bool historyPublicToSubscribers;
137+
final int? messageRetentionDays;
138+
139+
final int streamPostPolicy; // TODO enum
140+
// final bool isAnnouncementOnly; // deprecated; ignore
141+
142+
final int? canRemoveSubscribersGroupId; // TODO(server-6)
143+
144+
ZulipStream({
145+
required this.streamId,
146+
required this.name,
147+
required this.description,
148+
required this.renderedDescription,
149+
required this.dateCreated,
150+
required this.firstMessageId,
151+
required this.inviteOnly,
152+
required this.isWebPublic,
153+
required this.historyPublicToSubscribers,
154+
required this.messageRetentionDays,
155+
required this.streamPostPolicy,
156+
required this.canRemoveSubscribersGroupId,
157+
});
158+
159+
factory ZulipStream.fromJson(Map<String, dynamic> json) =>
160+
_$ZulipStreamFromJson(json);
161+
162+
Map<String, dynamic> toJson() => _$ZulipStreamToJson(this);
163+
}
164+
121165
/// As in `subscriptions` in the initial snapshot.
122166
@JsonSerializable(fieldRename: FieldRename.snake)
123167
class Subscription {

lib/api/model/model.g.dart

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/example_data.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ final InitialSnapshot initialSnapshot = InitialSnapshot(
109109
alertWords: ['klaxon'],
110110
customProfileFields: [],
111111
subscriptions: [], // TODO add subscriptions to example initial snapshot
112+
streams: [], // TODO add streams to example initial snapshot
112113
maxFileUploadSizeMib: 25,
113114
realmUsers: [],
114115
realmNonActiveUsers: [],

0 commit comments

Comments
 (0)