Skip to content
Snippets Groups Projects
Unverified Commit b0cbc573 authored by Patrick Cloke's avatar Patrick Cloke Committed by GitHub
Browse files

Convert the synapse.notifier module to async/await. (#7395)

parent 97ef1471
No related branches found
No related tags found
No related merge requests found
Convert synapse.notifier to async/await.
...@@ -273,10 +273,9 @@ class Notifier(object): ...@@ -273,10 +273,9 @@ class Notifier(object):
"room_key", room_stream_id, users=extra_users, rooms=[event.room_id] "room_key", room_stream_id, users=extra_users, rooms=[event.room_id]
) )
@defer.inlineCallbacks async def _notify_app_services(self, room_stream_id):
def _notify_app_services(self, room_stream_id):
try: try:
yield self.appservice_handler.notify_interested_services(room_stream_id) await self.appservice_handler.notify_interested_services(room_stream_id)
except Exception: except Exception:
logger.exception("Error notifying application services of event") logger.exception("Error notifying application services of event")
...@@ -475,20 +474,18 @@ class Notifier(object): ...@@ -475,20 +474,18 @@ class Notifier(object):
return result return result
@defer.inlineCallbacks async def _get_room_ids(self, user, explicit_room_id):
def _get_room_ids(self, user, explicit_room_id): joined_room_ids = await self.store.get_rooms_for_user(user.to_string())
joined_room_ids = yield self.store.get_rooms_for_user(user.to_string())
if explicit_room_id: if explicit_room_id:
if explicit_room_id in joined_room_ids: if explicit_room_id in joined_room_ids:
return [explicit_room_id], True return [explicit_room_id], True
if (yield self._is_world_readable(explicit_room_id)): if await self._is_world_readable(explicit_room_id):
return [explicit_room_id], False return [explicit_room_id], False
raise AuthError(403, "Non-joined access not allowed") raise AuthError(403, "Non-joined access not allowed")
return joined_room_ids, True return joined_room_ids, True
@defer.inlineCallbacks async def _is_world_readable(self, room_id):
def _is_world_readable(self, room_id): state = await self.state_handler.get_current_state(
state = yield self.state_handler.get_current_state(
room_id, EventTypes.RoomHistoryVisibility, "" room_id, EventTypes.RoomHistoryVisibility, ""
) )
if state and "history_visibility" in state.content: if state and "history_visibility" in state.content:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment