test_sync.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. # Copyright 2018-2019 New Vector Ltd
  2. # Copyright 2019 The Matrix.org Foundation C.I.C.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. import json
  16. import synapse.rest.admin
  17. from synapse.api.constants import (
  18. EventContentFields,
  19. EventTypes,
  20. ReadReceiptEventFields,
  21. RelationTypes,
  22. )
  23. from synapse.rest.client import knock, login, read_marker, receipts, room, sync
  24. from tests import unittest
  25. from tests.federation.transport.test_knocking import (
  26. KnockingStrippedStateEventHelperMixin,
  27. )
  28. from tests.server import TimedOutException
  29. from tests.unittest import override_config
  30. class FilterTestCase(unittest.HomeserverTestCase):
  31. user_id = "@apple:test"
  32. servlets = [
  33. synapse.rest.admin.register_servlets_for_client_rest_resource,
  34. room.register_servlets,
  35. login.register_servlets,
  36. sync.register_servlets,
  37. ]
  38. def test_sync_argless(self):
  39. channel = self.make_request("GET", "/sync")
  40. self.assertEqual(channel.code, 200)
  41. self.assertIn("next_batch", channel.json_body)
  42. class SyncFilterTestCase(unittest.HomeserverTestCase):
  43. servlets = [
  44. synapse.rest.admin.register_servlets_for_client_rest_resource,
  45. room.register_servlets,
  46. login.register_servlets,
  47. sync.register_servlets,
  48. ]
  49. def test_sync_filter_labels(self):
  50. """Test that we can filter by a label."""
  51. sync_filter = json.dumps(
  52. {
  53. "room": {
  54. "timeline": {
  55. "types": [EventTypes.Message],
  56. "org.matrix.labels": ["#fun"],
  57. }
  58. }
  59. }
  60. )
  61. events = self._test_sync_filter_labels(sync_filter)
  62. self.assertEqual(len(events), 2, [event["content"] for event in events])
  63. self.assertEqual(events[0]["content"]["body"], "with right label", events[0])
  64. self.assertEqual(events[1]["content"]["body"], "with right label", events[1])
  65. def test_sync_filter_not_labels(self):
  66. """Test that we can filter by the absence of a label."""
  67. sync_filter = json.dumps(
  68. {
  69. "room": {
  70. "timeline": {
  71. "types": [EventTypes.Message],
  72. "org.matrix.not_labels": ["#fun"],
  73. }
  74. }
  75. }
  76. )
  77. events = self._test_sync_filter_labels(sync_filter)
  78. self.assertEqual(len(events), 3, [event["content"] for event in events])
  79. self.assertEqual(events[0]["content"]["body"], "without label", events[0])
  80. self.assertEqual(events[1]["content"]["body"], "with wrong label", events[1])
  81. self.assertEqual(
  82. events[2]["content"]["body"], "with two wrong labels", events[2]
  83. )
  84. def test_sync_filter_labels_not_labels(self):
  85. """Test that we can filter by both a label and the absence of another label."""
  86. sync_filter = json.dumps(
  87. {
  88. "room": {
  89. "timeline": {
  90. "types": [EventTypes.Message],
  91. "org.matrix.labels": ["#work"],
  92. "org.matrix.not_labels": ["#notfun"],
  93. }
  94. }
  95. }
  96. )
  97. events = self._test_sync_filter_labels(sync_filter)
  98. self.assertEqual(len(events), 1, [event["content"] for event in events])
  99. self.assertEqual(events[0]["content"]["body"], "with wrong label", events[0])
  100. def _test_sync_filter_labels(self, sync_filter):
  101. user_id = self.register_user("kermit", "test")
  102. tok = self.login("kermit", "test")
  103. room_id = self.helper.create_room_as(user_id, tok=tok)
  104. self.helper.send_event(
  105. room_id=room_id,
  106. type=EventTypes.Message,
  107. content={
  108. "msgtype": "m.text",
  109. "body": "with right label",
  110. EventContentFields.LABELS: ["#fun"],
  111. },
  112. tok=tok,
  113. )
  114. self.helper.send_event(
  115. room_id=room_id,
  116. type=EventTypes.Message,
  117. content={"msgtype": "m.text", "body": "without label"},
  118. tok=tok,
  119. )
  120. self.helper.send_event(
  121. room_id=room_id,
  122. type=EventTypes.Message,
  123. content={
  124. "msgtype": "m.text",
  125. "body": "with wrong label",
  126. EventContentFields.LABELS: ["#work"],
  127. },
  128. tok=tok,
  129. )
  130. self.helper.send_event(
  131. room_id=room_id,
  132. type=EventTypes.Message,
  133. content={
  134. "msgtype": "m.text",
  135. "body": "with two wrong labels",
  136. EventContentFields.LABELS: ["#work", "#notfun"],
  137. },
  138. tok=tok,
  139. )
  140. self.helper.send_event(
  141. room_id=room_id,
  142. type=EventTypes.Message,
  143. content={
  144. "msgtype": "m.text",
  145. "body": "with right label",
  146. EventContentFields.LABELS: ["#fun"],
  147. },
  148. tok=tok,
  149. )
  150. channel = self.make_request(
  151. "GET", "/sync?filter=%s" % sync_filter, access_token=tok
  152. )
  153. self.assertEqual(channel.code, 200, channel.result)
  154. return channel.json_body["rooms"]["join"][room_id]["timeline"]["events"]
  155. class SyncTypingTests(unittest.HomeserverTestCase):
  156. servlets = [
  157. synapse.rest.admin.register_servlets_for_client_rest_resource,
  158. room.register_servlets,
  159. login.register_servlets,
  160. sync.register_servlets,
  161. ]
  162. user_id = True
  163. hijack_auth = False
  164. def test_sync_backwards_typing(self):
  165. """
  166. If the typing serial goes backwards and the typing handler is then reset
  167. (such as when the master restarts and sets the typing serial to 0), we
  168. do not incorrectly return typing information that had a serial greater
  169. than the now-reset serial.
  170. """
  171. typing_url = "/rooms/%s/typing/%s?access_token=%s"
  172. sync_url = "/sync?timeout=3000000&access_token=%s&since=%s"
  173. # Register the user who gets notified
  174. user_id = self.register_user("user", "pass")
  175. access_token = self.login("user", "pass")
  176. # Register the user who sends the message
  177. other_user_id = self.register_user("otheruser", "pass")
  178. other_access_token = self.login("otheruser", "pass")
  179. # Create a room
  180. room = self.helper.create_room_as(user_id, tok=access_token)
  181. # Invite the other person
  182. self.helper.invite(room=room, src=user_id, tok=access_token, targ=other_user_id)
  183. # The other user joins
  184. self.helper.join(room=room, user=other_user_id, tok=other_access_token)
  185. # The other user sends some messages
  186. self.helper.send(room, body="Hi!", tok=other_access_token)
  187. self.helper.send(room, body="There!", tok=other_access_token)
  188. # Start typing.
  189. channel = self.make_request(
  190. "PUT",
  191. typing_url % (room, other_user_id, other_access_token),
  192. b'{"typing": true, "timeout": 30000}',
  193. )
  194. self.assertEquals(200, channel.code)
  195. channel = self.make_request("GET", "/sync?access_token=%s" % (access_token,))
  196. self.assertEquals(200, channel.code)
  197. next_batch = channel.json_body["next_batch"]
  198. # Stop typing.
  199. channel = self.make_request(
  200. "PUT",
  201. typing_url % (room, other_user_id, other_access_token),
  202. b'{"typing": false}',
  203. )
  204. self.assertEquals(200, channel.code)
  205. # Start typing.
  206. channel = self.make_request(
  207. "PUT",
  208. typing_url % (room, other_user_id, other_access_token),
  209. b'{"typing": true, "timeout": 30000}',
  210. )
  211. self.assertEquals(200, channel.code)
  212. # Should return immediately
  213. channel = self.make_request("GET", sync_url % (access_token, next_batch))
  214. self.assertEquals(200, channel.code)
  215. next_batch = channel.json_body["next_batch"]
  216. # Reset typing serial back to 0, as if the master had.
  217. typing = self.hs.get_typing_handler()
  218. typing._latest_room_serial = 0
  219. # Since it checks the state token, we need some state to update to
  220. # invalidate the stream token.
  221. self.helper.send(room, body="There!", tok=other_access_token)
  222. channel = self.make_request("GET", sync_url % (access_token, next_batch))
  223. self.assertEquals(200, channel.code)
  224. next_batch = channel.json_body["next_batch"]
  225. # This should time out! But it does not, because our stream token is
  226. # ahead, and therefore it's saying the typing (that we've actually
  227. # already seen) is new, since it's got a token above our new, now-reset
  228. # stream token.
  229. channel = self.make_request("GET", sync_url % (access_token, next_batch))
  230. self.assertEquals(200, channel.code)
  231. next_batch = channel.json_body["next_batch"]
  232. # Clear the typing information, so that it doesn't think everything is
  233. # in the future.
  234. typing._reset()
  235. # Now it SHOULD fail as it never completes!
  236. with self.assertRaises(TimedOutException):
  237. self.make_request("GET", sync_url % (access_token, next_batch))
  238. class SyncKnockTestCase(
  239. unittest.HomeserverTestCase, KnockingStrippedStateEventHelperMixin
  240. ):
  241. servlets = [
  242. synapse.rest.admin.register_servlets,
  243. login.register_servlets,
  244. room.register_servlets,
  245. sync.register_servlets,
  246. knock.register_servlets,
  247. ]
  248. def prepare(self, reactor, clock, hs):
  249. self.store = hs.get_datastore()
  250. self.url = "/sync?since=%s"
  251. self.next_batch = "s0"
  252. # Register the first user (used to create the room to knock on).
  253. self.user_id = self.register_user("kermit", "monkey")
  254. self.tok = self.login("kermit", "monkey")
  255. # Create the room we'll knock on.
  256. self.room_id = self.helper.create_room_as(
  257. self.user_id,
  258. is_public=False,
  259. room_version="7",
  260. tok=self.tok,
  261. )
  262. # Register the second user (used to knock on the room).
  263. self.knocker = self.register_user("knocker", "monkey")
  264. self.knocker_tok = self.login("knocker", "monkey")
  265. # Perform an initial sync for the knocking user.
  266. channel = self.make_request(
  267. "GET",
  268. self.url % self.next_batch,
  269. access_token=self.tok,
  270. )
  271. self.assertEqual(channel.code, 200, channel.json_body)
  272. # Store the next batch for the next request.
  273. self.next_batch = channel.json_body["next_batch"]
  274. # Set up some room state to test with.
  275. self.expected_room_state = self.send_example_state_events_to_room(
  276. hs, self.room_id, self.user_id
  277. )
  278. @override_config({"experimental_features": {"msc2403_enabled": True}})
  279. def test_knock_room_state(self):
  280. """Tests that /sync returns state from a room after knocking on it."""
  281. # Knock on a room
  282. channel = self.make_request(
  283. "POST",
  284. "/_matrix/client/r0/knock/%s" % (self.room_id,),
  285. b"{}",
  286. self.knocker_tok,
  287. )
  288. self.assertEquals(200, channel.code, channel.result)
  289. # We expect to see the knock event in the stripped room state later
  290. self.expected_room_state[EventTypes.Member] = {
  291. "content": {"membership": "knock", "displayname": "knocker"},
  292. "state_key": "@knocker:test",
  293. }
  294. # Check that /sync includes stripped state from the room
  295. channel = self.make_request(
  296. "GET",
  297. self.url % self.next_batch,
  298. access_token=self.knocker_tok,
  299. )
  300. self.assertEqual(channel.code, 200, channel.json_body)
  301. # Extract the stripped room state events from /sync
  302. knock_entry = channel.json_body["rooms"]["knock"]
  303. room_state_events = knock_entry[self.room_id]["knock_state"]["events"]
  304. # Validate that the knock membership event came last
  305. self.assertEqual(room_state_events[-1]["type"], EventTypes.Member)
  306. # Validate the stripped room state events
  307. self.check_knock_room_state_against_room_state(
  308. room_state_events, self.expected_room_state
  309. )
  310. class ReadReceiptsTestCase(unittest.HomeserverTestCase):
  311. servlets = [
  312. synapse.rest.admin.register_servlets,
  313. login.register_servlets,
  314. receipts.register_servlets,
  315. room.register_servlets,
  316. sync.register_servlets,
  317. ]
  318. def prepare(self, reactor, clock, hs):
  319. self.url = "/sync?since=%s"
  320. self.next_batch = "s0"
  321. # Register the first user
  322. self.user_id = self.register_user("kermit", "monkey")
  323. self.tok = self.login("kermit", "monkey")
  324. # Create the room
  325. self.room_id = self.helper.create_room_as(self.user_id, tok=self.tok)
  326. # Register the second user
  327. self.user2 = self.register_user("kermit2", "monkey")
  328. self.tok2 = self.login("kermit2", "monkey")
  329. # Join the second user
  330. self.helper.join(room=self.room_id, user=self.user2, tok=self.tok2)
  331. @override_config({"experimental_features": {"msc2285_enabled": True}})
  332. def test_hidden_read_receipts(self):
  333. # Send a message as the first user
  334. res = self.helper.send(self.room_id, body="hello", tok=self.tok)
  335. # Send a read receipt to tell the server the first user's message was read
  336. body = json.dumps({ReadReceiptEventFields.MSC2285_HIDDEN: True}).encode("utf8")
  337. channel = self.make_request(
  338. "POST",
  339. "/rooms/%s/receipt/m.read/%s" % (self.room_id, res["event_id"]),
  340. body,
  341. access_token=self.tok2,
  342. )
  343. self.assertEqual(channel.code, 200)
  344. # Test that the first user can't see the other user's hidden read receipt
  345. self.assertEqual(self._get_read_receipt(), None)
  346. def test_read_receipt_with_empty_body(self):
  347. # Send a message as the first user
  348. res = self.helper.send(self.room_id, body="hello", tok=self.tok)
  349. # Send a read receipt for this message with an empty body
  350. channel = self.make_request(
  351. "POST",
  352. "/rooms/%s/receipt/m.read/%s" % (self.room_id, res["event_id"]),
  353. access_token=self.tok2,
  354. )
  355. self.assertEqual(channel.code, 200)
  356. def _get_read_receipt(self):
  357. """Syncs and returns the read receipt."""
  358. # Checks if event is a read receipt
  359. def is_read_receipt(event):
  360. return event["type"] == "m.receipt"
  361. # Sync
  362. channel = self.make_request(
  363. "GET",
  364. self.url % self.next_batch,
  365. access_token=self.tok,
  366. )
  367. self.assertEqual(channel.code, 200)
  368. # Store the next batch for the next request.
  369. self.next_batch = channel.json_body["next_batch"]
  370. # Return the read receipt
  371. ephemeral_events = channel.json_body["rooms"]["join"][self.room_id][
  372. "ephemeral"
  373. ]["events"]
  374. return next(filter(is_read_receipt, ephemeral_events), None)
  375. class UnreadMessagesTestCase(unittest.HomeserverTestCase):
  376. servlets = [
  377. synapse.rest.admin.register_servlets,
  378. login.register_servlets,
  379. read_marker.register_servlets,
  380. room.register_servlets,
  381. sync.register_servlets,
  382. receipts.register_servlets,
  383. ]
  384. def prepare(self, reactor, clock, hs):
  385. self.url = "/sync?since=%s"
  386. self.next_batch = "s0"
  387. # Register the first user (used to check the unread counts).
  388. self.user_id = self.register_user("kermit", "monkey")
  389. self.tok = self.login("kermit", "monkey")
  390. # Create the room we'll check unread counts for.
  391. self.room_id = self.helper.create_room_as(self.user_id, tok=self.tok)
  392. # Register the second user (used to send events to the room).
  393. self.user2 = self.register_user("kermit2", "monkey")
  394. self.tok2 = self.login("kermit2", "monkey")
  395. # Change the power levels of the room so that the second user can send state
  396. # events.
  397. self.helper.send_state(
  398. self.room_id,
  399. EventTypes.PowerLevels,
  400. {
  401. "users": {self.user_id: 100, self.user2: 100},
  402. "users_default": 0,
  403. "events": {
  404. "m.room.name": 50,
  405. "m.room.power_levels": 100,
  406. "m.room.history_visibility": 100,
  407. "m.room.canonical_alias": 50,
  408. "m.room.avatar": 50,
  409. "m.room.tombstone": 100,
  410. "m.room.server_acl": 100,
  411. "m.room.encryption": 100,
  412. },
  413. "events_default": 0,
  414. "state_default": 50,
  415. "ban": 50,
  416. "kick": 50,
  417. "redact": 50,
  418. "invite": 0,
  419. },
  420. tok=self.tok,
  421. )
  422. def test_unread_counts(self):
  423. """Tests that /sync returns the right value for the unread count (MSC2654)."""
  424. # Check that our own messages don't increase the unread count.
  425. self.helper.send(self.room_id, "hello", tok=self.tok)
  426. self._check_unread_count(0)
  427. # Join the new user and check that this doesn't increase the unread count.
  428. self.helper.join(room=self.room_id, user=self.user2, tok=self.tok2)
  429. self._check_unread_count(0)
  430. # Check that the new user sending a message increases our unread count.
  431. res = self.helper.send(self.room_id, "hello", tok=self.tok2)
  432. self._check_unread_count(1)
  433. # Send a read receipt to tell the server we've read the latest event.
  434. body = json.dumps({"m.read": res["event_id"]}).encode("utf8")
  435. channel = self.make_request(
  436. "POST",
  437. "/rooms/%s/read_markers" % self.room_id,
  438. body,
  439. access_token=self.tok,
  440. )
  441. self.assertEqual(channel.code, 200, channel.json_body)
  442. # Check that the unread counter is back to 0.
  443. self._check_unread_count(0)
  444. # Check that hidden read receipts don't break unread counts
  445. res = self.helper.send(self.room_id, "hello", tok=self.tok2)
  446. self._check_unread_count(1)
  447. # Send a read receipt to tell the server we've read the latest event.
  448. body = json.dumps({ReadReceiptEventFields.MSC2285_HIDDEN: True}).encode("utf8")
  449. channel = self.make_request(
  450. "POST",
  451. "/rooms/%s/receipt/m.read/%s" % (self.room_id, res["event_id"]),
  452. body,
  453. access_token=self.tok,
  454. )
  455. self.assertEqual(channel.code, 200, channel.json_body)
  456. # Check that the unread counter is back to 0.
  457. self._check_unread_count(0)
  458. # Check that room name changes increase the unread counter.
  459. self.helper.send_state(
  460. self.room_id,
  461. "m.room.name",
  462. {"name": "my super room"},
  463. tok=self.tok2,
  464. )
  465. self._check_unread_count(1)
  466. # Check that room topic changes increase the unread counter.
  467. self.helper.send_state(
  468. self.room_id,
  469. "m.room.topic",
  470. {"topic": "welcome!!!"},
  471. tok=self.tok2,
  472. )
  473. self._check_unread_count(2)
  474. # Check that encrypted messages increase the unread counter.
  475. self.helper.send_event(self.room_id, EventTypes.Encrypted, {}, tok=self.tok2)
  476. self._check_unread_count(3)
  477. # Check that custom events with a body increase the unread counter.
  478. self.helper.send_event(
  479. self.room_id,
  480. "org.matrix.custom_type",
  481. {"body": "hello"},
  482. tok=self.tok2,
  483. )
  484. self._check_unread_count(4)
  485. # Check that edits don't increase the unread counter.
  486. self.helper.send_event(
  487. room_id=self.room_id,
  488. type=EventTypes.Message,
  489. content={
  490. "body": "hello",
  491. "msgtype": "m.text",
  492. "m.relates_to": {"rel_type": RelationTypes.REPLACE},
  493. },
  494. tok=self.tok2,
  495. )
  496. self._check_unread_count(4)
  497. # Check that notices don't increase the unread counter.
  498. self.helper.send_event(
  499. room_id=self.room_id,
  500. type=EventTypes.Message,
  501. content={"body": "hello", "msgtype": "m.notice"},
  502. tok=self.tok2,
  503. )
  504. self._check_unread_count(4)
  505. # Check that tombstone events changes increase the unread counter.
  506. self.helper.send_state(
  507. self.room_id,
  508. EventTypes.Tombstone,
  509. {"replacement_room": "!someroom:test"},
  510. tok=self.tok2,
  511. )
  512. self._check_unread_count(5)
  513. def _check_unread_count(self, expected_count: int):
  514. """Syncs and compares the unread count with the expected value."""
  515. channel = self.make_request(
  516. "GET",
  517. self.url % self.next_batch,
  518. access_token=self.tok,
  519. )
  520. self.assertEqual(channel.code, 200, channel.json_body)
  521. room_entry = channel.json_body["rooms"]["join"][self.room_id]
  522. self.assertEqual(
  523. room_entry["org.matrix.msc2654.unread_count"],
  524. expected_count,
  525. room_entry,
  526. )
  527. # Store the next batch for the next request.
  528. self.next_batch = channel.json_body["next_batch"]
  529. class SyncCacheTestCase(unittest.HomeserverTestCase):
  530. servlets = [
  531. synapse.rest.admin.register_servlets,
  532. login.register_servlets,
  533. sync.register_servlets,
  534. ]
  535. def test_noop_sync_does_not_tightloop(self):
  536. """If the sync times out, we shouldn't cache the result
  537. Essentially a regression test for #8518.
  538. """
  539. self.user_id = self.register_user("kermit", "monkey")
  540. self.tok = self.login("kermit", "monkey")
  541. # we should immediately get an initial sync response
  542. channel = self.make_request("GET", "/sync", access_token=self.tok)
  543. self.assertEqual(channel.code, 200, channel.json_body)
  544. # now, make an incremental sync request, with a timeout
  545. next_batch = channel.json_body["next_batch"]
  546. channel = self.make_request(
  547. "GET",
  548. f"/sync?since={next_batch}&timeout=10000",
  549. access_token=self.tok,
  550. await_result=False,
  551. )
  552. # that should block for 10 seconds
  553. with self.assertRaises(TimedOutException):
  554. channel.await_result(timeout_ms=9900)
  555. channel.await_result(timeout_ms=200)
  556. self.assertEqual(channel.code, 200, channel.json_body)
  557. # we expect the next_batch in the result to be the same as before
  558. self.assertEqual(channel.json_body["next_batch"], next_batch)
  559. # another incremental sync should also block.
  560. channel = self.make_request(
  561. "GET",
  562. f"/sync?since={next_batch}&timeout=10000",
  563. access_token=self.tok,
  564. await_result=False,
  565. )
  566. # that should block for 10 seconds
  567. with self.assertRaises(TimedOutException):
  568. channel.await_result(timeout_ms=9900)
  569. channel.await_result(timeout_ms=200)
  570. self.assertEqual(channel.code, 200, channel.json_body)