Skip to content

Commit 6cf3dd9

Browse files
committed
model: Add hasPassedWaitingPeriod helper method to User
1 parent 9616005 commit 6cf3dd9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/api/model/model.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,18 @@ class User {
263263
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
264264

265265
Map<String, dynamic> toJson() => _$UserToJson(this);
266+
267+
/// Whether the user has passed the realm's waiting period to be a full member.
268+
///
269+
/// See:
270+
/// https://zulip.com/api/roles-and-permissions#determining-if-a-user-is-a-full-member
271+
///
272+
/// To determine if a user is a full member, callers must also check that the
273+
/// user's role is at least Role.Member.
274+
bool hasPassedWaitingPeriod(DateTime byDate, int realmWaitingPeriodThreshold) {
275+
final dateJoined = DateTime.parse(this.dateJoined);
276+
return byDate.difference(dateJoined).inDays >= realmWaitingPeriodThreshold;
277+
}
266278
}
267279

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

0 commit comments

Comments
 (0)