@@ -84,7 +84,7 @@ sealed class FcmMessageWithIdentity extends FcmMessage {
8484 ///
8585 /// Useful mainly in the case where the user has multiple accounts in the
8686 /// same realm.
87- @_IntConverter ( )
87+ @JsonKey (readValue : _readIntOrString) // TODO(server-12 )
8888 final int userId;
8989
9090 FcmMessageWithIdentity ({
@@ -110,7 +110,7 @@ class MessageFcmMessage extends FcmMessageWithIdentity {
110110 @JsonKey (includeToJson: true )
111111 String get type => 'message' ;
112112
113- @_IntConverter ( )
113+ @JsonKey (readValue : _readIntOrString) // TODO(server-12 )
114114 final int senderId;
115115 // final String senderEmail; // obsolete; ignore
116116 final Uri senderAvatarUrl;
@@ -121,7 +121,7 @@ class MessageFcmMessage extends FcmMessageWithIdentity {
121121
122122 @JsonKey (readValue: _readMessageId)
123123 final int messageId;
124- @_IntConverter ( )
124+ @JsonKey (readValue : _readIntOrString) // TODO(server-12 )
125125 final int time; // in Unix seconds UTC, like [Message.timestamp]
126126
127127 /// The content of the Zulip message, rendered as plain text.
@@ -301,4 +301,10 @@ class _IntConverter extends JsonConverter<int, String> {
301301 String toJson (int value) => value.toString ();
302302}
303303
304+ Object ? _readIntOrString (Map <dynamic , dynamic > json, String key) {
305+ final jsonValue = json[key];
306+ if (jsonValue is String ) return _parseInt (jsonValue);
307+ return jsonValue;
308+ }
309+
304310int _parseInt (String string) => int .parse (string, radix: 10 );
0 commit comments