Skip to content

Commit 93ce93a

Browse files
committed
model: Add hasPassedWaitingPeriod helper method to User
1 parent 2a1c18a commit 93ce93a

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
@@ -262,6 +262,18 @@ class User {
262262
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
263263

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

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

0 commit comments

Comments
 (0)