Skip to content

Commit b467f4c

Browse files
committed
model: Add isFullMember helper method to User
1 parent 5576d17 commit b467f4c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/api/model/model.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,13 @@ class User {
258258
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
259259

260260
Map<String, dynamic> toJson() => _$UserToJson(this);
261+
262+
// This is determined based on:
263+
// https://zulip.com/api/roles-and-permissions#determining-if-a-user-is-a-full-member
264+
bool isFullMember(int realmWaitingPeriodThreshold) {
265+
final dateJoined = DateTime.parse(this.dateJoined);
266+
return DateTime.now().difference(dateJoined).inDays >= realmWaitingPeriodThreshold;
267+
}
261268
}
262269

263270
/// As in [User.profileData].

0 commit comments

Comments
 (0)