@@ -5485,3 +5485,69 @@ async fn test_prefer_chat_group_id_over_references() -> Result<()> {
5485
5485
assert_ne ! ( chat1. id, chat2. id) ;
5486
5486
Ok ( ( ) )
5487
5487
}
5488
+
5489
+ /// Tests that if member timestamps are unknown
5490
+ /// because of the missing `Chat-Group-Member-Timestamps` header,
5491
+ /// then timestamps default to zero.
5492
+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
5493
+ async fn test_default_member_timestamps_to_zero ( ) -> Result < ( ) > {
5494
+ let bob = & TestContext :: new_bob ( ) . await ;
5495
+
5496
+ let now = time ( ) ;
5497
+
5498
+ let date = chrono:: DateTime :: < chrono:: Utc > :: from_timestamp ( now - 1000 , 0 )
5499
+ . unwrap ( )
5500
+ . to_rfc2822 ( ) ;
5501
+ let msg = receive_imf (
5502
+ bob,
5503
+ format ! (
5504
+ "Subject: Some group\r \n \
5505
+ From: <alice@example.org>\r \n \
5506
+ To: <bob@example.net>, <claire@example.org>, <fiona@example.org>\r \n \
5507
+ Date: {date}\r \n \
5508
+ Message-ID: <first@localhost>\r \n \
5509
+ Chat-Group-ID: foobarbaz12\n \
5510
+ Chat-Group-Name: foo\n \
5511
+ Chat-Version: 1.0\r \n \
5512
+ \r \n \
5513
+ Hi!\r \n "
5514
+ )
5515
+ . as_bytes ( ) ,
5516
+ false ,
5517
+ )
5518
+ . await ?
5519
+ . unwrap ( ) ;
5520
+ let chat = Chat :: load_from_db ( bob, msg. chat_id ) . await ?;
5521
+ assert_eq ! ( chat. typ, Chattype :: Group ) ;
5522
+ assert_eq ! ( chat:: get_chat_contacts( bob, chat. id) . await ?. len( ) , 4 ) ;
5523
+
5524
+ let date = chrono:: DateTime :: < chrono:: Utc > :: from_timestamp ( now, 0 )
5525
+ . unwrap ( )
5526
+ . to_rfc2822 ( ) ;
5527
+ receive_imf (
5528
+ bob,
5529
+ format ! (
5530
+ "Subject: Some group\r \n \
5531
+ From: <claire@example.org>\r \n \
5532
+ To: <alice@example.org>, <bob@example.net>\r \n \
5533
+ Chat-Group-Past-Members: <fiona@example.org>\r \n \
5534
+ Chat-Group-Member-Timestamps: 1737783000 1737783100 1737783200\r \n \
5535
+ Chat-Group-ID: foobarbaz12\n \
5536
+ Chat-Group-Name: foo\n \
5537
+ Chat-Version: 1.0\r \n \
5538
+ Date: {date}\r \n \
5539
+ Message-ID: <second@localhost>\r \n \
5540
+ \r \n \
5541
+ Hi back!\r \n "
5542
+ )
5543
+ . as_bytes ( ) ,
5544
+ false ,
5545
+ )
5546
+ . await ?
5547
+ . unwrap ( ) ;
5548
+
5549
+ let chat = Chat :: load_from_db ( bob, msg. chat_id ) . await ?;
5550
+ assert_eq ! ( chat. typ, Chattype :: Group ) ;
5551
+ assert_eq ! ( chat:: get_chat_contacts( bob, chat. id) . await ?. len( ) , 3 ) ;
5552
+ Ok ( ( ) )
5553
+ }
0 commit comments