@@ -536,98 +536,6 @@ def get_push_actions(
536
536
"get_unread_push_actions_for_user_in_range_http" , get_push_actions
537
537
)
538
538
539
- # find rooms that have a read receipt in them and return the next
540
- # push actions
541
- def get_after_receipt (
542
- txn : LoggingTransaction ,
543
- ) -> List [Tuple [str , str , int , str , bool ]]:
544
- # find rooms that have a read receipt in them and return the next
545
- # push actions
546
-
547
- receipt_types_clause , args = make_in_list_sql_clause (
548
- self .database_engine ,
549
- "receipt_type" ,
550
- (
551
- ReceiptTypes .READ ,
552
- ReceiptTypes .READ_PRIVATE ,
553
- ReceiptTypes .UNSTABLE_READ_PRIVATE ,
554
- ),
555
- )
556
-
557
- sql = f"""
558
- SELECT ep.event_id, ep.room_id, ep.stream_ordering, ep.actions,
559
- ep.highlight
560
- FROM (
561
- SELECT room_id,
562
- MAX(stream_ordering) as stream_ordering
563
- FROM events
564
- INNER JOIN receipts_linearized USING (room_id, event_id)
565
- WHERE { receipt_types_clause } AND user_id = ?
566
- GROUP BY room_id
567
- ) AS rl,
568
- event_push_actions AS ep
569
- WHERE
570
- ep.room_id = rl.room_id
571
- AND ep.stream_ordering > rl.stream_ordering
572
- AND ep.user_id = ?
573
- AND ep.stream_ordering > ?
574
- AND ep.stream_ordering <= ?
575
- AND ep.notif = 1
576
- ORDER BY ep.stream_ordering ASC LIMIT ?
577
- """
578
- args .extend (
579
- (user_id , user_id , min_stream_ordering , max_stream_ordering , limit )
580
- )
581
- txn .execute (sql , args )
582
- return cast (List [Tuple [str , str , int , str , bool ]], txn .fetchall ())
583
-
584
- after_read_receipt = await self .db_pool .runInteraction (
585
- "get_unread_push_actions_for_user_in_range_http_arr" , get_after_receipt
586
- )
587
-
588
- # There are rooms with push actions in them but you don't have a read receipt in
589
- # them e.g. rooms you've been invited to, so get push actions for rooms which do
590
- # not have read receipts in them too.
591
- def get_no_receipt (
592
- txn : LoggingTransaction ,
593
- ) -> List [Tuple [str , str , int , str , bool ]]:
594
- receipt_types_clause , args = make_in_list_sql_clause (
595
- self .database_engine ,
596
- "receipt_type" ,
597
- (
598
- ReceiptTypes .READ ,
599
- ReceiptTypes .READ_PRIVATE ,
600
- ReceiptTypes .UNSTABLE_READ_PRIVATE ,
601
- ),
602
- )
603
-
604
- sql = f"""
605
- SELECT ep.event_id, ep.room_id, ep.stream_ordering, ep.actions,
606
- ep.highlight
607
- FROM event_push_actions AS ep
608
- INNER JOIN events AS e USING (room_id, event_id)
609
- WHERE
610
- ep.room_id NOT IN (
611
- SELECT room_id FROM receipts_linearized
612
- WHERE { receipt_types_clause } AND user_id = ?
613
- GROUP BY room_id
614
- )
615
- AND ep.user_id = ?
616
- AND ep.stream_ordering > ?
617
- AND ep.stream_ordering <= ?
618
- AND ep.notif = 1
619
- ORDER BY ep.stream_ordering ASC LIMIT ?
620
- """
621
- args .extend (
622
- (user_id , user_id , min_stream_ordering , max_stream_ordering , limit )
623
- )
624
- txn .execute (sql , args )
625
- return cast (List [Tuple [str , str , int , str , bool ]], txn .fetchall ())
626
-
627
- no_read_receipt = await self .db_pool .runInteraction (
628
- "get_unread_push_actions_for_user_in_range_http_nrr" , get_no_receipt
629
- )
630
-
631
539
notifs = [
632
540
HttpPushAction (
633
541
event_id = row [0 ],
@@ -704,96 +612,6 @@ def get_push_actions(
704
612
"get_unread_push_actions_for_user_in_range_email" , get_push_actions
705
613
)
706
614
707
- # find rooms that have a read receipt in them and return the most recent
708
- # push actions
709
- def get_after_receipt (
710
- txn : LoggingTransaction ,
711
- ) -> List [Tuple [str , str , int , str , bool , int ]]:
712
- receipt_types_clause , args = make_in_list_sql_clause (
713
- self .database_engine ,
714
- "receipt_type" ,
715
- (
716
- ReceiptTypes .READ ,
717
- ReceiptTypes .READ_PRIVATE ,
718
- ReceiptTypes .UNSTABLE_READ_PRIVATE ,
719
- ),
720
- )
721
-
722
- sql = f"""
723
- SELECT ep.event_id, ep.room_id, ep.stream_ordering, ep.actions,
724
- ep.highlight, e.received_ts
725
- FROM (
726
- SELECT room_id,
727
- MAX(stream_ordering) as stream_ordering
728
- FROM events
729
- INNER JOIN receipts_linearized USING (room_id, event_id)
730
- WHERE { receipt_types_clause } AND user_id = ?
731
- GROUP BY room_id
732
- ) AS rl,
733
- event_push_actions AS ep
734
- INNER JOIN events AS e USING (room_id, event_id)
735
- WHERE
736
- ep.room_id = rl.room_id
737
- AND ep.stream_ordering > rl.stream_ordering
738
- AND ep.user_id = ?
739
- AND ep.stream_ordering > ?
740
- AND ep.stream_ordering <= ?
741
- AND ep.notif = 1
742
- ORDER BY ep.stream_ordering DESC LIMIT ?
743
- """
744
- args .extend (
745
- (user_id , user_id , min_stream_ordering , max_stream_ordering , limit )
746
- )
747
- txn .execute (sql , args )
748
- return cast (List [Tuple [str , str , int , str , bool , int ]], txn .fetchall ())
749
-
750
- after_read_receipt = await self .db_pool .runInteraction (
751
- "get_unread_push_actions_for_user_in_range_email_arr" , get_after_receipt
752
- )
753
-
754
- # There are rooms with push actions in them but you don't have a read receipt in
755
- # them e.g. rooms you've been invited to, so get push actions for rooms which do
756
- # not have read receipts in them too.
757
- def get_no_receipt (
758
- txn : LoggingTransaction ,
759
- ) -> List [Tuple [str , str , int , str , bool , int ]]:
760
- receipt_types_clause , args = make_in_list_sql_clause (
761
- self .database_engine ,
762
- "receipt_type" ,
763
- (
764
- ReceiptTypes .READ ,
765
- ReceiptTypes .READ_PRIVATE ,
766
- ReceiptTypes .UNSTABLE_READ_PRIVATE ,
767
- ),
768
- )
769
-
770
- sql = f"""
771
- SELECT ep.event_id, ep.room_id, ep.stream_ordering, ep.actions,
772
- ep.highlight, e.received_ts
773
- FROM event_push_actions AS ep
774
- INNER JOIN events AS e USING (room_id, event_id)
775
- WHERE
776
- ep.room_id NOT IN (
777
- SELECT room_id FROM receipts_linearized
778
- WHERE { receipt_types_clause } AND user_id = ?
779
- GROUP BY room_id
780
- )
781
- AND ep.user_id = ?
782
- AND ep.stream_ordering > ?
783
- AND ep.stream_ordering <= ?
784
- AND ep.notif = 1
785
- ORDER BY ep.stream_ordering DESC LIMIT ?
786
- """
787
- args .extend (
788
- (user_id , user_id , min_stream_ordering , max_stream_ordering , limit )
789
- )
790
- txn .execute (sql , args )
791
- return cast (List [Tuple [str , str , int , str , bool , int ]], txn .fetchall ())
792
-
793
- no_read_receipt = await self .db_pool .runInteraction (
794
- "get_unread_push_actions_for_user_in_range_email_nrr" , get_no_receipt
795
- )
796
-
797
615
# Make a list of dicts from the two sets of results.
798
616
notifs = [
799
617
EmailPushAction (
0 commit comments