Skip to content

Commit a5e47f3

Browse files
committed
wip and finish selfHasContentAccess
1 parent 25afacd commit a5e47f3

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lib/model/channel.dart

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,19 @@ mixin ChannelStore on UserStore {
140140
}
141141
}
142142

143-
bool selfCanSubscribe(int channelId) {
144-
// Compare web's stream_data.has_content_access_via_group_permissions.
143+
bool selfHasContentAccess(ZulipStream channel) {
144+
// Compare web's stream_data.has_content_access.
145+
if (channel.isWebPublic) return true;
146+
if (channel is Subscription) return true;
147+
// Here web calls has_metadata_access... but that always returns true,
148+
// as its comment says.
145149
if (selfUser.role == UserRole.guest) return false;
146-
final channel = streams[channelId];
147-
if (channel == null) return false;
148150
if (!channel.inviteOnly) return true;
151+
return _selfHasContentAccessViaGroupPermissions(channel);
152+
}
153+
154+
bool _selfHasContentAccessViaGroupPermissions(ZulipStream channel) {
155+
// Compare web's stream_data.has_content_access_via_group_permissions.
149156
return selfHasPermissionForGroupSetting(channel.canAddSubscribersGroup,
150157
GroupSettingType.group, 'can_add_subscribers_group')
151158
|| selfHasPermissionForGroupSetting(channel.canSubscribeGroup,

0 commit comments

Comments
 (0)