-
Notifications
You must be signed in to change notification settings - Fork 399
login: Reject earlier (at get-server-settings) when server is too old #1783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gnprice
merged 5 commits into
zulip:main
from
chrisbobbe:pr-ancient-servers-server-settings
Aug 7, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a55d8a9
dialog test [nfc]: Remove an unused import
chrisbobbe c67a4cc
login [nfc]: Tighten up some if-unmounted-returns; remove stale lint-…
chrisbobbe 6d02f42
server_support [nfc]: Move some server-support logic out to this new …
chrisbobbe 06f1b87
login test: Add happy-path test for AddAccountPage
chrisbobbe 733bb88
login: Reject earlier (at get-server-settings) when server is too old
chrisbobbe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import '../api/core.dart'; | ||
| import '../api/exception.dart'; | ||
| import '../api/model/initial_snapshot.dart'; | ||
| import '../api/route/realm.dart'; | ||
| import 'database.dart'; | ||
|
|
||
| /// The fields 'zulip_version', 'zulip_merge_base', and 'zulip_feature_level' | ||
| /// from a /server_settings or /register response. | ||
| class ZulipVersionData { | ||
| const ZulipVersionData({ | ||
| required this.zulipVersion, | ||
| required this.zulipMergeBase, | ||
| required this.zulipFeatureLevel, | ||
| }); | ||
|
|
||
| factory ZulipVersionData.fromServerSettings(GetServerSettingsResult serverSettings) => | ||
| ZulipVersionData( | ||
| zulipVersion: serverSettings.zulipVersion, | ||
| zulipMergeBase: serverSettings.zulipMergeBase, | ||
| zulipFeatureLevel: serverSettings.zulipFeatureLevel); | ||
|
|
||
| factory ZulipVersionData.fromInitialSnapshot(InitialSnapshot initialSnapshot) => | ||
| ZulipVersionData( | ||
| zulipVersion: initialSnapshot.zulipVersion, | ||
| zulipMergeBase: initialSnapshot.zulipMergeBase, | ||
| zulipFeatureLevel: initialSnapshot.zulipFeatureLevel); | ||
|
|
||
| /// Make a [ZulipVersionData] from a [MalformedServerResponseException], | ||
| /// if the body was readable/valid JSON and contained the data, else null. | ||
| /// | ||
| /// May be used for the /server_settings or the /register response. | ||
| /// | ||
| /// If there's a zulip_version but no zulip_feature_level, | ||
| /// we infer it's indeed a Zulip server, | ||
| /// just an ancient one before feature levels were introduced in Zulip 3.0, | ||
| /// and we set 0 for zulipFeatureLevel. | ||
| static ZulipVersionData? fromMalformedServerResponseException(MalformedServerResponseException e) { | ||
| try { | ||
| final data = e.data!; | ||
| return ZulipVersionData( | ||
| zulipVersion: data['zulip_version'] as String, | ||
| zulipMergeBase: data['zulip_merge_base'] as String?, | ||
| zulipFeatureLevel: data['zulip_feature_level'] as int? ?? 0); | ||
| } catch (inner) { | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| final String zulipVersion; | ||
| final String? zulipMergeBase; | ||
| final int zulipFeatureLevel; | ||
|
|
||
| bool matchesAccount(Account account) => | ||
| zulipVersion == account.zulipVersion | ||
| && zulipMergeBase == account.zulipMergeBase | ||
| && zulipFeatureLevel == account.zulipFeatureLevel; | ||
|
|
||
| bool get isUnsupported => zulipFeatureLevel < kMinSupportedZulipFeatureLevel; | ||
| } | ||
|
|
||
| class ServerVersionUnsupportedException implements Exception { | ||
| final ZulipVersionData data; | ||
|
|
||
| ServerVersionUnsupportedException(this.data); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,18 @@ | ||
| import 'package:checks/checks.dart'; | ||
| import 'package:zulip/api/route/messages.dart'; | ||
| import 'package:zulip/api/route/realm.dart'; | ||
| import 'package:zulip/api/route/saved_snippets.dart'; | ||
|
|
||
| extension SendMessageResultChecks on Subject<SendMessageResult> { | ||
| Subject<int> get id => has((e) => e.id, 'id'); | ||
| } | ||
|
|
||
| extension CreateSavedSnippetResultChecks on Subject<CreateSavedSnippetResult> { | ||
| Subject<int> get savedSnippetId => has((e) => e.savedSnippetId, 'savedSnippetId'); | ||
| } | ||
|
|
||
| extension GetServerSettingsResultChecks on Subject<GetServerSettingsResult> { | ||
| Subject<Uri> get realmUrl => has((e) => e.realmUrl, 'realmUrl'); | ||
| } | ||
|
|
||
| // TODO add similar extensions for other classes in api/route/*.dart |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,6 @@ import 'package:url_launcher/url_launcher.dart'; | |
| import 'package:zulip/model/settings.dart'; | ||
| import 'package:zulip/widgets/app.dart'; | ||
| import 'package:zulip/widgets/dialog.dart'; | ||
| import 'package:zulip/widgets/store.dart'; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, oops. I guess that changed in your revision of #1782, and I merged before CI finished running. … In fact I'm pretty sure I ran |
||
|
|
||
| import '../model/binding.dart'; | ||
| import 'dialog_checks.dart'; | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: third commit removes this line; second commit could omit adding it