@@ -128,6 +128,18 @@ mixin RealmStore on PerAccountStoreBase, UserGroupStore {
128128 return topic;
129129 }
130130
131+ /// Whether the self-user has passed the realm's waiting period
132+ /// to be a full member.
133+ ///
134+ /// See:
135+ /// https://zulip.com/api/roles-and-permissions#determining-if-a-user-is-a-full-member
136+ ///
137+ /// To determine if the self-user is a full member,
138+ /// callers must also check that the user's role is at least [UserRole.member] .
139+ // This used to be a method on [UserStore], but we needed it for permissions
140+ // here in [RealmStore].
141+ bool selfHasPassedWaitingPeriod ({required DateTime byDate});
142+
131143 /// Whether the self-user has the given (group-based) permission.
132144 bool selfHasPermissionForGroupSetting (GroupSettingValue value,
133145 GroupSettingType type, String name);
@@ -180,6 +192,9 @@ mixin ProxyRealmStore on RealmStore {
180192 @override
181193 List <CustomProfileField > get customProfileFields => realmStore.customProfileFields;
182194 @override
195+ bool selfHasPassedWaitingPeriod ({required DateTime byDate}) =>
196+ realmStore.selfHasPassedWaitingPeriod (byDate: byDate);
197+ @override
183198 bool selfHasPermissionForGroupSetting (GroupSettingValue value, GroupSettingType type, String name) =>
184199 realmStore.selfHasPermissionForGroupSetting (value, type, name);
185200}
@@ -203,6 +218,7 @@ class RealmStoreImpl extends HasUserGroupStore with RealmStore {
203218 required User selfUser,
204219 }) :
205220 _selfUserRole = selfUser.role,
221+ _selfUserDateJoined = selfUser.dateJoined,
206222 serverPresencePingIntervalSeconds = initialSnapshot.serverPresencePingIntervalSeconds,
207223 serverPresenceOfflineThresholdSeconds = initialSnapshot.serverPresenceOfflineThresholdSeconds,
208224 serverTypingStartedExpiryPeriodMilliseconds = initialSnapshot.serverTypingStartedExpiryPeriodMilliseconds,
@@ -224,6 +240,22 @@ class RealmStoreImpl extends HasUserGroupStore with RealmStore {
224240 realmDefaultExternalAccounts = initialSnapshot.realmDefaultExternalAccounts,
225241 customProfileFields = _sortCustomProfileFields (initialSnapshot.customProfileFields);
226242
243+ @override
244+ bool selfHasPassedWaitingPeriod ({required DateTime byDate}) {
245+ // [User.dateJoined] is in UTC. For logged-in users, the format is:
246+ // YYYY-MM-DDTHH:mm+00:00, which includes the timezone offset for UTC.
247+ // For logged-out spectators, the format is: YYYY-MM-DD, which doesn't
248+ // include the timezone offset. In the later case, [DateTime.parse] will
249+ // interpret it as the client's local timezone, which could lead to
250+ // incorrect results; but that's acceptable for now because the app
251+ // doesn't support viewing as a spectator.
252+ //
253+ // See the related discussion:
254+ // https://chat.zulip.org/#narrow/channel/412-api-documentation/topic/provide.20an.20explicit.20format.20for.20.60realm_user.2Edate_joined.60/near/1980194
255+ final dateJoined = DateTime .parse (_selfUserDateJoined);
256+ return byDate.difference (dateJoined).inDays >= realmWaitingPeriodThreshold;
257+ }
258+
227259 @override
228260 bool selfHasPermissionForGroupSetting (GroupSettingValue value,
229261 GroupSettingType type, String name) {
@@ -262,8 +294,20 @@ class RealmStoreImpl extends HasUserGroupStore with RealmStore {
262294 /// The main home of this information is [UserStore] : `store.selfUser.role` .
263295 /// We need it here for interpreting some permission settings;
264296 /// so we denormalize it here to avoid a cycle between substores.
297+ ///
298+ /// See also [_selfUserDateJoined] .
265299 UserRole _selfUserRole;
266300
301+ /// The [User.dateJoined] of the self-user.
302+ ///
303+ /// The main home of this information is [UserStore] :
304+ /// `store.selfUser.dateJoined` .
305+ /// We need it here for interpreting some permission settings;
306+ /// so we denormalize it here to avoid a cycle between substores.
307+ ///
308+ /// See also [_selfUserRole] .
309+ final String _selfUserDateJoined;
310+
267311 @override
268312 final int serverPresencePingIntervalSeconds;
269313 @override
0 commit comments