@@ -6,7 +6,7 @@ use matrix_sdk::{
66 media:: { MediaFormat , MediaRequestParameters } ,
77 room:: Room ,
88 ruma:: events:: room:: {
9- message:: { MessageType , OriginalSyncRoomMessageEvent } ,
9+ message:: { MessageType , OriginalSyncRoomMessageEvent , Relation } ,
1010 MediaSource ,
1111 } ,
1212 Client , RoomState ,
@@ -122,22 +122,26 @@ async fn process_message_like_to_str(
122122 . localtime ( )
123123 . map ( |d| format ! ( "<{}> " , d) )
124124 . unwrap_or_default ( ) ;
125+ let thread = match & event. content . relates_to {
126+ Some ( Relation :: Thread ( _) ) => "<th> " ,
127+ _ => "" ,
128+ } ;
129+ let prefix = time_prefix + thread;
125130
126131 match & event. content . msgtype {
127- MessageType :: Text ( text_content) => (
128- time_prefix + text_content. body . as_str ( ) ,
129- IrcMessageType :: Privmsg ,
130- ) ,
132+ MessageType :: Text ( text_content) => {
133+ ( prefix + text_content. body . as_str ( ) , IrcMessageType :: Privmsg )
134+ }
131135 MessageType :: Emote ( emote_content) => (
132- format ! ( "\u{001} ACTION {}{}" , time_prefix , emote_content. body) ,
136+ format ! ( "\u{001} ACTION {}{}" , prefix , emote_content. body) ,
133137 IrcMessageType :: Privmsg ,
134138 ) ,
135139 MessageType :: Notice ( notice_content) => (
136- time_prefix + notice_content. body . as_str ( ) ,
140+ prefix + notice_content. body . as_str ( ) ,
137141 IrcMessageType :: Notice ,
138142 ) ,
139143 MessageType :: ServerNotice ( snotice_content) => (
140- time_prefix + snotice_content. body . as_str ( ) ,
144+ prefix + snotice_content. body . as_str ( ) ,
141145 IrcMessageType :: Notice ,
142146 ) ,
143147 MessageType :: File ( file_content) => {
@@ -147,10 +151,7 @@ async fn process_message_like_to_str(
147151 . await
148152 . unwrap_or_else ( |e| format ! ( "{}" , e) ) ;
149153 (
150- format ! (
151- "{}Sent a file, {}: {}" ,
152- time_prefix, & file_content. body, url
153- ) ,
154+ format ! ( "{}Sent a file, {}: {}" , prefix, & file_content. body, url) ,
154155 IrcMessageType :: Notice ,
155156 )
156157 }
@@ -161,10 +162,7 @@ async fn process_message_like_to_str(
161162 . await
162163 . unwrap_or_else ( |e| format ! ( "{}" , e) ) ;
163164 (
164- format ! (
165- "{}Sent an image, {}: {}" ,
166- time_prefix, & image_content. body, url
167- ) ,
165+ format ! ( "{}Sent an image, {}: {}" , prefix, & image_content. body, url) ,
168166 IrcMessageType :: Notice ,
169167 )
170168 }
@@ -175,10 +173,7 @@ async fn process_message_like_to_str(
175173 . await
176174 . unwrap_or_else ( |e| format ! ( "{}" , e) ) ;
177175 (
178- format ! (
179- "{}Sent a video, {}: {}" ,
180- time_prefix, & video_content. body, url
181- ) ,
176+ format ! ( "{}Sent a video, {}: {}" , prefix, & video_content. body, url) ,
182177 IrcMessageType :: Notice ,
183178 )
184179 }
@@ -189,10 +184,7 @@ async fn process_message_like_to_str(
189184 . await
190185 . unwrap_or_else ( |e| format ! ( "{}" , e) ) ;
191186 (
192- format ! (
193- "{}Sent audio, {}: {}" ,
194- time_prefix, & audio_content. body, url
195- ) ,
187+ format ! ( "{}Sent audio, {}: {}" , prefix, & audio_content. body, url) ,
196188 IrcMessageType :: Notice ,
197189 )
198190 }
@@ -203,15 +195,12 @@ async fn process_message_like_to_str(
203195 {
204196 warn ! ( "Verif failed: {}" , e) ;
205197 (
206- format ! (
207- "{}Sent a verification request, but failed: {}" ,
208- time_prefix, e
209- ) ,
198+ format ! ( "{}Sent a verification request, but failed: {}" , prefix, e) ,
210199 IrcMessageType :: Notice ,
211200 )
212201 } else {
213202 (
214- format ! ( "{}Sent a verification request" , time_prefix ) ,
203+ format ! ( "{}Sent a verification request" , prefix ) ,
215204 IrcMessageType :: Notice ,
216205 )
217206 }
@@ -224,13 +213,7 @@ async fn process_message_like_to_str(
224213 ""
225214 } ;
226215 (
227- format ! (
228- "{}Sent {}{}: {}" ,
229- time_prefix,
230- msg. msgtype( ) ,
231- data,
232- msg. body( )
233- ) ,
216+ format ! ( "{}Sent {}{}: {}" , prefix, msg. msgtype( ) , data, msg. body( ) ) ,
234217 IrcMessageType :: Privmsg ,
235218 )
236219 }
0 commit comments