Skip to content

Commit 9a5960a

Browse files
committed
user [nfc]: Move userDisplayEmail here
This doesn't move any tests, because this method has no tests. (Which at this point isn't a problem: for server versions we actually support, this method's logic becomes trivial.)
1 parent d71f081 commit 9a5960a

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

lib/model/store.dart

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -618,36 +618,6 @@ class PerAccountStore extends PerAccountStoreBase with
618618

619619
final Presence presence;
620620

621-
/// The user's real email address, if known, for displaying in the UI.
622-
///
623-
/// Returns null if self-user isn't able to see the user's real email address,
624-
/// or if the user isn't actually a user we know about.
625-
String? userDisplayEmail(int userId) {
626-
final user = getUser(userId);
627-
if (user == null) return null;
628-
if (zulipFeatureLevel >= 163) { // TODO(server-7)
629-
// A non-null value means self-user has access to [user]'s real email,
630-
// while a null value means it doesn't have access to the email.
631-
// Search for "delivery_email" in https://zulip.com/api/register-queue.
632-
return user.deliveryEmail;
633-
} else {
634-
if (user.deliveryEmail != null) {
635-
// A non-null value means self-user has access to [user]'s real email,
636-
// while a null value doesn't necessarily mean it doesn't have access
637-
// to the email, ....
638-
return user.deliveryEmail;
639-
} else if (emailAddressVisibility == EmailAddressVisibility.everyone) {
640-
// ... we have to also check for [PerAccountStore.emailAddressVisibility].
641-
// See:
642-
// * https://github.com/zulip/zulip-mobile/pull/5515#discussion_r997731727
643-
// * https://chat.zulip.org/#narrow/stream/378-api-design/topic/email.20address.20visibility/near/1296133
644-
return user.email;
645-
} else {
646-
return null;
647-
}
648-
}
649-
}
650-
651621
//|//////////////////////////////
652622
// Streams, topics, and stuff about them.
653623

lib/model/user.dart

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,36 @@ mixin UserStore on PerAccountStoreBase, RealmStore {
8383
return getUser(senderId)?.fullName ?? message.senderFullName;
8484
}
8585

86+
/// The user's real email address, if known, for displaying in the UI.
87+
///
88+
/// Returns null if self-user isn't able to see the user's real email address,
89+
/// or if the user isn't actually a user we know about.
90+
String? userDisplayEmail(int userId) {
91+
final user = getUser(userId);
92+
if (user == null) return null;
93+
if (zulipFeatureLevel >= 163) { // TODO(server-7)
94+
// A non-null value means self-user has access to [user]'s real email,
95+
// while a null value means it doesn't have access to the email.
96+
// Search for "delivery_email" in https://zulip.com/api/register-queue.
97+
return user.deliveryEmail;
98+
} else {
99+
if (user.deliveryEmail != null) {
100+
// A non-null value means self-user has access to [user]'s real email,
101+
// while a null value doesn't necessarily mean it doesn't have access
102+
// to the email, ....
103+
return user.deliveryEmail;
104+
} else if (emailAddressVisibility == EmailAddressVisibility.everyone) {
105+
// ... we have to also check for [PerAccountStore.emailAddressVisibility].
106+
// See:
107+
// * https://github.com/zulip/zulip-mobile/pull/5515#discussion_r997731727
108+
// * https://chat.zulip.org/#narrow/stream/378-api-design/topic/email.20address.20visibility/near/1296133
109+
return user.email;
110+
} else {
111+
return null;
112+
}
113+
}
114+
}
115+
86116
/// Whether [user] has passed the realm's waiting period to be a full member.
87117
///
88118
/// See:

0 commit comments

Comments
 (0)