@@ -27,7 +27,7 @@ use ruma::{
27
27
SyncRoomMessageEvent ,
28
28
} ,
29
29
AnyMessageLikeEventContent , AnySyncMessageLikeEvent , AnyTimelineEvent ,
30
- BundledMessageLikeRelations ,
30
+ BundledMessageLikeRelations , Mentions ,
31
31
} ,
32
32
html:: RemoveReplyFallback ,
33
33
OwnedEventId , OwnedUserId , RoomVersionId , UserId ,
@@ -52,6 +52,7 @@ pub struct Message {
52
52
/// Event ID of the thread root, if this is a threaded message.
53
53
pub ( in crate :: timeline) thread_root : Option < OwnedEventId > ,
54
54
pub ( in crate :: timeline) edited : bool ,
55
+ pub ( in crate :: timeline) mentions : Option < Mentions > ,
55
56
}
56
57
57
58
impl Message {
@@ -94,11 +95,11 @@ impl Message {
94
95
_ => None ,
95
96
} ) ;
96
97
97
- let msgtype = match edit {
98
+ let ( msgtype, mentions ) = match edit {
98
99
Some ( mut e) => {
99
100
// Edit's content is never supposed to contain the reply fallback.
100
101
e. new_content . msgtype . sanitize ( DEFAULT_SANITIZER_MODE , RemoveReplyFallback :: No ) ;
101
- e. new_content . msgtype
102
+ ( e. new_content . msgtype , e . new_content . mentions )
102
103
}
103
104
None => {
104
105
let remove_reply_fallback = if in_reply_to. is_some ( ) {
@@ -109,11 +110,11 @@ impl Message {
109
110
110
111
let mut msgtype = c. msgtype ;
111
112
msgtype. sanitize ( DEFAULT_SANITIZER_MODE , remove_reply_fallback) ;
112
- msgtype
113
+ ( msgtype, c . mentions )
113
114
}
114
115
} ;
115
116
116
- Self { msgtype, in_reply_to, thread_root, edited }
117
+ Self { msgtype, in_reply_to, thread_root, edited, mentions }
117
118
}
118
119
119
120
/// Get the `msgtype`-specific data of this message.
@@ -144,6 +145,11 @@ impl Message {
144
145
self . edited
145
146
}
146
147
148
+ /// Get the mentions of this message.
149
+ pub fn mentions ( & self ) -> Option < & Mentions > {
150
+ self . mentions . as_ref ( )
151
+ }
152
+
147
153
pub ( in crate :: timeline) fn to_content ( & self ) -> RoomMessageEventContent {
148
154
// Like the `impl From<Message> for RoomMessageEventContent` below, but
149
155
// takes &self and only copies what's needed.
@@ -192,7 +198,7 @@ fn make_relates_to(
192
198
#[ cfg( not( tarpaulin_include) ) ]
193
199
impl fmt:: Debug for Message {
194
200
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
195
- let Self { msgtype : _, in_reply_to, thread_root, edited } = self ;
201
+ let Self { msgtype : _, in_reply_to, thread_root, edited, mentions : _ } = self ;
196
202
// since timeline items are logged, don't include all fields here so
197
203
// people don't leak personal data in bug reports
198
204
f. debug_struct ( "Message" )
0 commit comments