Skip to content

Commit b38efb2

Browse files
committed
api: Don't allow connecting to servers <4.0
From the README: https://github.com/zulip/zulip-flutter?tab=readme-ov-file#server-compatibility > We support Zulip Server 4.0 and later. This implementation isn't ideal because it logs you out, instead of just taking down the account's UI as we discussed: https://chat.zulip.org/#narrow/channel/243-mobile-team/topic/.23F267.20Disallow.20connecting.20to.20unsupported.20ancient.20servers/near/2104182 But it was simpler this way since programmatically logging out is already an action we handle. Fixes: #267
1 parent 40b1426 commit b38efb2

15 files changed

+264
-6
lines changed

assets/l10n/app_en.arb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,15 @@
538538
"@topicValidationErrorMandatoryButEmpty": {
539539
"description": "Topic validation error when topic is required but was empty."
540540
},
541+
"errorServerVersionUnsupportedMessage": "{url} is running Zulip Server {zulipVersion}, which is unsupported. The minimum supported version is Zulip Server {minSupportedZulipVersion}.",
542+
"@errorServerVersionUnsupportedMessage": {
543+
"description": "Error message in the dialog for when the Zulip Server version is unsupported.",
544+
"placeholders": {
545+
"url": {"type": "String", "example": "http://chat.example.com/"},
546+
"zulipVersion": {"type": "String", "example": "3.2"},
547+
"minSupportedZulipVersion": {"type": "String", "example": "4.0"}
548+
}
549+
},
541550
"errorInvalidApiKeyMessage": "Your account at {url} could not be authenticated. Please try logging in again or use another account.",
542551
"@errorInvalidApiKeyMessage": {
543552
"description": "Error message in the dialog for invalid API key.",

lib/api/core.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,24 @@ import '../model/binding.dart';
1010
import '../model/localizations.dart';
1111
import 'exception.dart';
1212

13+
/// The Zulip Server version below which we should refuse to connect.
14+
///
15+
/// When updating this, also update [kMinSupportedZulipFeatureLevel]
16+
/// and the README.
17+
const kMinSupportedZulipVersion = '4.0';
18+
19+
/// The Zulip feature level reserved for the [minSupportedZulipVersion] release.
20+
///
21+
/// For this value, see the API changelog:
22+
/// https://zulip.com/api/changelog
23+
const kMinSupportedZulipFeatureLevel = 65;
24+
25+
/// The doc stating our oldest supported server version.
26+
// TODO: Instead, link to new Help Center doc once we have it:
27+
// https://github.com/zulip/zulip/issues/23842
28+
final kServerSupportDocUrl = Uri.parse(
29+
'https://zulip.readthedocs.io/en/latest/overview/release-lifecycle.html#compatibility-and-upgrading');
30+
1331
/// A fused JSON + UTF-8 decoder.
1432
///
1533
/// This object is an instance of [`_JsonUtf8Decoder`][1] which is

lib/generated/l10n/zulip_localizations.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,12 @@ abstract class ZulipLocalizations {
825825
/// **'Topics are required in this organization.'**
826826
String get topicValidationErrorMandatoryButEmpty;
827827

828+
/// Error message in the dialog for when the Zulip Server version is unsupported.
829+
///
830+
/// In en, this message translates to:
831+
/// **'{url} is running Zulip Server {zulipVersion}, which is unsupported. The minimum supported version is Zulip Server {minSupportedZulipVersion}.'**
832+
String errorServerVersionUnsupportedMessage(String url, String zulipVersion, String minSupportedZulipVersion);
833+
828834
/// Error message in the dialog for invalid API key.
829835
///
830836
/// In en, this message translates to:

lib/generated/l10n/zulip_localizations_ar.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,11 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
416416
@override
417417
String get topicValidationErrorMandatoryButEmpty => 'Topics are required in this organization.';
418418

419+
@override
420+
String errorServerVersionUnsupportedMessage(String url, String zulipVersion, String minSupportedZulipVersion) {
421+
return '$url is running Zulip Server $zulipVersion, which is unsupported. The minimum supported version is Zulip Server $minSupportedZulipVersion.';
422+
}
423+
419424
@override
420425
String errorInvalidApiKeyMessage(String url) {
421426
return 'Your account at $url could not be authenticated. Please try logging in again or use another account.';

lib/generated/l10n/zulip_localizations_en.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,11 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
416416
@override
417417
String get topicValidationErrorMandatoryButEmpty => 'Topics are required in this organization.';
418418

419+
@override
420+
String errorServerVersionUnsupportedMessage(String url, String zulipVersion, String minSupportedZulipVersion) {
421+
return '$url is running Zulip Server $zulipVersion, which is unsupported. The minimum supported version is Zulip Server $minSupportedZulipVersion.';
422+
}
423+
419424
@override
420425
String errorInvalidApiKeyMessage(String url) {
421426
return 'Your account at $url could not be authenticated. Please try logging in again or use another account.';

lib/generated/l10n/zulip_localizations_ja.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,11 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
416416
@override
417417
String get topicValidationErrorMandatoryButEmpty => 'Topics are required in this organization.';
418418

419+
@override
420+
String errorServerVersionUnsupportedMessage(String url, String zulipVersion, String minSupportedZulipVersion) {
421+
return '$url is running Zulip Server $zulipVersion, which is unsupported. The minimum supported version is Zulip Server $minSupportedZulipVersion.';
422+
}
423+
419424
@override
420425
String errorInvalidApiKeyMessage(String url) {
421426
return 'Your account at $url could not be authenticated. Please try logging in again or use another account.';

lib/generated/l10n/zulip_localizations_nb.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,11 @@ class ZulipLocalizationsNb extends ZulipLocalizations {
416416
@override
417417
String get topicValidationErrorMandatoryButEmpty => 'Topics are required in this organization.';
418418

419+
@override
420+
String errorServerVersionUnsupportedMessage(String url, String zulipVersion, String minSupportedZulipVersion) {
421+
return '$url is running Zulip Server $zulipVersion, which is unsupported. The minimum supported version is Zulip Server $minSupportedZulipVersion.';
422+
}
423+
419424
@override
420425
String errorInvalidApiKeyMessage(String url) {
421426
return 'Your account at $url could not be authenticated. Please try logging in again or use another account.';

lib/generated/l10n/zulip_localizations_pl.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,11 @@ class ZulipLocalizationsPl extends ZulipLocalizations {
416416
@override
417417
String get topicValidationErrorMandatoryButEmpty => 'Wątki są wymagane przez tę organizację.';
418418

419+
@override
420+
String errorServerVersionUnsupportedMessage(String url, String zulipVersion, String minSupportedZulipVersion) {
421+
return '$url is running Zulip Server $zulipVersion, which is unsupported. The minimum supported version is Zulip Server $minSupportedZulipVersion.';
422+
}
423+
419424
@override
420425
String errorInvalidApiKeyMessage(String url) {
421426
return 'Your account at $url could not be authenticated. Please try logging in again or use another account.';

lib/generated/l10n/zulip_localizations_ru.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,11 @@ class ZulipLocalizationsRu extends ZulipLocalizations {
416416
@override
417417
String get topicValidationErrorMandatoryButEmpty => 'Темы обязательны в этой организации.';
418418

419+
@override
420+
String errorServerVersionUnsupportedMessage(String url, String zulipVersion, String minSupportedZulipVersion) {
421+
return '$url is running Zulip Server $zulipVersion, which is unsupported. The minimum supported version is Zulip Server $minSupportedZulipVersion.';
422+
}
423+
419424
@override
420425
String errorInvalidApiKeyMessage(String url) {
421426
return 'Your account at $url could not be authenticated. Please try logging in again or use another account.';

lib/generated/l10n/zulip_localizations_sk.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,11 @@ class ZulipLocalizationsSk extends ZulipLocalizations {
416416
@override
417417
String get topicValidationErrorMandatoryButEmpty => 'Topics are required in this organization.';
418418

419+
@override
420+
String errorServerVersionUnsupportedMessage(String url, String zulipVersion, String minSupportedZulipVersion) {
421+
return '$url is running Zulip Server $zulipVersion, which is unsupported. The minimum supported version is Zulip Server $minSupportedZulipVersion.';
422+
}
423+
419424
@override
420425
String errorInvalidApiKeyMessage(String url) {
421426
return 'Your account at $url could not be authenticated. Please try logging in again or use another account.';

0 commit comments

Comments
 (0)