Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop three User fields we aren't keeping up to date; verify that's all #876

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions lib/api/model/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,25 @@ enum Emojiset {
/// in <https://zulip.com/api/register-queue>.
@JsonSerializable(fieldRename: FieldRename.snake)
class User {
// When adding a field to this class:
// * If a [RealmUserUpdateEvent] can update it, be sure to add
// that case to [RealmUserUpdateEvent] and its handler.
// * If the field can never change for a given Zulip user, mark it final.
// * (If it can change but [RealmUserUpdateEvent] doesn't cover that,
// then that's a bug in the API; raise it in `#api design`.)

final int userId;
String? deliveryEmail;
String email;
String fullName;
String dateJoined;
final String dateJoined;
bool isActive; // Really sometimes absent in /register, but we normalize that away; see [InitialSnapshot.realmUsers].
bool isOwner;
bool isAdmin;
bool isGuest;
// bool isOwner; // obsoleted by [role]; ignore
// bool isAdmin; // obsoleted by [role]; ignore
// bool isGuest; // obsoleted by [role]; ignore
bool? isBillingAdmin; // TODO(server-5)
bool isBot;
int? botType; // TODO enum
final bool isBot;
final int? botType; // TODO enum
int? botOwnerId;
@JsonKey(unknownEnumValue: UserRole.unknown)
UserRole role;
Expand All @@ -214,7 +221,7 @@ class User {
Map<int, ProfileFieldUserData>? profileData;

@JsonKey(readValue: _readIsSystemBot)
bool isSystemBot;
final bool isSystemBot;

static Map<String, dynamic>? _readProfileData(Map<dynamic, dynamic> json, String key) {
final value = (json[key] as Map<String, dynamic>?);
Expand All @@ -240,9 +247,6 @@ class User {
required this.fullName,
required this.dateJoined,
required this.isActive,
required this.isOwner,
required this.isAdmin,
required this.isGuest,
required this.isBillingAdmin,
required this.isBot,
required this.botType,
Expand Down
6 changes: 0 additions & 6 deletions lib/api/model/model.g.dart

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

3 changes: 0 additions & 3 deletions test/api/model/model_checks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ extension UserChecks on Subject<User> {
Subject<String> get fullName => has((x) => x.fullName, 'fullName');
Subject<String> get dateJoined => has((x) => x.dateJoined, 'dateJoined');
Subject<bool> get isActive => has((x) => x.isActive, 'isActive');
Subject<bool> get isOwner => has((x) => x.isOwner, 'isOwner');
Subject<bool> get isAdmin => has((x) => x.isAdmin, 'isAdmin');
Subject<bool> get isGuest => has((x) => x.isGuest, 'isGuest');
Subject<bool?> get isBillingAdmin => has((x) => x.isBillingAdmin, 'isBillingAdmin');
Subject<bool> get isBot => has((x) => x.isBot, 'isBot');
Subject<int?> get botType => has((x) => x.botType, 'botType');
Expand Down
3 changes: 0 additions & 3 deletions test/example_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ User user({
fullName: fullName ?? 'A user', // TODO generate example names
dateJoined: '2023-04-28',
isActive: isActive ?? true,
isOwner: false,
isAdmin: false,
isGuest: false,
isBillingAdmin: false,
isBot: isBot ?? false,
botType: null,
Expand Down