Skip to content

Commit e9c49c7

Browse files
committed
channel: Make channelPostPolicy optional, because deprecated
1 parent 7b75c3a commit e9c49c7

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

lib/api/model/model.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ class ZulipStream {
649649
bool historyPublicToSubscribers;
650650
int? messageRetentionDays;
651651
@JsonKey(name: 'stream_post_policy')
652-
ChannelPostPolicy channelPostPolicy;
652+
ChannelPostPolicy? channelPostPolicy; // TODO(server-10) remove
653653
// final bool isAnnouncementOnly; // deprecated for `channelPostPolicy`; ignore
654654

655655
GroupSettingValue? canAddSubscribersGroup; // TODO(server-10)

lib/api/model/model.g.dart

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

lib/model/channel.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,21 +198,25 @@ mixin ChannelStore on UserStore {
198198
if (inChannel.canSendMessageGroup != null) {
199199
return selfHasPermissionForGroupSetting(inChannel.canSendMessageGroup!,
200200
GroupSettingType.stream, 'can_send_message_group');
201-
} else {
201+
} else if (inChannel.channelPostPolicy != null) {
202202
return _selfPassesLegacyChannelPostPolicy(inChannel: inChannel, atDate: byDate);
203+
} else {
204+
assert(false); // TODO(log)
205+
return true;
203206
}
204207
}
205208

206209
bool _selfPassesLegacyChannelPostPolicy({
207210
required ZulipStream inChannel,
208211
required DateTime atDate,
209212
}) {
213+
assert(inChannel.channelPostPolicy != null);
210214
final role = selfUser.role;
211215
// We let the users with [unknown] role to send the message, then the server
212216
// will decide to accept it or not based on its actual role.
213217
if (role == UserRole.unknown) return true;
214218

215-
switch (inChannel.channelPostPolicy) {
219+
switch (inChannel.channelPostPolicy!) {
216220
case ChannelPostPolicy.any: return true;
217221
case ChannelPostPolicy.fullMembers: {
218222
if (!role.isAtLeast(UserRole.member)) return false;

0 commit comments

Comments
 (0)