-
Notifications
You must be signed in to change notification settings - Fork 309
Start Requiring Zulip Server 5 #904
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
base: main
Are you sure you want to change the base?
Changes from all commits
d64620c
9f0e5c5
77b77e2
641a77f
66bcff8
ab318a9
0bd5ed5
b4d6fc2
34da2f5
63d0011
4ad8754
d238e43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -708,13 +708,13 @@ class UpdateMessageEvent extends Event { | |
@JsonKey(includeToJson: true) | ||
String get type => 'update_message'; | ||
|
||
final int? userId; // TODO(server-5) | ||
final bool? renderingOnly; // TODO(server-5) | ||
final int userId; | ||
final bool renderingOnly; | ||
final int messageId; | ||
final List<int> messageIds; | ||
|
||
final List<MessageFlag> flags; | ||
final int? editTimestamp; // TODO(server-5) | ||
final int editTimestamp; | ||
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. nit: this doesn't seem accurate:
since those fields are no longer optional. I think the commit message can skip explaining the fallback that previously existed for renderingOnly. It's directly relevant only when looking at the past; and the details are in this commit's diff. 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. Yeah, "were" would be more accurate here. Leaving this out makes sense. |
||
|
||
// final String? streamName; // ignore | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ class InitialSnapshot { | |
final int lastEventId; | ||
final int zulipFeatureLevel; | ||
final String zulipVersion; | ||
final String? zulipMergeBase; // TODO(server-5) | ||
final String zulipMergeBase; | ||
|
||
final List<String> alertWords; | ||
|
||
|
@@ -54,13 +54,7 @@ class InitialSnapshot { | |
|
||
final List<ZulipStream> streams; | ||
|
||
// Servers pre-5.0 don't have `user_settings`, and instead provide whatever | ||
// user settings they support at toplevel in the initial snapshot. Since we're | ||
// likely to desupport pre-5.0 servers before wide release, we prefer to | ||
// ignore the toplevel fields and use `user_settings` where present instead, | ||
// even at the expense of functionality with pre-5.0 servers. | ||
// TODO(server-5) remove pre-5.0 comment | ||
final UserSettings? userSettings; // TODO(server-5) | ||
final UserSettings userSettings; | ||
|
||
final List<UserTopicItem>? userTopics; // TODO(server-6) | ||
|
||
|
@@ -312,15 +306,9 @@ class UnreadMessagesSnapshot { | |
/// An item in [UnreadMessagesSnapshot.dms]. | ||
@JsonSerializable(fieldRename: FieldRename.snake) | ||
class UnreadDmSnapshot { | ||
@JsonKey(readValue: _readOtherUserId) | ||
final int otherUserId; | ||
Comment on lines
308
to
309
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. nit:
that's not the class this field is on 🙂 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. Good find! I should learn to not trust the diffs heading and be more careful from now on 😓 diff --git a/lib/api/model/initial_snapshot.dart b/lib/api/model/initial_snapshot.dart
index 565d89fe..6be29e78 100644
--- a/lib/api/model/initial_snapshot.dart
+++ b/lib/api/model/initial_snapshot.dart
@@ -269,15 +269,9 @@ class UnreadMessagesSnapshot {
/// An item in [UnreadMessagesSnapshot.dms].
@JsonSerializable(fieldRename: FieldRename.snake)
class UnreadDmSnapshot {
- @JsonKey(readValue: _readOtherUserId)
final int otherUserId;
final List<int> unreadMessageIds;
- // TODO(server-5): Simplify away.
- static dynamic _readOtherUserId(Map<dynamic, dynamic> json, String key) {
- return json[key] ?? json['sender_id'];
- }
- 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, yeah, the diff-hunk headers can be misleading like that sometimes 🙂 |
||
final List<int> unreadMessageIds; | ||
|
||
// TODO(server-5): Simplify away. | ||
static dynamic _readOtherUserId(Map<dynamic, dynamic> json, String key) { | ||
return json[key] ?? json['sender_id']; | ||
} | ||
|
||
UnreadDmSnapshot({ | ||
required this.otherUserId, | ||
required this.unreadMessageIds, | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -205,7 +205,7 @@ class User { | |
// bool isOwner; // obsoleted by [role]; ignore | ||
// bool isAdmin; // obsoleted by [role]; ignore | ||
// bool isGuest; // obsoleted by [role]; ignore | ||
bool? isBillingAdmin; // TODO(server-5) | ||
bool isBillingAdmin; | ||
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.
I would just leave out the sentence about how Also nit in summary line: 'required" 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. nit in commit message:
In the summary line, let's say User.isBillingAdmin rather than just isBillingAdmin. Similarly for fields in later commits. That helps the reader place the field in the relevant context within the overall model. In this case it also disambiguates things: there's an 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. Yeah, I think the context info is pretty helpful. While the commit summaries get longer, it is justified for this kind of migration changes. |
||
final bool isBot; | ||
final int? botType; // TODO enum | ||
int? botOwnerId; | ||
|
@@ -221,7 +221,9 @@ class User { | |
@JsonKey(readValue: _readProfileData) | ||
Map<int, ProfileFieldUserData>? profileData; | ||
|
||
@JsonKey(readValue: _readIsSystemBot) | ||
// This field is absent in `realm_users` and `realm_non_active_users`, | ||
// which contain no system bots; it's present in `cross_realm_bots`. | ||
@JsonKey(defaultValue: false) | ||
final bool isSystemBot; | ||
|
||
static Map<String, dynamic>? _readProfileData(Map<dynamic, dynamic> json, String key) { | ||
|
@@ -233,14 +235,6 @@ class User { | |
return (value != null && value.isNotEmpty) ? value : null; | ||
} | ||
|
||
static bool _readIsSystemBot(Map<dynamic, dynamic> json, String key) { | ||
// This field is absent in `realm_users` and `realm_non_active_users`, | ||
// which contain no system bots; it's present in `cross_realm_bots`. | ||
Comment on lines
-237
to
-238
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.
This comment still applies, right? The change made in FL 83 is just that |
||
return (json[key] as bool?) | ||
?? (json['is_cross_realm_bot'] as bool?) // TODO(server-5): renamed to `is_system_bot` | ||
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. nit in commit message:
Can focus the summary on what changed in the API, rather than on the method name which is an implementation detail of our (now-deleted) code:
|
||
?? false; | ||
} | ||
|
||
User({ | ||
required this.userId, | ||
required this.deliveryEmail, | ||
|
@@ -924,18 +918,15 @@ enum MessageEditState { | |
continue; | ||
} | ||
|
||
// TODO(server-5) prev_subject was the old name of prev_topic on pre-5.0 servers | ||
final prevTopicStr = (entry['prev_topic'] ?? entry['prev_subject']) as String?; | ||
final prevTopicStr = entry['prev_topic'] as String?; | ||
final prevTopic = prevTopicStr == null ? null : TopicName.fromJson(prevTopicStr); | ||
final topicStr = entry['topic'] as String?; | ||
final topic = topicStr == null ? null : TopicName.fromJson(topicStr); | ||
if (prevTopic != null) { | ||
// TODO(server-5) pre-5.0 servers do not have the 'topic' field | ||
if (topic == null) { | ||
hasMoved = true; | ||
} else { | ||
hasMoved |= !topicMoveWasResolveOrUnresolve(topic, prevTopic); | ||
} | ||
if (topic != null || prevTopic != null) { | ||
// Crunchy-shell validation: Both are present if the topic was edited | ||
topic as TopicName; | ||
prevTopic as TopicName; | ||
hasMoved |= !topicMoveWasResolveOrUnresolve(topic, prevTopic); | ||
} | ||
} | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ import 'package:flutter/foundation.dart'; | |
class WebAuthPayload { | ||
final Uri realm; | ||
final String email; | ||
final int? userId; // TODO(server-5) new in FL 108 | ||
final int userId; | ||
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. This is one that especially benefits from identifying the class:
so e.g.:
Otherwise "userId" could be all sorts of things. 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. bump / nit: use (in this revision it's:
) |
||
final String otpEncryptedApiKey; | ||
|
||
WebAuthPayload._({ | ||
|
@@ -25,21 +25,16 @@ class WebAuthPayload { | |
queryParameters: { | ||
'realm': String realmStr, | ||
'email': String email, | ||
// 'user_id' handled below | ||
'user_id': String userIdStr, | ||
'otp_encrypted_api_key': String otpEncryptedApiKey, | ||
}, | ||
) | ||
) { | ||
final Uri? realm = Uri.tryParse(realmStr); | ||
if (realm == null) throw const FormatException(); | ||
|
||
// TODO(server-5) require in queryParameters (new in FL 108) | ||
final userIdStr = url.queryParameters['user_id']; | ||
int? userId; | ||
if (userIdStr != null) { | ||
userId = int.tryParse(userIdStr, radix: 10); | ||
if (userId == null) throw const FormatException(); | ||
} | ||
final userId = int.tryParse(userIdStr, radix: 10); | ||
if (userId == null) throw const FormatException(); | ||
|
||
if (!RegExp(r'^[0-9a-fA-F]{64}$').hasMatch(otpEncryptedApiKey)) { | ||
throw const FormatException(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,16 @@ | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
import '../core.dart'; | ||
import '../exception.dart'; | ||
import '../model/model.dart'; | ||
import '../model/narrow.dart'; | ||
|
||
part 'messages.g.dart'; | ||
|
||
/// Convenience function to get a single message from any server. | ||
/// | ||
/// This encapsulates a server-feature check. | ||
/// | ||
/// Gives null if the server reports that the message doesn't exist. | ||
// TODO(server-5) Simplify this away; just use getMessage. | ||
Future<Message?> getMessageCompat(ApiConnection connection, { | ||
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. nit in commit message:
Instead say:
That way it's clear this hex blob refers to a commit (implicitly one in this same repo). |
||
required int messageId, | ||
bool? applyMarkdown, | ||
}) async { | ||
final useLegacyApi = connection.zulipFeatureLevel! < 120; | ||
if (useLegacyApi) { | ||
final response = await getMessages(connection, | ||
narrow: [ApiNarrowMessageId(messageId)], | ||
anchor: NumericAnchor(messageId), | ||
numBefore: 0, | ||
numAfter: 0, | ||
applyMarkdown: applyMarkdown, | ||
|
||
// Hard-code this param to `true`, as the new single-message API | ||
// effectively does: | ||
// https://chat.zulip.org/#narrow/stream/378-api-design/topic/.60client_gravatar.60.20in.20.60messages.2F.7Bmessage_id.7D.60/near/1418337 | ||
clientGravatar: true, | ||
); | ||
return response.messages.firstOrNull; | ||
} else { | ||
try { | ||
final response = await getMessage(connection, | ||
messageId: messageId, | ||
applyMarkdown: applyMarkdown, | ||
); | ||
return response.message; | ||
} on ZulipApiException catch (e) { | ||
if (e.code == 'BAD_REQUEST') { | ||
// Servers use this code when the message doesn't exist, according to | ||
// the example in the doc. | ||
return null; | ||
} | ||
rethrow; | ||
} | ||
} | ||
} | ||
|
||
/// https://zulip.com/api/get-message | ||
/// | ||
/// This binding only supports feature levels 120+. | ||
// TODO(server-5) remove FL 120+ mention in doc, and the related `assert` | ||
Future<GetMessageResult> getMessage(ApiConnection connection, { | ||
required int messageId, | ||
bool? applyMarkdown, | ||
}) { | ||
assert(connection.zulipFeatureLevel! >= 120); | ||
return connection.get('getMessage', GetMessageResult.fromJson, 'messages/$messageId', { | ||
if (applyMarkdown != null) 'apply_markdown': applyMarkdown, | ||
}); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -456,7 +456,7 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel | |
/// Will throw if called after [dispose] has been called. | ||
Account get account => _globalStore.getAccount(accountId)!; | ||
|
||
final UserSettings? userSettings; // TODO(server-5) | ||
final UserSettings userSettings; | ||
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. This should get a corresponding update in PerAccountStoreChecks. (Similarly in other commits.) |
||
|
||
final TypingNotifier typingNotifier; | ||
|
||
|
@@ -626,11 +626,11 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel | |
} | ||
switch (event.property!) { | ||
case UserSettingName.twentyFourHourTime: | ||
userSettings?.twentyFourHourTime = event.value as bool; | ||
userSettings.twentyFourHourTime = event.value as bool; | ||
case UserSettingName.displayEmojiReactionUsers: | ||
userSettings?.displayEmojiReactionUsers = event.value as bool; | ||
userSettings.displayEmojiReactionUsers = event.value as bool; | ||
case UserSettingName.emojiset: | ||
userSettings?.emojiset = event.value as Emojiset; | ||
userSettings.emojiset = event.value as Emojiset; | ||
} | ||
notifyListeners(); | ||
|
||
|
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: this summary line seems to cover only one of the three changes here:
Can say "fields on UpdateMessageEvent" to skip listing all three of them in the crowded space of the summary line.