Skip to content

Commit 4ea08ab

Browse files
committed
api: Add InitialSnapshot.realmTopicsPolicy
1 parent 1699aa5 commit 4ea08ab

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

lib/api/model/initial_snapshot.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ class InitialSnapshot {
9090

9191
final bool realmMandatoryTopics;
9292

93+
final RealmTopicsPolicy realmTopicsPolicy;
94+
9395
final String realmName;
9496

9597
/// The number of days until a user's account is treated as a full member.
@@ -181,6 +183,7 @@ class InitialSnapshot {
181183
required this.realmDeleteOwnMessagePolicy,
182184
required this.realmWildcardMentionPolicy,
183185
required this.realmMandatoryTopics,
186+
required this.realmTopicsPolicy,
184187
required this.realmName,
185188
required this.realmWaitingPeriodThreshold,
186189
required this.realmMessageContentDeleteLimitSeconds,
@@ -204,6 +207,22 @@ class InitialSnapshot {
204207
Map<String, dynamic> toJson() => _$InitialSnapshotToJson(this);
205208
}
206209

210+
/// A value of [InitialSnapshot.realmTopicsPolicy].
211+
///
212+
/// For docs, search for "realm_topics_policy"
213+
/// in <https://zulip.com/api/register-queue#response>.
214+
@JsonEnum(fieldRename: FieldRename.snake)
215+
enum RealmTopicsPolicy {
216+
allowEmptyTopic,
217+
disableEmptyTopic;
218+
219+
static RealmTopicsPolicy fromRawString(String raw) => _byRawString[raw] ?? allowEmptyTopic;
220+
221+
static final _byRawString = _$RealmTopicsPolicyEnumMap.map((key, value) => MapEntry(value, key));
222+
223+
String toJson() => _$RealmTopicsPolicyEnumMap[this]!;
224+
}
225+
207226
@JsonEnum(valueField: 'apiValue')
208227
enum RealmWildcardMentionPolicy {
209228
everyone(apiValue: 1),

lib/api/model/initial_snapshot.g.dart

Lines changed: 10 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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,7 @@ InitialSnapshot initialSnapshot({
13351335
RealmDeleteOwnMessagePolicy? realmDeleteOwnMessagePolicy,
13361336
RealmWildcardMentionPolicy? realmWildcardMentionPolicy,
13371337
bool? realmMandatoryTopics,
1338+
RealmTopicsPolicy? realmTopicsPolicy,
13381339
String? realmName,
13391340
int? realmWaitingPeriodThreshold,
13401341
int? realmMessageContentDeleteLimitSeconds,
@@ -1398,6 +1399,7 @@ InitialSnapshot initialSnapshot({
13981399
realmDeleteOwnMessagePolicy: realmDeleteOwnMessagePolicy,
13991400
realmWildcardMentionPolicy: realmWildcardMentionPolicy ?? RealmWildcardMentionPolicy.everyone,
14001401
realmMandatoryTopics: realmMandatoryTopics ?? true,
1402+
realmTopicsPolicy: realmTopicsPolicy ?? RealmTopicsPolicy.allowEmptyTopic,
14011403
realmName: realmName ?? 'Example Zulip organization',
14021404
realmWaitingPeriodThreshold: realmWaitingPeriodThreshold ?? 0,
14031405
realmMessageContentDeleteLimitSeconds: realmMessageContentDeleteLimitSeconds,

0 commit comments

Comments
 (0)