Skip to content

Commit 0900820

Browse files
chrisbobbegnprice
authored andcommitted
user [nfc]: Clear out pre-7.0 backwards-compat code for display email
We refuse to connect to servers older than 7.0; see the README and kMinSupportedZulipVersion.
1 parent 79edb40 commit 0900820

File tree

5 files changed

+2
-69
lines changed

5 files changed

+2
-69
lines changed

lib/api/model/initial_snapshot.dart

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,6 @@ class InitialSnapshot {
2424

2525
final List<CustomProfileField> customProfileFields;
2626

27-
/// The realm-level policy, on pre-FL 163 servers, for visibility of real email addresses.
28-
///
29-
/// Search for "email_address_visibility" in https://zulip.com/api/register-queue.
30-
///
31-
/// This field is removed in Zulip 7.0 (FL 163) and replaced with a user-level
32-
/// setting:
33-
/// * https://zulip.com/api/update-settings#parameter-email_address_visibility
34-
/// * https://zulip.com/api/update-realm-user-settings-defaults#parameter-email_address_visibility
35-
final EmailAddressVisibility? emailAddressVisibility; // TODO(server-7): remove
36-
3727
final int serverPresencePingIntervalSeconds;
3828
final int serverPresenceOfflineThresholdSeconds;
3929

@@ -146,7 +136,6 @@ class InitialSnapshot {
146136
required this.zulipMergeBase,
147137
required this.alertWords,
148138
required this.customProfileFields,
149-
required this.emailAddressVisibility,
150139
required this.serverPresencePingIntervalSeconds,
151140
required this.serverPresenceOfflineThresholdSeconds,
152141
required this.serverTypingStartedExpiryPeriodMilliseconds,
@@ -185,14 +174,6 @@ class InitialSnapshot {
185174
Map<String, dynamic> toJson() => _$InitialSnapshotToJson(this);
186175
}
187176

188-
enum EmailAddressVisibility {
189-
@JsonValue(1) everyone,
190-
@JsonValue(2) members,
191-
@JsonValue(3) admins,
192-
@JsonValue(4) nobody,
193-
@JsonValue(5) moderators,
194-
}
195-
196177
@JsonEnum(valueField: 'apiValue')
197178
enum RealmWildcardMentionPolicy {
198179
everyone(apiValue: 1),

lib/api/model/initial_snapshot.g.dart

Lines changed: 0 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/model/realm.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ mixin RealmStore on PerAccountStoreBase {
5151

5252
RealmWildcardMentionPolicy get realmWildcardMentionPolicy; // TODO(#662): replaced by can_mention_many_users_group
5353

54-
EmailAddressVisibility? get emailAddressVisibility; // TODO: replaced at FL-163 by a user setting
55-
5654
//|//////////////////////////////
5755
// Realm settings that lack events.
5856
// (Each of these is probably secretly a server setting.)
@@ -149,8 +147,6 @@ mixin ProxyRealmStore on RealmStore {
149147
@override
150148
RealmWildcardMentionPolicy get realmWildcardMentionPolicy => realmStore.realmWildcardMentionPolicy;
151149
@override
152-
EmailAddressVisibility? get emailAddressVisibility => realmStore.emailAddressVisibility;
153-
@override
154150
String get realmEmptyTopicDisplayName => realmStore.realmEmptyTopicDisplayName;
155151
@override
156152
Map<String, RealmDefaultExternalAccount> get realmDefaultExternalAccounts => realmStore.realmDefaultExternalAccounts;
@@ -187,7 +183,6 @@ class RealmStoreImpl extends PerAccountStoreBase with RealmStore {
187183
realmPresenceDisabled = initialSnapshot.realmPresenceDisabled,
188184
realmWaitingPeriodThreshold = initialSnapshot.realmWaitingPeriodThreshold,
189185
realmWildcardMentionPolicy = initialSnapshot.realmWildcardMentionPolicy,
190-
emailAddressVisibility = initialSnapshot.emailAddressVisibility,
191186
_realmEmptyTopicDisplayName = initialSnapshot.realmEmptyTopicDisplayName,
192187
realmDefaultExternalAccounts = initialSnapshot.realmDefaultExternalAccounts,
193188
customProfileFields = _sortCustomProfileFields(initialSnapshot.customProfileFields);
@@ -220,9 +215,6 @@ class RealmStoreImpl extends PerAccountStoreBase with RealmStore {
220215
@override
221216
final RealmWildcardMentionPolicy realmWildcardMentionPolicy;
222217

223-
@override
224-
final EmailAddressVisibility? emailAddressVisibility;
225-
226218
@override
227219
String get realmEmptyTopicDisplayName {
228220
assert(zulipFeatureLevel >= 334); // TODO(server-10)

lib/model/user.dart

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -95,31 +95,7 @@ mixin UserStore on PerAccountStoreBase, RealmStore {
9595
///
9696
/// Returns null if self-user isn't able to see the user's real email address,
9797
/// or if the user isn't actually a user we know about.
98-
String? userDisplayEmail(int userId) {
99-
final user = getUser(userId);
100-
if (user == null) return null;
101-
if (zulipFeatureLevel >= 163) { // TODO(server-7)
102-
// A non-null value means self-user has access to [user]'s real email,
103-
// while a null value means it doesn't have access to the email.
104-
// Search for "delivery_email" in https://zulip.com/api/register-queue.
105-
return user.deliveryEmail;
106-
} else {
107-
if (user.deliveryEmail != null) {
108-
// A non-null value means self-user has access to [user]'s real email,
109-
// while a null value doesn't necessarily mean it doesn't have access
110-
// to the email, ....
111-
return user.deliveryEmail;
112-
} else if (emailAddressVisibility == EmailAddressVisibility.everyone) {
113-
// ... we have to also check for [PerAccountStore.emailAddressVisibility].
114-
// See:
115-
// * https://github.com/zulip/zulip-mobile/pull/5515#discussion_r997731727
116-
// * https://chat.zulip.org/#narrow/stream/378-api-design/topic/email.20address.20visibility/near/1296133
117-
return user.email;
118-
} else {
119-
return null;
120-
}
121-
}
122-
}
98+
String? userDisplayEmail(int userId) => getUser(userId)?.deliveryEmail;
12399

124100
/// Whether [user] has passed the realm's waiting period to be a full member.
125101
///

test/example_data.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ int _lastEmailSuffix = 1000;
251251
/// other data in the test, or if the IDs need to increase in a different order
252252
/// from the calls to [user].
253253
///
254-
/// If `email` is not given, it defaults to `deliveryEmail` if given,
254+
/// If `email` is not given, it defaults to `deliveryEmail` if given and non-null,
255255
/// or else to a value resembling the Zulip server's generated fake emails.
256256
User user({
257257
int? userId,
@@ -1202,7 +1202,6 @@ InitialSnapshot initialSnapshot({
12021202
String? zulipMergeBase,
12031203
List<String>? alertWords,
12041204
List<CustomProfileField>? customProfileFields,
1205-
EmailAddressVisibility? emailAddressVisibility,
12061205
int? serverPresencePingIntervalSeconds,
12071206
int? serverPresenceOfflineThresholdSeconds,
12081207
int? serverTypingStartedExpiryPeriodMilliseconds,
@@ -1242,7 +1241,6 @@ InitialSnapshot initialSnapshot({
12421241
zulipMergeBase: zulipMergeBase ?? recentZulipVersion,
12431242
alertWords: alertWords ?? ['klaxon'],
12441243
customProfileFields: customProfileFields ?? [],
1245-
emailAddressVisibility: emailAddressVisibility ?? EmailAddressVisibility.everyone,
12461244
serverPresencePingIntervalSeconds: serverPresencePingIntervalSeconds ?? 60,
12471245
serverPresenceOfflineThresholdSeconds: serverPresenceOfflineThresholdSeconds ?? 140,
12481246
serverTypingStartedExpiryPeriodMilliseconds:

0 commit comments

Comments
 (0)