@@ -15,6 +15,7 @@ use crate::message::{Message, MsgId, Viewtype};
1515use crate :: mimeparser:: { MimeMessage , SystemMessage } ;
1616use crate :: net:: dns:: lookup_host_with_cache;
1717use crate :: param:: Param ;
18+ use crate :: stock_str;
1819use crate :: tools:: { normalize_text, time} ;
1920use anyhow:: { Context as _, Result , ensure} ;
2021use deltachat_derive:: { FromSql , ToSql } ;
@@ -200,9 +201,10 @@ impl Context {
200201 ) ;
201202 ensure ! ( !chat. is_self_talk( ) , "Cannot call self" ) ;
202203
204+ let outgoing_call_str = stock_str:: outgoing_call ( self ) . await ;
203205 let mut call = Message {
204206 viewtype : Viewtype :: Call ,
205- text : "Outgoing call" . into ( ) ,
207+ text : outgoing_call_str ,
206208 ..Default :: default ( )
207209 } ;
208210 call. param . set ( Param :: WebrtcRoom , & place_call_info) ;
@@ -275,10 +277,12 @@ impl Context {
275277 if !call. is_accepted ( ) {
276278 if call. is_incoming ( ) {
277279 call. mark_as_ended ( self ) . await ?;
278- call. update_text ( self , "Declined call" ) . await ?;
280+ let declined_call_str = stock_str:: declined_call ( self ) . await ;
281+ call. update_text ( self , & declined_call_str) . await ?;
279282 } else {
280283 call. mark_as_canceled ( self ) . await ?;
281- call. update_text ( self , "Canceled call" ) . await ?;
284+ let canceled_call_str = stock_str:: canceled_call ( self ) . await ;
285+ call. update_text ( self , & canceled_call_str) . await ?;
282286 }
283287 } else {
284288 call. mark_as_ended ( self ) . await ?;
@@ -320,10 +324,12 @@ impl Context {
320324 if !call. is_accepted ( ) && !call. is_ended ( ) {
321325 if call. is_incoming ( ) {
322326 call. mark_as_canceled ( & context) . await ?;
323- call. update_text ( & context, "Missed call" ) . await ?;
327+ let missed_call_str = stock_str:: missed_call ( & context) . await ;
328+ call. update_text ( & context, & missed_call_str) . await ?;
324329 } else {
325330 call. mark_as_ended ( & context) . await ?;
326- call. update_text ( & context, "Canceled call" ) . await ?;
331+ let canceled_call_str = stock_str:: canceled_call ( & context) . await ;
332+ call. update_text ( & context, & canceled_call_str) . await ?;
327333 }
328334 context. emit_msgs_changed ( call. msg . chat_id , call_id) ;
329335 context. emit_event ( EventType :: CallEnded {
@@ -348,10 +354,12 @@ impl Context {
348354
349355 if call. is_incoming ( ) {
350356 if call. is_stale ( ) {
351- call. update_text ( self , "Missed call" ) . await ?;
357+ let missed_call_str = stock_str:: missed_call ( self ) . await ;
358+ call. update_text ( self , & missed_call_str) . await ?;
352359 self . emit_incoming_msg ( call. msg . chat_id , call_id) ; // notify missed call
353360 } else {
354- call. update_text ( self , "Incoming call" ) . await ?;
361+ let incoming_call_str = stock_str:: incoming_call ( self ) . await ;
362+ call. update_text ( self , & incoming_call_str) . await ?;
355363 self . emit_msgs_changed ( call. msg . chat_id , call_id) ; // ringing calls are not additionally notified
356364 let can_call_me = match who_can_call_me ( self ) . await ? {
357365 WhoCanCallMe :: Contacts => ChatIdBlocked :: lookup_by_contact ( self , from_id)
@@ -391,7 +399,8 @@ impl Context {
391399 ) ) ;
392400 }
393401 } else {
394- call. update_text ( self , "Outgoing call" ) . await ?;
402+ let outgoing_call_str = stock_str:: outgoing_call ( self ) . await ;
403+ call. update_text ( self , & outgoing_call_str) . await ?;
395404 self . emit_msgs_changed ( call. msg . chat_id , call_id) ;
396405 }
397406 } else {
@@ -441,19 +450,23 @@ impl Context {
441450 if call. is_incoming ( ) {
442451 if from_id == ContactId :: SELF {
443452 call. mark_as_ended ( self ) . await ?;
444- call. update_text ( self , "Declined call" ) . await ?;
453+ let declined_call_str = stock_str:: declined_call ( self ) . await ;
454+ call. update_text ( self , & declined_call_str) . await ?;
445455 } else {
446456 call. mark_as_canceled ( self ) . await ?;
447- call. update_text ( self , "Missed call" ) . await ?;
457+ let missed_call_str = stock_str:: missed_call ( self ) . await ;
458+ call. update_text ( self , & missed_call_str) . await ?;
448459 }
449460 } else {
450461 // outgoing
451462 if from_id == ContactId :: SELF {
452463 call. mark_as_canceled ( self ) . await ?;
453- call. update_text ( self , "Canceled call" ) . await ?;
464+ let canceled_call_str = stock_str:: canceled_call ( self ) . await ;
465+ call. update_text ( self , & canceled_call_str) . await ?;
454466 } else {
455467 call. mark_as_ended ( self ) . await ?;
456- call. update_text ( self , "Declined call" ) . await ?;
468+ let declined_call_str = stock_str:: declined_call ( self ) . await ;
469+ call. update_text ( self , & declined_call_str) . await ?;
457470 }
458471 }
459472 } else {
0 commit comments