mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-14 04:33:47 +01:00
Have TypingNotificationEventSource.get_new_events_for_user() return a deferred, for consistency and extensibility
This commit is contained in:
parent
399b5add58
commit
0268d40281
3 changed files with 15 additions and 8 deletions
|
@ -252,7 +252,7 @@ class TypingNotificationEventSource(object):
|
||||||
# TODO: check if user is in room
|
# TODO: check if user is in room
|
||||||
events.append(self._make_event_for(room_id))
|
events.append(self._make_event_for(room_id))
|
||||||
|
|
||||||
return (events, handler._latest_room_serial)
|
return defer.succeed((events, handler._latest_room_serial))
|
||||||
|
|
||||||
def get_current_key(self):
|
def get_current_key(self):
|
||||||
return self.handler()._latest_room_serial
|
return self.handler()._latest_room_serial
|
||||||
|
|
|
@ -175,8 +175,9 @@ class TypingNotificationsTestCase(unittest.TestCase):
|
||||||
])
|
])
|
||||||
|
|
||||||
self.assertEquals(self.event_source.get_current_key(), 1)
|
self.assertEquals(self.event_source.get_current_key(), 1)
|
||||||
|
events = yield self.event_source.get_new_events_for_user(self.u_apple, 0, None)
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
self.event_source.get_new_events_for_user(self.u_apple, 0, None)[0],
|
events[0],
|
||||||
[
|
[
|
||||||
{"type": "m.typing",
|
{"type": "m.typing",
|
||||||
"room_id": self.room_id,
|
"room_id": self.room_id,
|
||||||
|
@ -237,8 +238,9 @@ class TypingNotificationsTestCase(unittest.TestCase):
|
||||||
])
|
])
|
||||||
|
|
||||||
self.assertEquals(self.event_source.get_current_key(), 1)
|
self.assertEquals(self.event_source.get_current_key(), 1)
|
||||||
|
events = yield self.event_source.get_new_events_for_user(self.u_apple, 0, None)
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
self.event_source.get_new_events_for_user(self.u_apple, 0, None)[0],
|
events[0],
|
||||||
[
|
[
|
||||||
{"type": "m.typing",
|
{"type": "m.typing",
|
||||||
"room_id": self.room_id,
|
"room_id": self.room_id,
|
||||||
|
@ -292,8 +294,9 @@ class TypingNotificationsTestCase(unittest.TestCase):
|
||||||
yield put_json.await_calls()
|
yield put_json.await_calls()
|
||||||
|
|
||||||
self.assertEquals(self.event_source.get_current_key(), 1)
|
self.assertEquals(self.event_source.get_current_key(), 1)
|
||||||
|
events = yield self.event_source.get_new_events_for_user(self.u_apple, 0, None)
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
self.event_source.get_new_events_for_user(self.u_apple, 0, None)[0],
|
events[0],
|
||||||
[
|
[
|
||||||
{"type": "m.typing",
|
{"type": "m.typing",
|
||||||
"room_id": self.room_id,
|
"room_id": self.room_id,
|
||||||
|
@ -322,8 +325,9 @@ class TypingNotificationsTestCase(unittest.TestCase):
|
||||||
self.on_new_user_event.reset_mock()
|
self.on_new_user_event.reset_mock()
|
||||||
|
|
||||||
self.assertEquals(self.event_source.get_current_key(), 1)
|
self.assertEquals(self.event_source.get_current_key(), 1)
|
||||||
|
events = yield self.event_source.get_new_events_for_user(self.u_apple, 0, None)
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
self.event_source.get_new_events_for_user(self.u_apple, 0, None)[0],
|
events[0],
|
||||||
[
|
[
|
||||||
{"type": "m.typing",
|
{"type": "m.typing",
|
||||||
"room_id": self.room_id,
|
"room_id": self.room_id,
|
||||||
|
@ -340,8 +344,9 @@ class TypingNotificationsTestCase(unittest.TestCase):
|
||||||
])
|
])
|
||||||
|
|
||||||
self.assertEquals(self.event_source.get_current_key(), 2)
|
self.assertEquals(self.event_source.get_current_key(), 2)
|
||||||
|
events = yield self.event_source.get_new_events_for_user(self.u_apple, 1, None)
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
self.event_source.get_new_events_for_user(self.u_apple, 1, None)[0],
|
events[0],
|
||||||
[
|
[
|
||||||
{"type": "m.typing",
|
{"type": "m.typing",
|
||||||
"room_id": self.room_id,
|
"room_id": self.room_id,
|
||||||
|
@ -366,8 +371,9 @@ class TypingNotificationsTestCase(unittest.TestCase):
|
||||||
self.on_new_user_event.reset_mock()
|
self.on_new_user_event.reset_mock()
|
||||||
|
|
||||||
self.assertEquals(self.event_source.get_current_key(), 3)
|
self.assertEquals(self.event_source.get_current_key(), 3)
|
||||||
|
events = yield self.event_source.get_new_events_for_user(self.u_apple, 0, None)
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
self.event_source.get_new_events_for_user(self.u_apple, 0, None)[0],
|
events[0],
|
||||||
[
|
[
|
||||||
{"type": "m.typing",
|
{"type": "m.typing",
|
||||||
"room_id": self.room_id,
|
"room_id": self.room_id,
|
||||||
|
|
|
@ -115,8 +115,9 @@ class RoomTypingTestCase(RestTestCase):
|
||||||
self.assertEquals(200, code)
|
self.assertEquals(200, code)
|
||||||
|
|
||||||
self.assertEquals(self.event_source.get_current_key(), 1)
|
self.assertEquals(self.event_source.get_current_key(), 1)
|
||||||
|
events = yield self.event_source.get_new_events_for_user(self.user_id, 0, None)
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
self.event_source.get_new_events_for_user(self.user_id, 0, None)[0],
|
events[0],
|
||||||
[
|
[
|
||||||
{"type": "m.typing",
|
{"type": "m.typing",
|
||||||
"room_id": self.room_id,
|
"room_id": self.room_id,
|
||||||
|
|
Loading…
Reference in a new issue