Skip to content

Commit 39967c8

Browse files
committed
api: Add realm-level restrict-message-deleting fields to InitialSnapshot
1 parent f304ec4 commit 39967c8

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

lib/api/model/initial_snapshot.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ 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.
83+
final RealmDeleteOwnMessagePolicy? realmDeleteOwnMessagePolicy; // TODO(server-10)
84+
7585
/// The policy for who can use wildcard mentions in large channels.
7686
///
7787
/// Search for "realm_wildcard_mention_policy" in https://zulip.com/api/register-queue.
@@ -87,6 +97,8 @@ class InitialSnapshot {
8797
/// https://zulip.com/api/roles-and-permissions#determining-if-a-user-is-a-full-member
8898
final int realmWaitingPeriodThreshold;
8999

100+
final int? realmMessageContentDeleteLimitSeconds;
101+
90102
final bool realmAllowMessageEditing;
91103
final int? realmMessageContentEditLimitSeconds;
92104

@@ -158,9 +170,13 @@ class InitialSnapshot {
158170
required this.userStatuses,
159171
required this.userSettings,
160172
required this.userTopics,
173+
required this.realmCanDeleteAnyMessageGroup,
174+
required this.realmCanDeleteOwnMessageGroup,
175+
required this.realmDeleteOwnMessagePolicy,
161176
required this.realmWildcardMentionPolicy,
162177
required this.realmMandatoryTopics,
163178
required this.realmWaitingPeriodThreshold,
179+
required this.realmMessageContentDeleteLimitSeconds,
164180
required this.realmAllowMessageEditing,
165181
required this.realmMessageContentEditLimitSeconds,
166182
required this.realmEnableReadReceipts,
@@ -196,6 +212,21 @@ enum RealmWildcardMentionPolicy {
196212
int? toJson() => apiValue;
197213
}
198214

215+
@JsonEnum(valueField: 'apiValue')
216+
enum RealmDeleteOwnMessagePolicy {
217+
members(apiValue: 1),
218+
admins(apiValue: 2),
219+
fullMembers(apiValue: 3),
220+
moderators(apiValue: 4),
221+
everyone(apiValue: 5);
222+
223+
const RealmDeleteOwnMessagePolicy({required this.apiValue});
224+
225+
final int? apiValue;
226+
227+
int? toJson() => apiValue;
228+
}
229+
199230
/// An item in `realm_default_external_accounts`.
200231
///
201232
/// 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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,9 +1236,13 @@ InitialSnapshot initialSnapshot({
12361236
Map<int, UserStatusChange>? userStatuses,
12371237
UserSettings? userSettings,
12381238
List<UserTopicItem>? userTopics,
1239+
GroupSettingValue? realmCanDeleteAnyMessageGroup,
1240+
GroupSettingValue? realmCanDeleteOwnMessageGroup,
1241+
RealmDeleteOwnMessagePolicy? realmDeleteOwnMessagePolicy,
12391242
RealmWildcardMentionPolicy? realmWildcardMentionPolicy,
12401243
bool? realmMandatoryTopics,
12411244
int? realmWaitingPeriodThreshold,
1245+
int? realmMessageContentDeleteLimitSeconds,
12421246
bool? realmAllowMessageEditing,
12431247
int? realmMessageContentEditLimitSeconds,
12441248
bool? realmEnableReadReceipts,
@@ -1284,9 +1288,16 @@ InitialSnapshot initialSnapshot({
12841288
presenceEnabled: true,
12851289
),
12861290
userTopics: userTopics,
1291+
// no default; allow `null` to simulate servers without this
1292+
realmCanDeleteAnyMessageGroup: realmCanDeleteAnyMessageGroup,
1293+
// no default; allow `null` to simulate servers without this
1294+
realmCanDeleteOwnMessageGroup: realmCanDeleteOwnMessageGroup,
1295+
// no default; allow `null` to simulate servers without this
1296+
realmDeleteOwnMessagePolicy: realmDeleteOwnMessagePolicy,
12871297
realmWildcardMentionPolicy: realmWildcardMentionPolicy ?? RealmWildcardMentionPolicy.everyone,
12881298
realmMandatoryTopics: realmMandatoryTopics ?? true,
12891299
realmWaitingPeriodThreshold: realmWaitingPeriodThreshold ?? 0,
1300+
realmMessageContentDeleteLimitSeconds: realmMessageContentDeleteLimitSeconds,
12901301
realmAllowMessageEditing: realmAllowMessageEditing ?? true,
12911302
realmMessageContentEditLimitSeconds: realmMessageContentEditLimitSeconds,
12921303
realmEnableReadReceipts: realmEnableReadReceipts ?? true,

0 commit comments

Comments
 (0)