@@ -516,6 +516,26 @@ async def get_unread_push_actions_for_user_in_range_for_http(
516
516
),
517
517
)
518
518
519
+ def get_push_actions (
520
+ txn : LoggingTransaction ,
521
+ ) -> List [Tuple [str , str , int , str , bool ]]:
522
+ sql = """
523
+ SELECT ep.event_id, ep.room_id, ep.stream_ordering, ep.actions, ep.highlight
524
+ FROM event_push_actions AS ep
525
+ WHERE
526
+ ep.user_id = ?
527
+ AND ep.stream_ordering > ?
528
+ AND ep.stream_ordering <= ?
529
+ AND ep.notif = 1
530
+ ORDER BY ep.stream_ordering ASC LIMIT ?
531
+ """
532
+ txn .execute (sql , (user_id , min_stream_ordering , max_stream_ordering , limit ))
533
+ return cast (List [Tuple [str , str , int , str , bool ]], txn .fetchall ())
534
+
535
+ push_actions = await self .db_pool .runInteraction (
536
+ "get_unread_push_actions_for_user_in_range_http" , get_push_actions
537
+ )
538
+
519
539
# find rooms that have a read receipt in them and return the next
520
540
# push actions
521
541
def get_after_receipt (
@@ -615,7 +635,10 @@ def get_no_receipt(
615
635
stream_ordering = row [2 ],
616
636
actions = _deserialize_action (row [3 ], row [4 ]),
617
637
)
618
- for row in after_read_receipt + no_read_receipt
638
+ for row in push_actions
639
+ # Only include push actions with a stream ordering after any receipt, or without any
640
+ # receipt present (invited to but never read rooms).
641
+ if row [2 ] > receipts_by_room .get (row [1 ], 0 )
619
642
]
620
643
621
644
# Now sort it so it's ordered correctly, since currently it will
@@ -659,6 +682,28 @@ async def get_unread_push_actions_for_user_in_range_for_email(
659
682
),
660
683
)
661
684
685
+ def get_push_actions (
686
+ txn : LoggingTransaction ,
687
+ ) -> List [Tuple [str , str , int , str , bool , int ]]:
688
+ sql = """
689
+ SELECT ep.event_id, ep.room_id, ep.stream_ordering, ep.actions,
690
+ ep.highlight, e.received_ts
691
+ FROM event_push_actions AS ep
692
+ INNER JOIN events AS e USING (room_id, event_id)
693
+ WHERE
694
+ ep.user_id = ?
695
+ AND ep.stream_ordering > ?
696
+ AND ep.stream_ordering <= ?
697
+ AND ep.notif = 1
698
+ ORDER BY ep.stream_ordering DESC LIMIT ?
699
+ """
700
+ txn .execute (sql , (user_id , min_stream_ordering , max_stream_ordering , limit ))
701
+ return cast (List [Tuple [str , str , int , str , bool , int ]], txn .fetchall ())
702
+
703
+ push_actions = await self .db_pool .runInteraction (
704
+ "get_unread_push_actions_for_user_in_range_email" , get_push_actions
705
+ )
706
+
662
707
# find rooms that have a read receipt in them and return the most recent
663
708
# push actions
664
709
def get_after_receipt (
@@ -758,7 +803,10 @@ def get_no_receipt(
758
803
actions = _deserialize_action (row [3 ], row [4 ]),
759
804
received_ts = row [5 ],
760
805
)
761
- for row in after_read_receipt + no_read_receipt
806
+ for row in push_actions
807
+ # Only include push actions with a stream ordering after any receipt, or without any
808
+ # receipt present (invited to but never read rooms).
809
+ if row [2 ] > receipts_by_room .get (row [1 ], 0 )
762
810
]
763
811
764
812
# Now sort it so it's ordered correctly, since currently it will
0 commit comments