@@ -8,7 +8,7 @@ use crate::chat::{send_msg, Chat, ChatId};
8
8
use crate :: constants:: Chattype ;
9
9
use crate :: context:: Context ;
10
10
use crate :: events:: EventType ;
11
- use crate :: message:: { rfc724_mid_exists, Message , MsgId , Viewtype } ;
11
+ use crate :: message:: { self , rfc724_mid_exists, Message , MsgId , Viewtype } ;
12
12
use crate :: mimeparser:: { MimeMessage , SystemMessage } ;
13
13
use crate :: param:: Param ;
14
14
use crate :: sync:: SyncData ;
@@ -52,6 +52,17 @@ impl CallInfo {
52
52
let remaining_seconds = self . msg . timestamp_sent + RINGING_SECONDS - time ( ) ;
53
53
remaining_seconds. clamp ( 0 , RINGING_SECONDS )
54
54
}
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
+ }
55
66
}
56
67
57
68
impl Context {
@@ -158,6 +169,7 @@ impl Context {
158
169
let call = self . load_call_by_root_id ( call_or_child_id) . await ?;
159
170
if call. incoming {
160
171
if call. is_stale_call ( ) {
172
+ call. update_text ( self , "Missed call" ) . await ?;
161
173
self . emit_incoming_msg ( call. msg . chat_id , call_or_child_id) ;
162
174
} else {
163
175
self . emit_msgs_changed ( call. msg . chat_id , call_or_child_id) ;
@@ -531,4 +543,17 @@ mod tests {
531
543
532
544
Ok ( ( ) )
533
545
}
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
+ }
534
559
}
0 commit comments