@@ -69,6 +69,7 @@ sealed class Event {
69
69
default : return UnexpectedEvent .fromJson (json);
70
70
}
71
71
// case 'muted_topics': … // TODO(#422) we ignore this feature on older servers
72
+ case 'user_status' : return UserStatusEvent .fromJson (json);
72
73
case 'user_topic' : return UserTopicEvent .fromJson (json);
73
74
case 'muted_users' : return MutedUsersEvent .fromJson (json);
74
75
case 'message' : return MessageEvent .fromJson (json);
@@ -797,6 +798,41 @@ class SubscriptionPeerRemoveEvent extends SubscriptionEvent {
797
798
Map <String , dynamic > toJson () => _$SubscriptionPeerRemoveEventToJson (this );
798
799
}
799
800
801
+ /// A Zulip event of type `user_status` : https://zulip.com/api/get-events#user_status
802
+ @JsonSerializable (fieldRename: FieldRename .snake, createToJson: false )
803
+ class UserStatusEvent extends Event {
804
+ @override
805
+ @JsonKey (includeToJson: true )
806
+ String get type => 'user_status' ;
807
+
808
+ final int userId;
809
+
810
+ @JsonKey (readValue: _readChange)
811
+ final UserStatusChange change;
812
+
813
+ static Object ? _readChange (Map <dynamic , dynamic > json, String key) {
814
+ assert (json is Map <String , dynamic >); // value came through `fromJson` with this type
815
+ return json;
816
+ }
817
+
818
+ UserStatusEvent ({
819
+ required super .id,
820
+ required this .userId,
821
+ required this .change,
822
+ });
823
+
824
+ factory UserStatusEvent .fromJson (Map <String , dynamic > json) =>
825
+ _$UserStatusEventFromJson (json);
826
+
827
+ @override
828
+ Map <String , dynamic > toJson () => {
829
+ 'id' : id,
830
+ 'type' : type,
831
+ 'user_id' : userId,
832
+ ...change.toJson (),
833
+ };
834
+ }
835
+
800
836
/// A Zulip event of type `user_topic` : https://zulip.com/api/get-events#user_topic
801
837
@JsonSerializable (fieldRename: FieldRename .snake)
802
838
class UserTopicEvent extends Event {
0 commit comments