Skip to content

Commit 963eb8f

Browse files
committed
api: Add realmDefaultExtrenalAccounts
1 parent fab0fb9 commit 963eb8f

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

lib/api/model/initial_snapshot.dart

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class InitialSnapshot {
3939
// TODO(server-5) remove pre-5.0 comment
4040
final UserSettings? userSettings; // TODO(server-5)
4141

42+
final Map<String, RealmDefaultExternalAccount> realmDefaultExternalAccounts;
43+
4244
final int maxFileUploadSizeMib;
4345

4446
@JsonKey(readValue: _readUsersIsActiveFallbackTrue)
@@ -81,6 +83,7 @@ class InitialSnapshot {
8183
required this.subscriptions,
8284
required this.unreadMsgs,
8385
required this.streams,
86+
required this.realmDefaultExternalAccounts,
8487
required this.userSettings,
8588
required this.maxFileUploadSizeMib,
8689
required this.realmUsers,
@@ -94,6 +97,30 @@ class InitialSnapshot {
9497
Map<String, dynamic> toJson() => _$InitialSnapshotToJson(this);
9598
}
9699

100+
/// An item in `realm_default_external_accounts`.
101+
///
102+
/// For docs, search for "realm_default_external_accounts:"
103+
/// in <https://zulip.com/api/register-queue>.
104+
@JsonSerializable(fieldRename: FieldRename.snake)
105+
class RealmDefaultExternalAccount {
106+
final String name;
107+
final String text;
108+
final String hint;
109+
final String urlPattern;
110+
111+
RealmDefaultExternalAccount({
112+
required this.name,
113+
required this.text,
114+
required this.hint,
115+
required this.urlPattern,
116+
});
117+
118+
factory RealmDefaultExternalAccount.fromJson(Map<String, dynamic> json) =>
119+
_$RealmDefaultExternalAccountFromJson(json);
120+
121+
Map<String, dynamic> toJson() => _$RealmDefaultExternalAccountToJson(this);
122+
}
123+
97124
/// An item in `recent_private_conversations`.
98125
///
99126
/// For docs, search for "recent_private_conversations:"

lib/api/model/initial_snapshot.g.dart

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

lib/model/store.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ class PerAccountStore extends ChangeNotifier {
151151
required InitialSnapshot initialSnapshot,
152152
}) : zulipVersion = initialSnapshot.zulipVersion,
153153
maxFileUploadSizeMib = initialSnapshot.maxFileUploadSizeMib,
154+
realmDefaultExternalAccounts = initialSnapshot.realmDefaultExternalAccounts,
154155
userSettings = initialSnapshot.userSettings,
155156
users = Map.fromEntries(
156157
initialSnapshot.realmUsers
@@ -172,6 +173,7 @@ class PerAccountStore extends ChangeNotifier {
172173
// Data attached to the realm or the server.
173174
final String zulipVersion; // TODO get from account; update there on initial snapshot
174175
final int maxFileUploadSizeMib; // No event for this.
176+
final Map<String, RealmDefaultExternalAccount> realmDefaultExternalAccounts;
175177

176178
// Data attached to the self-account on the realm.
177179
final UserSettings? userSettings; // TODO(server-5)

test/example_data.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ InitialSnapshot initialSnapshot({
246246
List<Subscription>? subscriptions,
247247
UnreadMessagesSnapshot? unreadMsgs,
248248
List<ZulipStream>? streams,
249+
Map<String, RealmDefaultExternalAccount>? realmDefaultExternalAccounts,
249250
UserSettings? userSettings,
250251
int? maxFileUploadSizeMib,
251252
List<User>? realmUsers,
@@ -264,6 +265,7 @@ InitialSnapshot initialSnapshot({
264265
subscriptions: subscriptions ?? [], // TODO add subscriptions to default
265266
unreadMsgs: unreadMsgs ?? _unreadMsgs(),
266267
streams: streams ?? [], // TODO add streams to default
268+
realmDefaultExternalAccounts: realmDefaultExternalAccounts ?? {},
267269
userSettings: userSettings, // TODO add userSettings to default
268270
maxFileUploadSizeMib: maxFileUploadSizeMib ?? 25,
269271
realmUsers: realmUsers ?? [],

0 commit comments

Comments
 (0)