@@ -61,6 +61,7 @@ sealed class Event {
61
61
default : return UnexpectedEvent .fromJson (json);
62
62
}
63
63
// case 'muted_topics': … // TODO(#422) we ignore this feature on older servers
64
+ case 'user_status' : return UserStatusEvent .fromJson (json);
64
65
case 'user_topic' : return UserTopicEvent .fromJson (json);
65
66
case 'muted_users' : return MutedUsersEvent .fromJson (json);
66
67
case 'message' : return MessageEvent .fromJson (json);
@@ -708,6 +709,40 @@ class SubscriptionPeerRemoveEvent extends SubscriptionEvent {
708
709
Map <String , dynamic > toJson () => _$SubscriptionPeerRemoveEventToJson (this );
709
710
}
710
711
712
+ /// A Zulip event of type `user_status` : https://zulip.com/api/get-events#user_status
713
+ @JsonSerializable (fieldRename: FieldRename .snake)
714
+ class UserStatusEvent extends Event {
715
+ @override
716
+ @JsonKey (includeToJson: true )
717
+ String get type => 'user_status' ;
718
+
719
+ final int userId;
720
+
721
+ @JsonKey (readValue: _readChange, includeToJson: false )
722
+ final UserStatusChange change;
723
+
724
+ static Object ? _readChange (Map <dynamic , dynamic > json, String key) {
725
+ assert (json is Map <String , dynamic >); // value came through `fromJson` with this type
726
+ json['status_text' ] as String ? ;
727
+ json['reaction_type' ] as String ? ;
728
+ json['emoji_code' ] as String ? ;
729
+ json['emoji_name' ] as String ? ;
730
+ return json;
731
+ }
732
+
733
+ UserStatusEvent ({
734
+ required super .id,
735
+ required this .userId,
736
+ required this .change,
737
+ });
738
+
739
+ factory UserStatusEvent .fromJson (Map <String , dynamic > json) =>
740
+ _$UserStatusEventFromJson (json);
741
+
742
+ @override
743
+ Map <String , dynamic > toJson () => _$UserStatusEventToJson (this );
744
+ }
745
+
711
746
/// A Zulip event of type `user_topic` : https://zulip.com/api/get-events#user_topic
712
747
@JsonSerializable (fieldRename: FieldRename .snake)
713
748
class UserTopicEvent extends Event {
0 commit comments