Skip to content

Commit 916319b

Browse files
committed
api: Update Subscription for API changes
Remove `emailAddress` field per update in FL 226. Rename `canRemoveSubscribersGroupId`. Also change `isWebPublic` to be non-null. It has been a field on subscriptions since at least FL 8 (see zulip/zulip@f93c19ec6 in `zerver/openapi/zulip.yaml` and the docs attached to `Subscription.API_FIELDS` in `zerver/models.py`).
1 parent 015130a commit 916319b

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

lib/api/model/model.dart

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,16 +326,18 @@ class Subscription {
326326
final int? streamWeeklyTraffic;
327327

328328
final bool inviteOnly;
329-
final bool? isWebPublic; // TODO(server-??): doc doesn't say when added
329+
final bool isWebPublic;
330330
final bool historyPublicToSubscribers;
331331
final int? messageRetentionDays;
332332
// final List<int> subscribers; // we register with includeSubscribers false
333333

334334
final StreamPostPolicy streamPostPolicy;
335335
// final bool? isAnnouncementOnly; // deprecated for `streamPostPolicy`; ignore
336-
final String emailAddress;
337336

338-
final int? canRemoveSubscribersGroupId; // TODO(server-6)
337+
// TODO(server-6): `canRemoveSubscribersGroupId` added in FL 142
338+
// TODO(server-8): in FL 197 renamed to `canRemoveSubscribersGroup`
339+
@JsonKey(readValue: _readCanRemoveSubscribersGroup)
340+
final int? canRemoveSubscribersGroup;
339341

340342
// Then, fields that are specific to the subscription,
341343
// i.e. the user's relationship to the stream.
@@ -353,6 +355,10 @@ class Subscription {
353355

354356
final String color;
355357

358+
static int? _readCanRemoveSubscribersGroup(Map json, String key) {
359+
return json[key] ?? json['can_remove_subscribers_group_id'];
360+
}
361+
356362
Subscription({
357363
required this.streamId,
358364
required this.name,
@@ -366,7 +372,6 @@ class Subscription {
366372
required this.pushNotifications,
367373
required this.audibleNotifications,
368374
required this.pinToTop,
369-
required this.emailAddress,
370375
required this.isMuted,
371376
required this.isWebPublic,
372377
required this.color,
@@ -375,7 +380,7 @@ class Subscription {
375380
required this.historyPublicToSubscribers,
376381
required this.firstMessageId,
377382
required this.streamWeeklyTraffic,
378-
required this.canRemoveSubscribersGroupId,
383+
required this.canRemoveSubscribersGroup,
379384
});
380385

381386
factory Subscription.fromJson(Map<String, dynamic> json) =>

lib/api/model/model.g.dart

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

0 commit comments

Comments
 (0)