@@ -1815,52 +1815,45 @@ def _handle_event_relations(
1815
1815
txn: The current database transaction.
1816
1816
event: The event which might have relations.
1817
1817
"""
1818
- relation = event .content . get ( "m.relates_to" )
1818
+ relation = event .relation ( )
1819
1819
if not relation :
1820
- # No relations
1820
+ # No relation, nothing to do.
1821
1821
return
1822
1822
1823
- # Relations must have a type and parent event ID.
1824
- rel_type = relation .get ("rel_type" )
1825
- if not isinstance (rel_type , str ):
1826
- return
1827
-
1828
- parent_id = relation .get ("event_id" )
1829
- if not isinstance (parent_id , str ):
1830
- return
1831
-
1832
- # Annotations have a key field.
1833
- aggregation_key = None
1834
- if rel_type == RelationTypes .ANNOTATION :
1835
- aggregation_key = relation .get ("key" )
1836
-
1837
1823
self .db_pool .simple_insert_txn (
1838
1824
txn ,
1839
1825
table = "event_relations" ,
1840
1826
values = {
1841
1827
"event_id" : event .event_id ,
1842
- "relates_to_id" : parent_id ,
1843
- "relation_type" : rel_type ,
1844
- "aggregation_key" : aggregation_key ,
1828
+ "relates_to_id" : relation . parent_id ,
1829
+ "relation_type" : relation . rel_type ,
1830
+ "aggregation_key" : relation . aggregation_key ,
1845
1831
},
1846
1832
)
1847
1833
1848
- txn .call_after (self .store .get_relations_for_event .invalidate , (parent_id ,))
1849
1834
txn .call_after (
1850
- self .store .get_aggregation_groups_for_event .invalidate , (parent_id ,)
1835
+ self .store .get_relations_for_event .invalidate , (relation .parent_id ,)
1836
+ )
1837
+ txn .call_after (
1838
+ self .store .get_aggregation_groups_for_event .invalidate ,
1839
+ (relation .parent_id ,),
1851
1840
)
1852
1841
1853
- if rel_type == RelationTypes .REPLACE :
1854
- txn .call_after (self .store .get_applicable_edit .invalidate , (parent_id ,))
1842
+ if relation .rel_type == RelationTypes .REPLACE :
1843
+ txn .call_after (
1844
+ self .store .get_applicable_edit .invalidate , (relation .parent_id ,)
1845
+ )
1855
1846
1856
- if rel_type == RelationTypes .THREAD :
1857
- txn .call_after (self .store .get_thread_summary .invalidate , (parent_id ,))
1847
+ if relation .rel_type == RelationTypes .THREAD :
1848
+ txn .call_after (
1849
+ self .store .get_thread_summary .invalidate , (relation .parent_id ,)
1850
+ )
1858
1851
# It should be safe to only invalidate the cache if the user has not
1859
1852
# previously participated in the thread, but that's difficult (and
1860
1853
# potentially error-prone) so it is always invalidated.
1861
1854
txn .call_after (
1862
1855
self .store .get_thread_participated .invalidate ,
1863
- (parent_id , event .sender ),
1856
+ (relation . parent_id , event .sender ),
1864
1857
)
1865
1858
1866
1859
def _handle_insertion_event (self , txn : LoggingTransaction , event : EventBase ):
0 commit comments