File tree 4 files changed +36
-4
lines changed
4 files changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -1221,6 +1221,22 @@ impl ChatId {
1221
1221
Ok ( self . get_param ( context) . await ?. exists ( Param :: Devicetalk ) )
1222
1222
}
1223
1223
1224
+ /// Returns chat member list timestamp.
1225
+ pub ( crate ) async fn member_list_timestamp ( self , context : & Context ) -> Result < i64 > {
1226
+ let creation_timestamp: i64 = context
1227
+ . sql
1228
+ . query_get_value ( "SELECT created_timestamp FROM chats WHERE id=?" , ( self , ) )
1229
+ . await
1230
+ . context ( "SQL error querying created_timestamp" ) ?
1231
+ . context ( "Chat not found" ) ?;
1232
+
1233
+ Ok ( self
1234
+ . get_param ( context)
1235
+ . await ?
1236
+ . get_i64 ( Param :: MemberListTimestamp )
1237
+ . unwrap_or ( creation_timestamp) )
1238
+ }
1239
+
1224
1240
async fn parent_query < T , F > (
1225
1241
self ,
1226
1242
context : & Context ,
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ use tokio::fs;
12
12
use crate :: blob:: BlobObject ;
13
13
use crate :: chat:: { self , Chat } ;
14
14
use crate :: config:: Config ;
15
- use crate :: constants:: { Chattype , DC_FROM_HANDSHAKE } ;
15
+ use crate :: constants:: { Chattype , DC_FROM_HANDSHAKE , TIMESTAMP_SENT_TOLERANCE } ;
16
16
use crate :: contact:: { Contact , ContactId , Origin } ;
17
17
use crate :: context:: Context ;
18
18
use crate :: e2ee:: EncryptHelper ;
@@ -621,7 +621,17 @@ impl MimeFactory {
621
621
) ;
622
622
}
623
623
624
- if !self . member_timestamps . is_empty ( ) {
624
+ let chat_memberlist_is_stale = if let Loaded :: Message { chat, .. } = & self . loaded {
625
+ let now = time ( ) ;
626
+ let member_list_ts = chat. id . member_list_timestamp ( context) . await ?;
627
+ member_list_ts > 0
628
+ && now. saturating_add ( TIMESTAMP_SENT_TOLERANCE )
629
+ >= member_list_ts. saturating_add ( 60 * 24 * 3600 )
630
+ } else {
631
+ false
632
+ } ;
633
+
634
+ if !self . member_timestamps . is_empty ( ) && !chat_memberlist_is_stale {
625
635
headers. push (
626
636
Header :: new_with_value (
627
637
"Chat-Group-Member-Timestamps" . into ( ) ,
Original file line number Diff line number Diff line change @@ -183,8 +183,6 @@ pub enum Param {
183
183
GroupNameTimestamp = b'g' ,
184
184
185
185
/// For Chats: timestamp of member list update.
186
- ///
187
- /// Deprecated 2025-01-07.
188
186
MemberListTimestamp = b'k' ,
189
187
190
188
/// For Webxdc Message Instances: Current document name
Original file line number Diff line number Diff line change @@ -2395,6 +2395,14 @@ async fn apply_group_changes(
2395
2395
send_event_chat_modified = true ;
2396
2396
}
2397
2397
}
2398
+
2399
+ chat_id
2400
+ . update_timestamp (
2401
+ context,
2402
+ Param :: MemberListTimestamp ,
2403
+ mime_parser. timestamp_sent ,
2404
+ )
2405
+ . await ?;
2398
2406
}
2399
2407
2400
2408
if let Some ( added_id) = added_id {
You can’t perform that action at this time.
0 commit comments