@@ -1756,16 +1756,18 @@ impl Chat {
1756
1756
if self . typ != Chattype :: Single || self . protected != ProtectionStatus :: Unprotected {
1757
1757
return Ok ( 0 ) ;
1758
1758
}
1759
- let ( mut param0, mut param1) = ( Params :: new ( ) , Params :: new ( ) ) ;
1760
- param0. set_cmd ( SystemMessage :: SecurejoinWait ) ;
1761
- param1. set_cmd ( SystemMessage :: SecurejoinWaitTimeout ) ;
1762
- let ( param0, param1) = ( param0. to_string ( ) , param1. to_string ( ) ) ;
1759
+
1760
+ // get last info message of type SecurejoinWait or SecurejoinWaitTimeout
1761
+ let ( mut param_wait, mut param_timeout) = ( Params :: new ( ) , Params :: new ( ) ) ;
1762
+ param_wait. set_cmd ( SystemMessage :: SecurejoinWait ) ;
1763
+ param_timeout. set_cmd ( SystemMessage :: SecurejoinWaitTimeout ) ;
1764
+ let ( param_wait, param_timeout) = ( param_wait. to_string ( ) , param_timeout. to_string ( ) ) ;
1763
1765
let Some ( ( param, ts_sort, ts_start) ) = context
1764
1766
. sql
1765
1767
. query_row_optional (
1766
1768
"SELECT param, timestamp, timestamp_sent FROM msgs WHERE id=\
1767
1769
(SELECT MAX(id) FROM msgs WHERE chat_id=? AND param IN (?, ?))",
1768
- ( self . id , & param0 , & param1 ) ,
1770
+ ( self . id , & param_wait , & param_timeout ) ,
1769
1771
|row| {
1770
1772
let param: String = row. get ( 0 ) ?;
1771
1773
let ts_sort: i64 = row. get ( 1 ) ?;
@@ -1777,9 +1779,11 @@ impl Chat {
1777
1779
else {
1778
1780
return Ok ( 0 ) ;
1779
1781
} ;
1780
- if param == param1 {
1782
+
1783
+ if param == param_timeout {
1781
1784
return Ok ( 0 ) ;
1782
1785
}
1786
+
1783
1787
let now = time ( ) ;
1784
1788
// Don't await SecureJoin if the clock was set back.
1785
1789
if ts_start <= now {
@@ -1790,6 +1794,7 @@ impl Chat {
1790
1794
return Ok ( timeout as u64 ) ;
1791
1795
}
1792
1796
}
1797
+
1793
1798
add_info_msg_with_cmd (
1794
1799
context,
1795
1800
self . id ,
0 commit comments