@@ -1695,13 +1695,13 @@ impl Chat {
1695
1695
return Ok ( Some ( reason) ) ;
1696
1696
}
1697
1697
let reason = SecurejoinWait ;
1698
- if !skip_fn ( & reason) {
1699
- let ( can_write , _ ) = self
1698
+ if !skip_fn ( & reason)
1699
+ && self
1700
1700
. check_securejoin_wait ( context, constants:: SECUREJOIN_WAIT_TIMEOUT )
1701
- . await ?;
1702
- if !can_write {
1703
- return Ok ( Some ( reason ) ) ;
1704
- }
1701
+ . await ?
1702
+ > 0
1703
+ {
1704
+ return Ok ( Some ( reason ) ) ;
1705
1705
}
1706
1706
Ok ( None )
1707
1707
}
@@ -1713,18 +1713,17 @@ impl Chat {
1713
1713
Ok ( self . why_cant_send ( context) . await ?. is_none ( ) )
1714
1714
}
1715
1715
1716
- /// Returns if the chat can be sent to
1717
- /// and the remaining timeout for the 1:1 chat in-progress SecureJoin.
1716
+ /// Returns the remaining timeout for the 1:1 chat in-progress SecureJoin.
1718
1717
///
1719
- /// If the timeout has expired, adds an info message with additional information;
1720
- /// the chat still cannot be sent to in this case. See also [`CantSendReason::SecurejoinWait`].
1718
+ /// If the timeout has expired, adds an info message with additional information.
1719
+ /// See also [`CantSendReason::SecurejoinWait`].
1721
1720
pub ( crate ) async fn check_securejoin_wait (
1722
1721
& self ,
1723
1722
context : & Context ,
1724
1723
timeout : u64 ,
1725
- ) -> Result < ( bool , u64 ) > {
1724
+ ) -> Result < u64 > {
1726
1725
if self . typ != Chattype :: Single || self . protected != ProtectionStatus :: Unprotected {
1727
- return Ok ( ( true , 0 ) ) ;
1726
+ return Ok ( 0 ) ;
1728
1727
}
1729
1728
1730
1729
// chat is single and unprotected:
@@ -1748,11 +1747,10 @@ impl Chat {
1748
1747
)
1749
1748
. await ?
1750
1749
else {
1751
- return Ok ( ( true , 0 ) ) ;
1750
+ return Ok ( 0 ) ;
1752
1751
} ;
1753
-
1754
1752
if param == param_timeout {
1755
- return Ok ( ( false , 0 ) ) ;
1753
+ return Ok ( 0 ) ;
1756
1754
}
1757
1755
1758
1756
let now = time ( ) ;
@@ -1762,10 +1760,9 @@ impl Chat {
1762
1760
. saturating_add ( timeout. try_into ( ) ?)
1763
1761
. saturating_sub ( now) ;
1764
1762
if timeout > 0 {
1765
- return Ok ( ( false , timeout as u64 ) ) ;
1763
+ return Ok ( timeout as u64 ) ;
1766
1764
}
1767
1765
}
1768
-
1769
1766
add_info_msg_with_cmd (
1770
1767
context,
1771
1768
self . id ,
@@ -1780,8 +1777,8 @@ impl Chat {
1780
1777
None ,
1781
1778
)
1782
1779
. await ?;
1783
-
1784
- Ok ( ( false , 0 ) )
1780
+ context . emit_event ( EventType :: ChatModified ( self . id ) ) ;
1781
+ Ok ( 0 )
1785
1782
}
1786
1783
1787
1784
/// Checks if the user is part of a chat
@@ -2584,7 +2581,7 @@ pub(crate) async fn resume_securejoin_wait(context: &Context) -> Result<()> {
2584
2581
2585
2582
for chat_id in chat_ids {
2586
2583
let chat = Chat :: load_from_db ( context, chat_id) . await ?;
2587
- let ( _ , timeout) = chat
2584
+ let timeout = chat
2588
2585
. check_securejoin_wait ( context, constants:: SECUREJOIN_WAIT_TIMEOUT )
2589
2586
. await ?;
2590
2587
if timeout > 0 {
0 commit comments