Skip to content

Commit 48fb81b

Browse files
gnpricechrisbobbe
authored andcommitted
api: Cut ZulipStream.canRemoveSubscribersGroup as it changes format
This field is becoming a group-setting value. We haven't yet implemented those (that's #814), so we can no longer handle this field until we do that work. Conveniently we weren't actually making any use of this field, though -- so for now, just ignore it. Fixes: #1082
1 parent 6e5d454 commit 48fb81b

File tree

6 files changed

+2
-61
lines changed

6 files changed

+2
-61
lines changed

lib/api/model/model.dart

+1-11
Original file line numberDiff line numberDiff line change
@@ -342,19 +342,11 @@ class ZulipStream {
342342
ChannelPostPolicy channelPostPolicy;
343343
// final bool isAnnouncementOnly; // deprecated for `channelPostPolicy`; ignore
344344

345-
// TODO(server-6): `canRemoveSubscribersGroupId` added in FL 142
346-
// TODO(server-8): in FL 197 renamed to `canRemoveSubscribersGroup`
347-
@JsonKey(readValue: _readCanRemoveSubscribersGroup)
348-
int? canRemoveSubscribersGroup;
345+
// GroupSettingsValue canRemoveSubscribersGroup; // TODO(#814)
349346

350347
// TODO(server-8): added in FL 199, was previously only on [Subscription] objects
351348
int? streamWeeklyTraffic;
352349

353-
static int? _readCanRemoveSubscribersGroup(Map<dynamic, dynamic> json, String key) {
354-
return (json[key] as int?)
355-
?? (json['can_remove_subscribers_group_id'] as int?);
356-
}
357-
358350
ZulipStream({
359351
required this.streamId,
360352
required this.name,
@@ -367,7 +359,6 @@ class ZulipStream {
367359
required this.historyPublicToSubscribers,
368360
required this.messageRetentionDays,
369361
required this.channelPostPolicy,
370-
required this.canRemoveSubscribersGroup,
371362
required this.streamWeeklyTraffic,
372363
});
373364

@@ -478,7 +469,6 @@ class Subscription extends ZulipStream {
478469
required super.historyPublicToSubscribers,
479470
required super.messageRetentionDays,
480471
required super.channelPostPolicy,
481-
required super.canRemoveSubscribersGroup,
482472
required super.streamWeeklyTraffic,
483473
required this.desktopNotifications,
484474
required this.emailNotifications,

lib/api/model/model.g.dart

-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/model/channel.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ class ChannelStoreImpl with ChannelStore {
281281
stream.channelPostPolicy = event.value as ChannelPostPolicy;
282282
case ChannelPropertyName.canRemoveSubscribersGroup:
283283
case ChannelPropertyName.canRemoveSubscribersGroupId:
284-
stream.canRemoveSubscribersGroup = event.value as int?;
284+
break; // not tracking this property
285285
case ChannelPropertyName.streamWeeklyTraffic:
286286
stream.streamWeeklyTraffic = event.value as int?;
287287
}

test/api/model/model_checks.dart

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ extension UserChecks on Subject<User> {
2222
}
2323

2424
extension ZulipStreamChecks on Subject<ZulipStream> {
25-
Subject<int?> get canRemoveSubscribersGroup => has((e) => e.canRemoveSubscribersGroup, 'canRemoveSubscribersGroup');
2625
}
2726

2827
extension MessageChecks on Subject<Message> {

test/api/model/model_test.dart

-37
Original file line numberDiff line numberDiff line change
@@ -67,43 +67,6 @@ void main() {
6767
});
6868
});
6969

70-
group('ZulipStream.canRemoveSubscribersGroup', () {
71-
final Map<String, dynamic> baseJson = Map.unmodifiable({
72-
'stream_id': 123,
73-
'name': 'A stream',
74-
'description': 'A description',
75-
'rendered_description': '<p>A description</p>',
76-
'date_created': 1686774898,
77-
'first_message_id': null,
78-
'invite_only': false,
79-
'is_web_public': false,
80-
'history_public_to_subscribers': true,
81-
'message_retention_days': null,
82-
'stream_post_policy': ChannelPostPolicy.any.apiValue,
83-
// 'can_remove_subscribers_group': null,
84-
'stream_weekly_traffic': null,
85-
});
86-
87-
test('smoke', () {
88-
check(ZulipStream.fromJson({ ...baseJson,
89-
'can_remove_subscribers_group': 123,
90-
})).canRemoveSubscribersGroup.equals(123);
91-
});
92-
93-
// TODO(server-8): field renamed in FL 197
94-
test('support old can_remove_subscribers_group_id', () {
95-
check(ZulipStream.fromJson({ ...baseJson,
96-
'can_remove_subscribers_group_id': 456,
97-
})).canRemoveSubscribersGroup.equals(456);
98-
});
99-
100-
// TODO(server-6): field added in FL 142
101-
test('support field missing', () {
102-
check(ZulipStream.fromJson({ ...baseJson,
103-
})).canRemoveSubscribersGroup.isNull();
104-
});
105-
});
106-
10770
group('Subscription', () {
10871
test('converts color to int', () {
10972
Subscription subWithColor(String color) {

test/example_data.dart

-3
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ ZulipStream stream({
212212
bool? historyPublicToSubscribers,
213213
int? messageRetentionDays,
214214
ChannelPostPolicy? channelPostPolicy,
215-
int? canRemoveSubscribersGroup,
216215
int? streamWeeklyTraffic,
217216
}) {
218217
_checkPositive(streamId, 'stream ID');
@@ -232,7 +231,6 @@ ZulipStream stream({
232231
historyPublicToSubscribers: historyPublicToSubscribers ?? true,
233232
messageRetentionDays: messageRetentionDays,
234233
channelPostPolicy: channelPostPolicy ?? ChannelPostPolicy.any,
235-
canRemoveSubscribersGroup: canRemoveSubscribersGroup ?? 123,
236234
streamWeeklyTraffic: streamWeeklyTraffic,
237235
);
238236
}
@@ -270,7 +268,6 @@ Subscription subscription(
270268
historyPublicToSubscribers: stream.historyPublicToSubscribers,
271269
messageRetentionDays: stream.messageRetentionDays,
272270
channelPostPolicy: stream.channelPostPolicy,
273-
canRemoveSubscribersGroup: stream.canRemoveSubscribersGroup,
274271
streamWeeklyTraffic: stream.streamWeeklyTraffic,
275272
desktopNotifications: desktopNotifications ?? false,
276273
emailNotifications: emailNotifications ?? false,

0 commit comments

Comments
 (0)