Skip to content
Merged
5 changes: 5 additions & 0 deletions lib/api/model/events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,9 @@ class ChannelUpdateEvent extends ChannelEvent {
final value = json['value'];
switch (ChannelPropertyName.fromRawString(json['property'] as String)) {
case ChannelPropertyName.name:
return value as String;
case ChannelPropertyName.isArchived:
return value as bool;
case ChannelPropertyName.description:
return value as String;
case ChannelPropertyName.firstMessageId:
Expand All @@ -675,6 +678,8 @@ class ChannelUpdateEvent extends ChannelEvent {
case ChannelPropertyName.channelPostPolicy:
return ChannelPostPolicy.fromApiValue(value as int);
case ChannelPropertyName.canAddSubscribersGroup:
case ChannelPropertyName.canDeleteAnyMessageGroup:
case ChannelPropertyName.canDeleteOwnMessageGroup:
case ChannelPropertyName.canSubscribeGroup:
return GroupSettingValue.fromJson(value);
case ChannelPropertyName.streamWeeklyTraffic:
Expand Down
3 changes: 3 additions & 0 deletions lib/api/model/events.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

168 changes: 167 additions & 1 deletion lib/api/model/initial_snapshot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ class InitialSnapshot {

final List<UserTopicItem>? userTopics; // TODO(server-6)

final GroupSettingValue? realmCanDeleteAnyMessageGroup; // TODO(server-10)

final GroupSettingValue? realmCanDeleteOwnMessageGroup; // TODO(server-10)

/// The policy for who can delete their own messages,
/// on supported servers below version 10.
///
/// Removed in FL 291, so absent in the current API doc;
/// see zulip/zulip@0cd51f2fe.
final RealmDeleteOwnMessagePolicy? realmDeleteOwnMessagePolicy; // TODO(server-10)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be delete_own_message_policy and not realm_delete_own_message_policy?
(Docs only has mention of the former.)

Copy link
Collaborator Author

@chrisbobbe chrisbobbe Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I should add a note that this relies on information that isn't in the current doc; I had to look at zulip/zulip@0cd51f2fe, which removed the entry for realm_delete_own_message_policy in the register-response doc.

In general there's a pattern for realm attributes where the field in the register response is prefixed with realm_ but the field in the realm/update_dict event isn't.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the added note (with the reference to that zulip/zulip commit) appears in a later commit


/// The policy for who can use wildcard mentions in large channels.
///
/// Search for "realm_wildcard_mention_policy" in https://zulip.com/api/register-queue.
Expand All @@ -87,6 +98,8 @@ class InitialSnapshot {
/// https://zulip.com/api/roles-and-permissions#determining-if-a-user-is-a-full-member
final int realmWaitingPeriodThreshold;

final int? realmMessageContentDeleteLimitSeconds;

final bool realmAllowMessageEditing;
final int? realmMessageContentEditLimitSeconds;

Expand Down Expand Up @@ -158,9 +171,13 @@ class InitialSnapshot {
required this.userStatuses,
required this.userSettings,
required this.userTopics,
required this.realmCanDeleteAnyMessageGroup,
required this.realmCanDeleteOwnMessageGroup,
required this.realmDeleteOwnMessagePolicy,
required this.realmWildcardMentionPolicy,
required this.realmMandatoryTopics,
required this.realmWaitingPeriodThreshold,
required this.realmMessageContentDeleteLimitSeconds,
required this.realmAllowMessageEditing,
required this.realmMessageContentEditLimitSeconds,
required this.realmEnableReadReceipts,
Expand Down Expand Up @@ -196,6 +213,21 @@ enum RealmWildcardMentionPolicy {
int? toJson() => apiValue;
}

@JsonEnum(valueField: 'apiValue')
enum RealmDeleteOwnMessagePolicy {
members(apiValue: 1),
admins(apiValue: 2),
fullMembers(apiValue: 3),
moderators(apiValue: 4),
everyone(apiValue: 5);

const RealmDeleteOwnMessagePolicy({required this.apiValue});

final int apiValue;

int toJson() => apiValue;
}

/// An item in `realm_default_external_accounts`.
///
/// For docs, search for "realm_default_external_accounts:"
Expand Down Expand Up @@ -425,7 +457,141 @@ class SupportedPermissionSettings {
/// or a similar API, and switch to using that. See thread:
/// https://chat.zulip.org/#narrow/channel/378-api-design/topic/server_supported_permission_settings/near/2247549
static SupportedPermissionSettings fixture = SupportedPermissionSettings(
realm: {}, // Please go ahead and fill this in when we come to need it.
realm: {
// From the server's Realm.REALM_PERMISSION_GROUP_SETTINGS,
// in zerver/models/realms.py. Current as of 6ab30fcce, 2025-08.
'create_multiuse_invite_group': PermissionSettingsItem(
// allow_nobody_group=True,
allowEveryoneGroup: false,
// default_group_name=SystemGroups.ADMINISTRATORS,
),
'can_access_all_users_group': PermissionSettingsItem(
// require_system_group=True,
// allow_nobody_group=False,
allowEveryoneGroup: true,
// default_group_name=SystemGroups.EVERYONE,
// # Note that user_can_access_all_other_users in the web
// # app is relying on members always have access.
// allowed_system_groups=[SystemGroups.EVERYONE, SystemGroups.MEMBERS],
),
'can_add_subscribers_group': PermissionSettingsItem(
// allow_nobody_group=True,
allowEveryoneGroup: false,
// default_group_name=SystemGroups.MEMBERS,
),
'can_add_custom_emoji_group': PermissionSettingsItem(
// allow_nobody_group=True,
allowEveryoneGroup: false,
// default_group_name=SystemGroups.MEMBERS,
),
'can_create_bots_group': PermissionSettingsItem(
// allow_nobody_group=True,
allowEveryoneGroup: false,
// default_group_name=SystemGroups.MEMBERS,
),
'can_create_groups': PermissionSettingsItem(
// allow_nobody_group=True,
allowEveryoneGroup: false,
// default_group_name=SystemGroups.MEMBERS,
),
'can_create_public_channel_group': PermissionSettingsItem(
// allow_nobody_group=True,
allowEveryoneGroup: false,
// default_group_name=SystemGroups.MEMBERS,
),
'can_create_private_channel_group': PermissionSettingsItem(
// allow_nobody_group=True,
allowEveryoneGroup: false,
// default_group_name=SystemGroups.MEMBERS,
),
'can_create_web_public_channel_group': PermissionSettingsItem(
// require_system_group=True,
// allow_nobody_group=True,
allowEveryoneGroup: false,
// default_group_name=SystemGroups.OWNERS,
// allowed_system_groups=[
// SystemGroups.MODERATORS,
// SystemGroups.ADMINISTRATORS,
// SystemGroups.OWNERS,
// SystemGroups.NOBODY,
// ],
),
'can_create_write_only_bots_group': PermissionSettingsItem(
// allow_nobody_group=True,
allowEveryoneGroup: false,
// default_group_name=SystemGroups.MEMBERS,
),
'can_delete_any_message_group': PermissionSettingsItem(
// allow_nobody_group=True,
allowEveryoneGroup: false,
// default_group_name=SystemGroups.ADMINISTRATORS,
),
'can_delete_own_message_group': PermissionSettingsItem(
// allow_nobody_group=True,
allowEveryoneGroup: true,
// default_group_name=SystemGroups.EVERYONE,
),
'can_invite_users_group': PermissionSettingsItem(
// allow_nobody_group=True,
allowEveryoneGroup: false,
// default_group_name=SystemGroups.MEMBERS,
),
'can_manage_all_groups': PermissionSettingsItem(
// allow_nobody_group=False,
allowEveryoneGroup: false,
// default_group_name=SystemGroups.OWNERS,
),
'can_manage_billing_group': PermissionSettingsItem(
// allow_nobody_group=False,
allowEveryoneGroup: false,
// default_group_name=SystemGroups.ADMINISTRATORS,
),
'can_mention_many_users_group': PermissionSettingsItem(
// allow_nobody_group=True,
allowEveryoneGroup: true,
// default_group_name=SystemGroups.ADMINISTRATORS,
),
'can_move_messages_between_channels_group': PermissionSettingsItem(
// allow_nobody_group=True,
allowEveryoneGroup: false,
// default_group_name=SystemGroups.MEMBERS,
),
'can_move_messages_between_topics_group': PermissionSettingsItem(
// allow_nobody_group=True,
allowEveryoneGroup: true,
// default_group_name=SystemGroups.EVERYONE,
),
'can_resolve_topics_group': PermissionSettingsItem(
// allow_nobody_group=True,
allowEveryoneGroup: true,
// default_group_name=SystemGroups.EVERYONE,
),
'can_set_delete_message_policy_group': PermissionSettingsItem(
// allow_nobody_group=True,
allowEveryoneGroup: false,
// default_group_name=SystemGroups.MODERATORS,
),
'can_set_topics_policy_group': PermissionSettingsItem(
// allow_nobody_group=True,
allowEveryoneGroup: true,
// default_group_name=SystemGroups.MEMBERS,
),
'can_summarize_topics_group': PermissionSettingsItem(
// allow_nobody_group=True,
allowEveryoneGroup: true,
// default_group_name=SystemGroups.EVERYONE,
),
'direct_message_initiator_group': PermissionSettingsItem(
// allow_nobody_group=True,
allowEveryoneGroup: true,
// default_group_name=SystemGroups.EVERYONE,
),
'direct_message_permission_group': PermissionSettingsItem(
// allow_nobody_group=True,
allowEveryoneGroup: true,
// default_group_name=SystemGroups.EVERYONE,
),
},
group: {}, // Please go ahead and fill this in when we come to need it.
stream: {
// From the server's Stream.stream_permission_group_settings,
Expand Down
27 changes: 27 additions & 0 deletions lib/api/model/initial_snapshot.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions lib/api/model/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,12 @@ class ZulipStream {

final int streamId;
String name;

// Servers that don't send this property will only send non-archived channels;
// default to false for those servers.
@JsonKey(defaultValue: false)
bool isArchived; // TODO(server-10) remove default and its comment

String description;
String renderedDescription;

Expand All @@ -642,6 +648,8 @@ class ZulipStream {
// final bool isAnnouncementOnly; // deprecated for `channelPostPolicy`; ignore

GroupSettingValue? canAddSubscribersGroup; // TODO(server-10)
GroupSettingValue? canDeleteAnyMessageGroup; // TODO(server-11)
GroupSettingValue? canDeleteOwnMessageGroup; // TODO(server-11)
GroupSettingValue? canSubscribeGroup; // TODO(server-10)

// TODO(server-8): added in FL 199, was previously only on [Subscription] objects
Expand All @@ -650,6 +658,7 @@ class ZulipStream {
ZulipStream({
required this.streamId,
required this.name,
required this.isArchived,
required this.description,
required this.renderedDescription,
required this.dateCreated,
Expand All @@ -660,6 +669,8 @@ class ZulipStream {
required this.messageRetentionDays,
required this.channelPostPolicy,
required this.canAddSubscribersGroup,
required this.canDeleteAnyMessageGroup,
required this.canDeleteOwnMessageGroup,
required this.canSubscribeGroup,
required this.streamWeeklyTraffic,
});
Expand All @@ -670,6 +681,7 @@ class ZulipStream {
streamId: subscription.streamId,
name: subscription.name,
description: subscription.description,
isArchived: subscription.isArchived,
renderedDescription: subscription.renderedDescription,
dateCreated: subscription.dateCreated,
firstMessageId: subscription.firstMessageId,
Expand All @@ -679,6 +691,8 @@ class ZulipStream {
messageRetentionDays: subscription.messageRetentionDays,
channelPostPolicy: subscription.channelPostPolicy,
canAddSubscribersGroup: subscription.canAddSubscribersGroup,
canDeleteAnyMessageGroup: subscription.canDeleteAnyMessageGroup,
canDeleteOwnMessageGroup: subscription.canDeleteOwnMessageGroup,
canSubscribeGroup: subscription.canSubscribeGroup,
streamWeeklyTraffic: subscription.streamWeeklyTraffic,
);
Expand All @@ -700,6 +714,7 @@ class ZulipStream {
enum ChannelPropertyName {
// streamId is immutable
name,
isArchived,
description,
// renderedDescription is updated via its own [ChannelUpdateEvent] field
// dateCreated is immutable
Expand All @@ -711,6 +726,8 @@ enum ChannelPropertyName {
@JsonValue('stream_post_policy')
channelPostPolicy,
canAddSubscribersGroup,
canDeleteAnyMessageGroup,
canDeleteOwnMessageGroup,
canSubscribeGroup,
streamWeeklyTraffic;

Expand Down Expand Up @@ -783,6 +800,7 @@ class Subscription extends ZulipStream {
required super.streamId,
required super.name,
required super.description,
required super.isArchived,
required super.renderedDescription,
required super.dateCreated,
required super.firstMessageId,
Expand All @@ -792,6 +810,8 @@ class Subscription extends ZulipStream {
required super.messageRetentionDays,
required super.channelPostPolicy,
required super.canAddSubscribersGroup,
required super.canDeleteAnyMessageGroup,
required super.canDeleteOwnMessageGroup,
required super.canSubscribeGroup,
required super.streamWeeklyTraffic,
required this.desktopNotifications,
Expand Down
Loading