@@ -8,7 +8,7 @@ use crate::chat::{send_msg, Chat, ChatId};
88use crate :: constants:: Chattype ;
99use crate :: context:: Context ;
1010use crate :: events:: EventType ;
11- use crate :: message:: { rfc724_mid_exists, Message , MsgId , Viewtype } ;
11+ use crate :: message:: { self , rfc724_mid_exists, Message , MsgId , Viewtype } ;
1212use crate :: mimeparser:: { MimeMessage , SystemMessage } ;
1313use crate :: param:: Param ;
1414use crate :: sync:: SyncData ;
@@ -52,6 +52,17 @@ impl CallInfo {
5252 let remaining_seconds = self . msg . timestamp_sent + RINGING_SECONDS - time ( ) ;
5353 remaining_seconds. clamp ( 0 , RINGING_SECONDS )
5454 }
55+
56+ async fn update_text ( & self , context : & Context , text : & str ) -> Result < ( ) > {
57+ context
58+ . sql
59+ . execute (
60+ "UPDATE msgs SET txt=?, txt_normalized=? WHERE id=?;" ,
61+ ( text, message:: normalize_text ( text) , self . msg . id ) ,
62+ )
63+ . await ?;
64+ Ok ( ( ) )
65+ }
5566}
5667
5768impl Context {
@@ -158,6 +169,7 @@ impl Context {
158169 let call = self . load_call_by_root_id ( call_or_child_id) . await ?;
159170 if call. incoming {
160171 if call. is_stale_call ( ) {
172+ call. update_text ( self , "Missed call" ) . await ?;
161173 self . emit_incoming_msg ( call. msg . chat_id , call_or_child_id) ;
162174 } else {
163175 self . emit_msgs_changed ( call. msg . chat_id , call_or_child_id) ;
@@ -531,4 +543,17 @@ mod tests {
531543
532544 Ok ( ( ) )
533545 }
546+
547+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
548+ async fn test_udpate_call_text ( ) -> Result < ( ) > {
549+ let ( alice, _alice2, alice_call, _bob, _bob2, _bob_call, _bob2_call) = setup_call ( ) . await ?;
550+
551+ let call_info = alice. load_call_by_root_id ( alice_call. id ) . await ?;
552+ call_info. update_text ( & alice, "foo bar" ) . await ?;
553+
554+ let alice_call = Message :: load_from_db ( & alice, alice_call. id ) . await ?;
555+ assert_eq ! ( alice_call. get_text( ) , "foo bar" ) ;
556+
557+ Ok ( ( ) )
558+ }
534559}
0 commit comments