mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Fixup functions to consistently return deferreds
This commit is contained in:
parent
b2ee65ea8c
commit
b3a4e35ca8
@ -339,7 +339,7 @@ class SyncHandler(object):
|
|||||||
room_ids = sync_result_builder.joined_room_ids
|
room_ids = sync_result_builder.joined_room_ids
|
||||||
|
|
||||||
typing_source = self.event_sources.sources["typing"]
|
typing_source = self.event_sources.sources["typing"]
|
||||||
typing, typing_key = typing_source.get_new_events(
|
typing, typing_key = await typing_source.get_new_events(
|
||||||
user=sync_config.user,
|
user=sync_config.user,
|
||||||
from_key=typing_key,
|
from_key=typing_key,
|
||||||
limit=sync_config.filter_collection.ephemeral_limit(),
|
limit=sync_config.filter_collection.ephemeral_limit(),
|
||||||
@ -1013,7 +1013,7 @@ class SyncHandler(object):
|
|||||||
now_token = sync_result_builder.now_token
|
now_token = sync_result_builder.now_token
|
||||||
|
|
||||||
if since_token and since_token.groups_key:
|
if since_token and since_token.groups_key:
|
||||||
results = self.store.get_groups_changes_for_user(
|
results = await self.store.get_groups_changes_for_user(
|
||||||
user_id, since_token.groups_key, now_token.groups_key
|
user_id, since_token.groups_key, now_token.groups_key
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@ -1197,7 +1197,7 @@ class SyncHandler(object):
|
|||||||
(
|
(
|
||||||
account_data,
|
account_data,
|
||||||
account_data_by_room,
|
account_data_by_room,
|
||||||
) = self.store.get_updated_account_data_for_user(
|
) = await self.store.get_updated_account_data_for_user(
|
||||||
user_id, since_token.account_data_key
|
user_id, since_token.account_data_key
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -313,7 +313,7 @@ class TypingNotificationEventSource(object):
|
|||||||
|
|
||||||
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.get_typing_handler()._latest_room_serial
|
return self.get_typing_handler()._latest_room_serial
|
||||||
|
@ -250,7 +250,7 @@ class AccountDataWorkerStore(SQLBaseStore):
|
|||||||
user_id, int(stream_id)
|
user_id, int(stream_id)
|
||||||
)
|
)
|
||||||
if not changed:
|
if not changed:
|
||||||
return {}, {}
|
return defer.succeed(({}, {}))
|
||||||
|
|
||||||
return self.runInteraction(
|
return self.runInteraction(
|
||||||
"get_updated_account_data_for_user", get_updated_account_data_for_user_txn
|
"get_updated_account_data_for_user", get_updated_account_data_for_user_txn
|
||||||
|
@ -1109,7 +1109,7 @@ class GroupServerStore(SQLBaseStore):
|
|||||||
user_id, from_token
|
user_id, from_token
|
||||||
)
|
)
|
||||||
if not has_changed:
|
if not has_changed:
|
||||||
return []
|
return defer.succeed([])
|
||||||
|
|
||||||
def _get_groups_changes_for_user_txn(txn):
|
def _get_groups_changes_for_user_txn(txn):
|
||||||
sql = """
|
sql = """
|
||||||
@ -1139,7 +1139,7 @@ class GroupServerStore(SQLBaseStore):
|
|||||||
from_token
|
from_token
|
||||||
)
|
)
|
||||||
if not has_changed:
|
if not has_changed:
|
||||||
return []
|
return defer.succeed([])
|
||||||
|
|
||||||
def _get_all_groups_changes_txn(txn):
|
def _get_all_groups_changes_txn(txn):
|
||||||
sql = """
|
sql = """
|
||||||
|
@ -163,7 +163,9 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
|
|||||||
self.on_new_event.assert_has_calls([call("typing_key", 1, rooms=[ROOM_ID])])
|
self.on_new_event.assert_has_calls([call("typing_key", 1, rooms=[ROOM_ID])])
|
||||||
|
|
||||||
self.assertEquals(self.event_source.get_current_key(), 1)
|
self.assertEquals(self.event_source.get_current_key(), 1)
|
||||||
events = self.event_source.get_new_events(room_ids=[ROOM_ID], from_key=0)
|
events = self.get_success(
|
||||||
|
self.event_source.get_new_events(room_ids=[ROOM_ID], from_key=0)
|
||||||
|
)
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
events[0],
|
events[0],
|
||||||
[
|
[
|
||||||
@ -227,7 +229,9 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
|
|||||||
self.on_new_event.assert_has_calls([call("typing_key", 1, rooms=[ROOM_ID])])
|
self.on_new_event.assert_has_calls([call("typing_key", 1, rooms=[ROOM_ID])])
|
||||||
|
|
||||||
self.assertEquals(self.event_source.get_current_key(), 1)
|
self.assertEquals(self.event_source.get_current_key(), 1)
|
||||||
events = self.event_source.get_new_events(room_ids=[ROOM_ID], from_key=0)
|
events = self.get_success(
|
||||||
|
self.event_source.get_new_events(room_ids=[ROOM_ID], from_key=0)
|
||||||
|
)
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
events[0],
|
events[0],
|
||||||
[
|
[
|
||||||
@ -279,7 +283,9 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.assertEquals(self.event_source.get_current_key(), 1)
|
self.assertEquals(self.event_source.get_current_key(), 1)
|
||||||
events = self.event_source.get_new_events(room_ids=[ROOM_ID], from_key=0)
|
events = self.get_success(
|
||||||
|
self.event_source.get_new_events(room_ids=[ROOM_ID], from_key=0)
|
||||||
|
)
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
events[0],
|
events[0],
|
||||||
[{"type": "m.typing", "room_id": ROOM_ID, "content": {"user_ids": []}}],
|
[{"type": "m.typing", "room_id": ROOM_ID, "content": {"user_ids": []}}],
|
||||||
@ -300,7 +306,9 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
|
|||||||
self.on_new_event.reset_mock()
|
self.on_new_event.reset_mock()
|
||||||
|
|
||||||
self.assertEquals(self.event_source.get_current_key(), 1)
|
self.assertEquals(self.event_source.get_current_key(), 1)
|
||||||
events = self.event_source.get_new_events(room_ids=[ROOM_ID], from_key=0)
|
events = self.get_success(
|
||||||
|
self.event_source.get_new_events(room_ids=[ROOM_ID], from_key=0)
|
||||||
|
)
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
events[0],
|
events[0],
|
||||||
[
|
[
|
||||||
@ -317,7 +325,9 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
|
|||||||
self.on_new_event.assert_has_calls([call("typing_key", 2, rooms=[ROOM_ID])])
|
self.on_new_event.assert_has_calls([call("typing_key", 2, rooms=[ROOM_ID])])
|
||||||
|
|
||||||
self.assertEquals(self.event_source.get_current_key(), 2)
|
self.assertEquals(self.event_source.get_current_key(), 2)
|
||||||
events = self.event_source.get_new_events(room_ids=[ROOM_ID], from_key=1)
|
events = self.get_success(
|
||||||
|
self.event_source.get_new_events(room_ids=[ROOM_ID], from_key=1)
|
||||||
|
)
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
events[0],
|
events[0],
|
||||||
[{"type": "m.typing", "room_id": ROOM_ID, "content": {"user_ids": []}}],
|
[{"type": "m.typing", "room_id": ROOM_ID, "content": {"user_ids": []}}],
|
||||||
@ -335,7 +345,9 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
|
|||||||
self.on_new_event.reset_mock()
|
self.on_new_event.reset_mock()
|
||||||
|
|
||||||
self.assertEquals(self.event_source.get_current_key(), 3)
|
self.assertEquals(self.event_source.get_current_key(), 3)
|
||||||
events = self.event_source.get_new_events(room_ids=[ROOM_ID], from_key=0)
|
events = self.get_success(
|
||||||
|
self.event_source.get_new_events(room_ids=[ROOM_ID], from_key=0)
|
||||||
|
)
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
events[0],
|
events[0],
|
||||||
[
|
[
|
||||||
|
@ -109,7 +109,9 @@ class RoomTypingTestCase(unittest.HomeserverTestCase):
|
|||||||
self.assertEquals(200, channel.code)
|
self.assertEquals(200, channel.code)
|
||||||
|
|
||||||
self.assertEquals(self.event_source.get_current_key(), 1)
|
self.assertEquals(self.event_source.get_current_key(), 1)
|
||||||
events = self.event_source.get_new_events(from_key=0, room_ids=[self.room_id])
|
events = self.get_success(
|
||||||
|
self.event_source.get_new_events(from_key=0, room_ids=[self.room_id])
|
||||||
|
)
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
events[0],
|
events[0],
|
||||||
[
|
[
|
||||||
|
Loading…
Reference in New Issue
Block a user