Skip to content

Commit

Permalink
api: Drop isOwner, isAdmin, isGuest from User class
Browse files Browse the repository at this point in the history
These are obsoleted by [User.role] (which dates to Zulip 4.0).
We never looked at these fields, but had a latent bug because
we weren't keeping them up to date on RealmUserUpdateEvent.
To fix the bug, just stop having the fields around at all.

(Later if we find we want booleans with these handy names,
we can always add getters that just inspect [User.role].)
  • Loading branch information
gnprice committed Aug 10, 2024
1 parent cca6f24 commit 241f6d7
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 18 deletions.
9 changes: 3 additions & 6 deletions lib/api/model/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ class User {
String fullName;
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
Expand Down Expand Up @@ -240,9 +240,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 @@ -88,9 +88,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

0 comments on commit 241f6d7

Please sign in to comment.