@@ -35,10 +35,10 @@ use crate::reaction::get_msg_reactions;
3535use crate :: sql;
3636use crate :: summary:: Summary ;
3737use crate :: sync:: SyncData ;
38- use crate :: tools:: create_outgoing_rfc724_mid;
3938use crate :: tools:: {
4039 buf_compress, buf_decompress, get_filebytes, get_filemeta, gm2local_offset, read_file,
41- sanitize_filename, time, timestamp_to_str,
40+ sanitize_filename, time, timestamp_to_str, truncate_msg_text,
41+ create_outgoing_rfc724_mid
4242} ;
4343
4444/// Message ID, including reserved IDs.
@@ -431,7 +431,13 @@ pub struct Message {
431431 pub ( crate ) timestamp_rcvd : i64 ,
432432 pub ( crate ) ephemeral_timer : EphemeralTimer ,
433433 pub ( crate ) ephemeral_timestamp : i64 ,
434+
435+ /// Message text, possibly truncated if the message is large.
434436 pub ( crate ) text : String ,
437+
438+ /// Full text if the message text is truncated.
439+ pub ( crate ) full_text : Option < String > ,
440+
435441 /// Text that is added to the end of Message.text
436442 ///
437443 /// Currently used for adding the download information on pre-messages
@@ -556,6 +562,7 @@ impl Message {
556562 }
557563 _ => String :: new ( ) ,
558564 } ;
565+
559566 let msg = Message {
560567 id : row. get ( "id" ) ?,
561568 rfc724_mid : row. get :: < _ , String > ( "rfc724mid" ) ?,
@@ -580,6 +587,7 @@ impl Message {
580587 original_msg_id : row. get ( "original_msg_id" ) ?,
581588 mime_modified : row. get ( "mime_modified" ) ?,
582589 text,
590+ full_text : None ,
583591 additional_text : String :: new ( ) ,
584592 subject : row. get ( "subject" ) ?,
585593 param : row. get :: < _ , String > ( "param" ) ?. parse ( ) . unwrap_or_default ( ) ,
@@ -597,6 +605,15 @@ impl Message {
597605 . with_context ( || format ! ( "failed to load message {id} from the database" ) ) ?;
598606
599607 if let Some ( msg) = & mut msg {
608+ if !msg. mime_modified {
609+ let ( truncated_text, was_truncated) =
610+ truncate_msg_text ( context, msg. text . clone ( ) ) . await ?;
611+ if was_truncated {
612+ msg. full_text = Some ( msg. text . clone ( ) ) ;
613+ msg. text = truncated_text;
614+ }
615+ }
616+
600617 msg. additional_text =
601618 Self :: get_additional_text ( context, msg. download_state , & msg. param ) . await ?;
602619 }
0 commit comments