@@ -1710,40 +1710,53 @@ def test_redact_parent_thread(self) -> None:
1710
1710
1711
1711
1712
1712
class ThreadsTestCase (BaseRelationsTestCase ):
1713
- @unittest .override_config ({"experimental_features" : {"msc3856_enabled" : True }})
1713
+ def _get_threads (self , body : JsonDict ) -> List [Tuple [str , str ]]:
1714
+ return [
1715
+ (
1716
+ ev ["event_id" ],
1717
+ ev ["unsigned" ]["m.relations" ]["m.thread" ]["latest_event" ]["event_id" ],
1718
+ )
1719
+ for ev in body ["chunk" ]
1720
+ ]
1721
+
1714
1722
def test_threads (self ) -> None :
1715
1723
"""Create threads and ensure the ordering is due to their latest event."""
1716
1724
# Create 2 threads.
1717
1725
thread_1 = self .parent_id
1718
1726
res = self .helper .send (self .room , body = "Thread Root!" , tok = self .user_token )
1719
1727
thread_2 = res ["event_id" ]
1720
1728
1721
- self ._send_relation (RelationTypes .THREAD , "m.room.test" )
1722
- self ._send_relation (RelationTypes .THREAD , "m.room.test" , parent_id = thread_2 )
1729
+ channel = self ._send_relation (RelationTypes .THREAD , "m.room.test" )
1730
+ reply_1 = channel .json_body ["event_id" ]
1731
+ channel = self ._send_relation (
1732
+ RelationTypes .THREAD , "m.room.test" , parent_id = thread_2
1733
+ )
1734
+ reply_2 = channel .json_body ["event_id" ]
1723
1735
1724
1736
# Request the threads in the room.
1725
1737
channel = self .make_request (
1726
1738
"GET" ,
1727
- f"/_matrix/client/unstable/org.matrix.msc3856 /rooms/{ self .room } /threads" ,
1739
+ f"/_matrix/client/v1 /rooms/{ self .room } /threads" ,
1728
1740
access_token = self .user_token ,
1729
1741
)
1730
1742
self .assertEquals (200 , channel .code , channel .json_body )
1731
- thread_roots = [ ev [ "event_id" ] for ev in channel .json_body [ "chunk" ]]
1732
- self .assertEqual (thread_roots , [thread_2 , thread_1 ])
1743
+ threads = self . _get_threads ( channel .json_body )
1744
+ self .assertEqual (threads , [( thread_2 , reply_2 ), ( thread_1 , reply_1 ) ])
1733
1745
1734
1746
# Update the first thread, the ordering should swap.
1735
- self ._send_relation (RelationTypes .THREAD , "m.room.test" )
1747
+ channel = self ._send_relation (RelationTypes .THREAD , "m.room.test" )
1748
+ reply_3 = channel .json_body ["event_id" ]
1736
1749
1737
1750
channel = self .make_request (
1738
1751
"GET" ,
1739
- f"/_matrix/client/unstable/org.matrix.msc3856 /rooms/{ self .room } /threads" ,
1752
+ f"/_matrix/client/v1 /rooms/{ self .room } /threads" ,
1740
1753
access_token = self .user_token ,
1741
1754
)
1742
1755
self .assertEquals (200 , channel .code , channel .json_body )
1743
- thread_roots = [ev ["event_id" ] for ev in channel .json_body ["chunk" ]]
1744
- self .assertEqual (thread_roots , [thread_1 , thread_2 ])
1756
+ # Tuple of (thread ID, latest event ID) for each thread.
1757
+ threads = self ._get_threads (channel .json_body )
1758
+ self .assertEqual (threads , [(thread_1 , reply_3 ), (thread_2 , reply_2 )])
1745
1759
1746
- @unittest .override_config ({"experimental_features" : {"msc3856_enabled" : True }})
1747
1760
def test_pagination (self ) -> None :
1748
1761
"""Create threads and paginate through them."""
1749
1762
# Create 2 threads.
@@ -1757,7 +1770,7 @@ def test_pagination(self) -> None:
1757
1770
# Request the threads in the room.
1758
1771
channel = self .make_request (
1759
1772
"GET" ,
1760
- f"/_matrix/client/unstable/org.matrix.msc3856 /rooms/{ self .room } /threads?limit=1" ,
1773
+ f"/_matrix/client/v1 /rooms/{ self .room } /threads?limit=1" ,
1761
1774
access_token = self .user_token ,
1762
1775
)
1763
1776
self .assertEquals (200 , channel .code , channel .json_body )
@@ -1771,7 +1784,7 @@ def test_pagination(self) -> None:
1771
1784
1772
1785
channel = self .make_request (
1773
1786
"GET" ,
1774
- f"/_matrix/client/unstable/org.matrix.msc3856 /rooms/{ self .room } /threads?limit=1&from={ next_batch } " ,
1787
+ f"/_matrix/client/v1 /rooms/{ self .room } /threads?limit=1&from={ next_batch } " ,
1775
1788
access_token = self .user_token ,
1776
1789
)
1777
1790
self .assertEquals (200 , channel .code , channel .json_body )
@@ -1780,7 +1793,6 @@ def test_pagination(self) -> None:
1780
1793
1781
1794
self .assertNotIn ("next_batch" , channel .json_body , channel .json_body )
1782
1795
1783
- @unittest .override_config ({"experimental_features" : {"msc3856_enabled" : True }})
1784
1796
def test_include (self ) -> None :
1785
1797
"""Filtering threads to all or participated in should work."""
1786
1798
# Thread 1 has the user as the root event.
@@ -1807,7 +1819,7 @@ def test_include(self) -> None:
1807
1819
# All threads in the room.
1808
1820
channel = self .make_request (
1809
1821
"GET" ,
1810
- f"/_matrix/client/unstable/org.matrix.msc3856 /rooms/{ self .room } /threads" ,
1822
+ f"/_matrix/client/v1 /rooms/{ self .room } /threads" ,
1811
1823
access_token = self .user_token ,
1812
1824
)
1813
1825
self .assertEquals (200 , channel .code , channel .json_body )
@@ -1819,14 +1831,13 @@ def test_include(self) -> None:
1819
1831
# Only participated threads.
1820
1832
channel = self .make_request (
1821
1833
"GET" ,
1822
- f"/_matrix/client/unstable/org.matrix.msc3856 /rooms/{ self .room } /threads?include=participated" ,
1834
+ f"/_matrix/client/v1 /rooms/{ self .room } /threads?include=participated" ,
1823
1835
access_token = self .user_token ,
1824
1836
)
1825
1837
self .assertEquals (200 , channel .code , channel .json_body )
1826
1838
thread_roots = [ev ["event_id" ] for ev in channel .json_body ["chunk" ]]
1827
1839
self .assertEqual (thread_roots , [thread_2 , thread_1 ], channel .json_body )
1828
1840
1829
- @unittest .override_config ({"experimental_features" : {"msc3856_enabled" : True }})
1830
1841
def test_ignored_user (self ) -> None :
1831
1842
"""Events from ignored users should be ignored."""
1832
1843
# Thread 1 has a reply from an ignored user.
@@ -1852,7 +1863,7 @@ def test_ignored_user(self) -> None:
1852
1863
# Only thread 1 is returned.
1853
1864
channel = self .make_request (
1854
1865
"GET" ,
1855
- f"/_matrix/client/unstable/org.matrix.msc3856 /rooms/{ self .room } /threads" ,
1866
+ f"/_matrix/client/v1 /rooms/{ self .room } /threads" ,
1856
1867
access_token = self .user_token ,
1857
1868
)
1858
1869
self .assertEquals (200 , channel .code , channel .json_body )
0 commit comments