Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit d510975

Browse files
committed
Test ignored users.
1 parent 8dcdb4e commit d510975

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

tests/rest/client/test_relations.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1796,4 +1796,35 @@ def test_include(self) -> None:
17961796
thread_roots = [ev["event_id"] for ev in channel.json_body["chunk"]]
17971797
self.assertEqual(thread_roots, [thread_2, thread_1], channel.json_body)
17981798

1799-
# XXX Test ignoring users.
1799+
@unittest.override_config({"experimental_features": {"msc3856_enabled": True}})
1800+
def test_ignored_user(self) -> None:
1801+
"""Events from ignored users should be ignored."""
1802+
# Thread 1 has a reply from an ignored user.
1803+
thread_1 = self.parent_id
1804+
self._send_relation(
1805+
RelationTypes.THREAD, "m.room.test", access_token=self.user2_token
1806+
)
1807+
1808+
# Thread 2 is created by an ignored user.
1809+
res = self.helper.send(self.room, body="Thread Root!", tok=self.user2_token)
1810+
thread_2 = res["event_id"]
1811+
self._send_relation(RelationTypes.THREAD, "m.room.test", parent_id=thread_2)
1812+
1813+
# Ignore user2.
1814+
self.get_success(
1815+
self.store.add_account_data_for_user(
1816+
self.user_id,
1817+
AccountDataTypes.IGNORED_USER_LIST,
1818+
{"ignored_users": {self.user2_id: {}}},
1819+
)
1820+
)
1821+
1822+
# Only thread 1 is returned.
1823+
channel = self.make_request(
1824+
"GET",
1825+
f"/_matrix/client/unstable/org.matrix.msc3856/rooms/{self.room}/threads",
1826+
access_token=self.user_token,
1827+
)
1828+
self.assertEquals(200, channel.code, channel.json_body)
1829+
thread_roots = [ev["event_id"] for ev in channel.json_body["chunk"]]
1830+
self.assertEqual(thread_roots, [thread_1], channel.json_body)

0 commit comments

Comments
 (0)