Skip to content

Commit 1c10f9a

Browse files
committed
api: Add realm-level restrict-message-deleting fields to InitialSnapshot
1 parent ce8802b commit 1c10f9a

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

lib/api/model/initial_snapshot.dart

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ class InitialSnapshot {
7272

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

75+
final GroupSettingValue? realmCanDeleteAnyMessageGroup; // TODO(server-10)
76+
77+
final GroupSettingValue? realmCanDeleteOwnMessageGroup; // TODO(server-10)
78+
79+
/// The policy for who can delete their own messages,
80+
/// on supported servers below version 10.
81+
///
82+
/// Removed in FL 291, so absent in the current API doc;
83+
/// see zulip/zulip@0cd51f2fe.
84+
final RealmDeleteOwnMessagePolicy? realmDeleteOwnMessagePolicy; // TODO(server-10)
85+
7586
/// The policy for who can use wildcard mentions in large channels.
7687
///
7788
/// Search for "realm_wildcard_mention_policy" in https://zulip.com/api/register-queue.
@@ -87,6 +98,8 @@ class InitialSnapshot {
8798
/// https://zulip.com/api/roles-and-permissions#determining-if-a-user-is-a-full-member
8899
final int realmWaitingPeriodThreshold;
89100

101+
final int? realmMessageContentDeleteLimitSeconds;
102+
90103
final bool realmAllowMessageEditing;
91104
final int? realmMessageContentEditLimitSeconds;
92105

@@ -158,9 +171,13 @@ class InitialSnapshot {
158171
required this.userStatuses,
159172
required this.userSettings,
160173
required this.userTopics,
174+
required this.realmCanDeleteAnyMessageGroup,
175+
required this.realmCanDeleteOwnMessageGroup,
176+
required this.realmDeleteOwnMessagePolicy,
161177
required this.realmWildcardMentionPolicy,
162178
required this.realmMandatoryTopics,
163179
required this.realmWaitingPeriodThreshold,
180+
required this.realmMessageContentDeleteLimitSeconds,
164181
required this.realmAllowMessageEditing,
165182
required this.realmMessageContentEditLimitSeconds,
166183
required this.realmEnableReadReceipts,
@@ -196,6 +213,21 @@ enum RealmWildcardMentionPolicy {
196213
int? toJson() => apiValue;
197214
}
198215

216+
@JsonEnum(valueField: 'apiValue')
217+
enum RealmDeleteOwnMessagePolicy {
218+
members(apiValue: 1),
219+
admins(apiValue: 2),
220+
fullMembers(apiValue: 3),
221+
moderators(apiValue: 4),
222+
everyone(apiValue: 5);
223+
224+
const RealmDeleteOwnMessagePolicy({required this.apiValue});
225+
226+
final int apiValue;
227+
228+
int toJson() => apiValue;
229+
}
230+
199231
/// An item in `realm_default_external_accounts`.
200232
///
201233
/// For docs, search for "realm_default_external_accounts:"

lib/api/model/initial_snapshot.g.dart

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

test/example_data.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,9 +1243,13 @@ InitialSnapshot initialSnapshot({
12431243
Map<int, UserStatusChange>? userStatuses,
12441244
UserSettings? userSettings,
12451245
List<UserTopicItem>? userTopics,
1246+
GroupSettingValue? realmCanDeleteAnyMessageGroup,
1247+
GroupSettingValue? realmCanDeleteOwnMessageGroup,
1248+
RealmDeleteOwnMessagePolicy? realmDeleteOwnMessagePolicy,
12461249
RealmWildcardMentionPolicy? realmWildcardMentionPolicy,
12471250
bool? realmMandatoryTopics,
12481251
int? realmWaitingPeriodThreshold,
1252+
int? realmMessageContentDeleteLimitSeconds,
12491253
bool? realmAllowMessageEditing,
12501254
int? realmMessageContentEditLimitSeconds,
12511255
bool? realmEnableReadReceipts,
@@ -1291,9 +1295,15 @@ InitialSnapshot initialSnapshot({
12911295
presenceEnabled: true,
12921296
),
12931297
userTopics: userTopics,
1298+
// no default; allow `null` to simulate servers without this
1299+
realmCanDeleteAnyMessageGroup: realmCanDeleteAnyMessageGroup,
1300+
// no default; allow `null` to simulate servers without this
1301+
realmCanDeleteOwnMessageGroup: realmCanDeleteOwnMessageGroup,
1302+
realmDeleteOwnMessagePolicy: realmDeleteOwnMessagePolicy,
12941303
realmWildcardMentionPolicy: realmWildcardMentionPolicy ?? RealmWildcardMentionPolicy.everyone,
12951304
realmMandatoryTopics: realmMandatoryTopics ?? true,
12961305
realmWaitingPeriodThreshold: realmWaitingPeriodThreshold ?? 0,
1306+
realmMessageContentDeleteLimitSeconds: realmMessageContentDeleteLimitSeconds,
12971307
realmAllowMessageEditing: realmAllowMessageEditing ?? true,
12981308
realmMessageContentEditLimitSeconds: realmMessageContentEditLimitSeconds,
12991309
realmEnableReadReceipts: realmEnableReadReceipts ?? true,

0 commit comments

Comments
 (0)