@@ -24,6 +24,7 @@ use matrix_sdk::{
24
24
AttachmentConfig , AttachmentInfo , BaseAudioInfo , BaseFileInfo , BaseImageInfo ,
25
25
BaseThumbnailInfo , BaseVideoInfo , Thumbnail ,
26
26
} ,
27
+ deserialized_responses:: ShieldState as RustShieldState ,
27
28
Error ,
28
29
} ;
29
30
use matrix_sdk_ui:: timeline:: {
@@ -922,6 +923,30 @@ impl From<&matrix_sdk_ui::timeline::EventSendState> for EventSendState {
922
923
}
923
924
}
924
925
926
+ /// Recommended decorations for decrypted messages, representing the message's
927
+ /// authenticity properties.
928
+ #[ derive( uniffi:: Enum ) ]
929
+ pub enum ShieldState {
930
+ /// A red shield with a tooltip containing the associated message should be
931
+ /// presented.
932
+ Red { message : String } ,
933
+ /// A grey shield with a tooltip containing the associated message should be
934
+ /// presented.
935
+ Grey { message : String } ,
936
+ /// No shield should be presented.
937
+ None ,
938
+ }
939
+
940
+ impl From < RustShieldState > for ShieldState {
941
+ fn from ( value : RustShieldState ) -> Self {
942
+ match value {
943
+ RustShieldState :: Red { message } => Self :: Red { message : message. to_owned ( ) } ,
944
+ RustShieldState :: Grey { message } => Self :: Grey { message : message. to_owned ( ) } ,
945
+ RustShieldState :: None => Self :: None ,
946
+ }
947
+ }
948
+ }
949
+
925
950
#[ derive( uniffi:: Object ) ]
926
951
pub struct EventTimelineItem ( pub ( crate ) matrix_sdk_ui:: timeline:: EventTimelineItem ) ;
927
952
@@ -1008,6 +1033,12 @@ impl EventTimelineItem {
1008
1033
pub fn can_be_replied_to ( & self ) -> bool {
1009
1034
self . 0 . can_be_replied_to ( )
1010
1035
}
1036
+
1037
+ /// Gets the [`ShieldState`] which can be used to decorate messages in the
1038
+ /// recommended way.
1039
+ pub fn get_shield ( & self , strict : bool ) -> Option < ShieldState > {
1040
+ self . 0 . get_shield ( strict) . map ( Into :: into)
1041
+ }
1011
1042
}
1012
1043
1013
1044
#[ derive( uniffi:: Record ) ]
0 commit comments