@@ -29,7 +29,8 @@ use ruma::{
29
29
} ,
30
30
owned_event_id, owned_mxc_uri, room_id,
31
31
serde:: Raw ,
32
- uint, user_id, EventId , OwnedEventId , OwnedUserId , RoomId , TransactionId , UserId ,
32
+ uint, user_id, EventId , MilliSecondsSinceUnixEpoch , OwnedEventId , OwnedUserId , RoomId ,
33
+ TransactionId , UserId ,
33
34
} ;
34
35
use serde_json:: { json, value:: Value as JsonValue } ;
35
36
@@ -980,13 +981,21 @@ impl StateStoreIntegrationTests for DynStateStore {
980
981
let ev =
981
982
SerializableEventContent :: new ( & RoomMessageEventContent :: text_plain ( "sup" ) . into ( ) )
982
983
. unwrap ( ) ;
983
- self . save_send_queue_request ( room_id, txn. clone ( ) , ev. into ( ) , 0 ) . await ?;
984
+ self . save_send_queue_request (
985
+ room_id,
986
+ txn. clone ( ) ,
987
+ MilliSecondsSinceUnixEpoch :: now ( ) ,
988
+ ev. into ( ) ,
989
+ 0 ,
990
+ )
991
+ . await ?;
984
992
985
993
// Add a single dependent queue request.
986
994
self . save_dependent_queued_request (
987
995
room_id,
988
996
& txn,
989
997
ChildTransactionId :: new ( ) ,
998
+ MilliSecondsSinceUnixEpoch :: now ( ) ,
990
999
DependentQueuedRequestKind :: RedactEvent ,
991
1000
)
992
1001
. await ?;
@@ -1242,7 +1251,15 @@ impl StateStoreIntegrationTests for DynStateStore {
1242
1251
let event0 =
1243
1252
SerializableEventContent :: new ( & RoomMessageEventContent :: text_plain ( "msg0" ) . into ( ) )
1244
1253
. unwrap ( ) ;
1245
- self . save_send_queue_request ( room_id, txn0. clone ( ) , event0. into ( ) , 0 ) . await . unwrap ( ) ;
1254
+ self . save_send_queue_request (
1255
+ room_id,
1256
+ txn0. clone ( ) ,
1257
+ MilliSecondsSinceUnixEpoch :: now ( ) ,
1258
+ event0. into ( ) ,
1259
+ 0 ,
1260
+ )
1261
+ . await
1262
+ . unwrap ( ) ;
1246
1263
1247
1264
// Reading it will work.
1248
1265
let pending = self . load_send_queue_requests ( room_id) . await . unwrap ( ) ;
@@ -1266,7 +1283,15 @@ impl StateStoreIntegrationTests for DynStateStore {
1266
1283
)
1267
1284
. unwrap ( ) ;
1268
1285
1269
- self . save_send_queue_request ( room_id, txn, event. into ( ) , 0 ) . await . unwrap ( ) ;
1286
+ self . save_send_queue_request (
1287
+ room_id,
1288
+ txn,
1289
+ MilliSecondsSinceUnixEpoch :: now ( ) ,
1290
+ event. into ( ) ,
1291
+ 0 ,
1292
+ )
1293
+ . await
1294
+ . unwrap ( ) ;
1270
1295
}
1271
1296
1272
1297
// Reading all the events should work.
@@ -1364,7 +1389,15 @@ impl StateStoreIntegrationTests for DynStateStore {
1364
1389
let event =
1365
1390
SerializableEventContent :: new ( & RoomMessageEventContent :: text_plain ( "room2" ) . into ( ) )
1366
1391
. unwrap ( ) ;
1367
- self . save_send_queue_request ( room_id2, txn. clone ( ) , event. into ( ) , 0 ) . await . unwrap ( ) ;
1392
+ self . save_send_queue_request (
1393
+ room_id2,
1394
+ txn. clone ( ) ,
1395
+ MilliSecondsSinceUnixEpoch :: now ( ) ,
1396
+ event. into ( ) ,
1397
+ 0 ,
1398
+ )
1399
+ . await
1400
+ . unwrap ( ) ;
1368
1401
}
1369
1402
1370
1403
// Add and remove one event for room3.
@@ -1374,7 +1407,15 @@ impl StateStoreIntegrationTests for DynStateStore {
1374
1407
let event =
1375
1408
SerializableEventContent :: new ( & RoomMessageEventContent :: text_plain ( "room3" ) . into ( ) )
1376
1409
. unwrap ( ) ;
1377
- self . save_send_queue_request ( room_id3, txn. clone ( ) , event. into ( ) , 0 ) . await . unwrap ( ) ;
1410
+ self . save_send_queue_request (
1411
+ room_id3,
1412
+ txn. clone ( ) ,
1413
+ MilliSecondsSinceUnixEpoch :: now ( ) ,
1414
+ event. into ( ) ,
1415
+ 0 ,
1416
+ )
1417
+ . await
1418
+ . unwrap ( ) ;
1378
1419
1379
1420
self . remove_send_queue_request ( room_id3, & txn) . await . unwrap ( ) ;
1380
1421
}
@@ -1399,21 +1440,45 @@ impl StateStoreIntegrationTests for DynStateStore {
1399
1440
let ev0 =
1400
1441
SerializableEventContent :: new ( & RoomMessageEventContent :: text_plain ( "low0" ) . into ( ) )
1401
1442
. unwrap ( ) ;
1402
- self . save_send_queue_request ( room_id, low0_txn. clone ( ) , ev0. into ( ) , 2 ) . await . unwrap ( ) ;
1443
+ self . save_send_queue_request (
1444
+ room_id,
1445
+ low0_txn. clone ( ) ,
1446
+ MilliSecondsSinceUnixEpoch :: now ( ) ,
1447
+ ev0. into ( ) ,
1448
+ 2 ,
1449
+ )
1450
+ . await
1451
+ . unwrap ( ) ;
1403
1452
1404
1453
// Saving one request with higher priority should work.
1405
1454
let high_txn = TransactionId :: new ( ) ;
1406
1455
let ev1 =
1407
1456
SerializableEventContent :: new ( & RoomMessageEventContent :: text_plain ( "high" ) . into ( ) )
1408
1457
. unwrap ( ) ;
1409
- self . save_send_queue_request ( room_id, high_txn. clone ( ) , ev1. into ( ) , 10 ) . await . unwrap ( ) ;
1458
+ self . save_send_queue_request (
1459
+ room_id,
1460
+ high_txn. clone ( ) ,
1461
+ MilliSecondsSinceUnixEpoch :: now ( ) ,
1462
+ ev1. into ( ) ,
1463
+ 10 ,
1464
+ )
1465
+ . await
1466
+ . unwrap ( ) ;
1410
1467
1411
1468
// Saving another request with the low priority should work.
1412
1469
let low1_txn = TransactionId :: new ( ) ;
1413
1470
let ev2 =
1414
1471
SerializableEventContent :: new ( & RoomMessageEventContent :: text_plain ( "low1" ) . into ( ) )
1415
1472
. unwrap ( ) ;
1416
- self . save_send_queue_request ( room_id, low1_txn. clone ( ) , ev2. into ( ) , 2 ) . await . unwrap ( ) ;
1473
+ self . save_send_queue_request (
1474
+ room_id,
1475
+ low1_txn. clone ( ) ,
1476
+ MilliSecondsSinceUnixEpoch :: now ( ) ,
1477
+ ev2. into ( ) ,
1478
+ 2 ,
1479
+ )
1480
+ . await
1481
+ . unwrap ( ) ;
1417
1482
1418
1483
// The requests should be ordered from higher priority to lower, and when equal,
1419
1484
// should use the insertion order instead.
@@ -1453,7 +1518,15 @@ impl StateStoreIntegrationTests for DynStateStore {
1453
1518
let event0 =
1454
1519
SerializableEventContent :: new ( & RoomMessageEventContent :: text_plain ( "hey" ) . into ( ) )
1455
1520
. unwrap ( ) ;
1456
- self . save_send_queue_request ( room_id, txn0. clone ( ) , event0. into ( ) , 0 ) . await . unwrap ( ) ;
1521
+ self . save_send_queue_request (
1522
+ room_id,
1523
+ txn0. clone ( ) ,
1524
+ MilliSecondsSinceUnixEpoch :: now ( ) ,
1525
+ event0. into ( ) ,
1526
+ 0 ,
1527
+ )
1528
+ . await
1529
+ . unwrap ( ) ;
1457
1530
1458
1531
// No dependents, to start with.
1459
1532
assert ! ( self . load_dependent_queued_requests( room_id) . await . unwrap( ) . is_empty( ) ) ;
@@ -1464,6 +1537,7 @@ impl StateStoreIntegrationTests for DynStateStore {
1464
1537
room_id,
1465
1538
& txn0,
1466
1539
child_txn. clone ( ) ,
1540
+ MilliSecondsSinceUnixEpoch :: now ( ) ,
1467
1541
DependentQueuedRequestKind :: RedactEvent ,
1468
1542
)
1469
1543
. await
@@ -1515,12 +1589,21 @@ impl StateStoreIntegrationTests for DynStateStore {
1515
1589
let event1 =
1516
1590
SerializableEventContent :: new ( & RoomMessageEventContent :: text_plain ( "hey2" ) . into ( ) )
1517
1591
. unwrap ( ) ;
1518
- self . save_send_queue_request ( room_id, txn1. clone ( ) , event1. into ( ) , 0 ) . await . unwrap ( ) ;
1592
+ self . save_send_queue_request (
1593
+ room_id,
1594
+ txn1. clone ( ) ,
1595
+ MilliSecondsSinceUnixEpoch :: now ( ) ,
1596
+ event1. into ( ) ,
1597
+ 0 ,
1598
+ )
1599
+ . await
1600
+ . unwrap ( ) ;
1519
1601
1520
1602
self . save_dependent_queued_request (
1521
1603
room_id,
1522
1604
& txn0,
1523
1605
ChildTransactionId :: new ( ) ,
1606
+ MilliSecondsSinceUnixEpoch :: now ( ) ,
1524
1607
DependentQueuedRequestKind :: RedactEvent ,
1525
1608
)
1526
1609
. await
@@ -1531,6 +1614,7 @@ impl StateStoreIntegrationTests for DynStateStore {
1531
1614
room_id,
1532
1615
& txn1,
1533
1616
ChildTransactionId :: new ( ) ,
1617
+ MilliSecondsSinceUnixEpoch :: now ( ) ,
1534
1618
DependentQueuedRequestKind :: EditEvent {
1535
1619
new_content : SerializableEventContent :: new (
1536
1620
& RoomMessageEventContent :: text_plain ( "edit" ) . into ( ) ,
@@ -1563,6 +1647,7 @@ impl StateStoreIntegrationTests for DynStateStore {
1563
1647
room_id,
1564
1648
& txn,
1565
1649
child_txn. clone ( ) ,
1650
+ MilliSecondsSinceUnixEpoch :: now ( ) ,
1566
1651
DependentQueuedRequestKind :: RedactEvent ,
1567
1652
)
1568
1653
. await
0 commit comments