Skip to content

Commit

Permalink
Convert the synapse.notifier module to async/await. (matrix-org#7395)
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep authored and phil-flex committed Jun 16, 2020
1 parent aea0541 commit 9c7e95a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
1 change: 1 addition & 0 deletions changelog.d/7395.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Convert synapse.notifier to async/await.
17 changes: 7 additions & 10 deletions synapse/notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,9 @@ def _on_new_room_event(self, event, room_stream_id, extra_users=[]):
"room_key", room_stream_id, users=extra_users, rooms=[event.room_id]
)

@defer.inlineCallbacks
def _notify_app_services(self, room_stream_id):
async def _notify_app_services(self, room_stream_id):
try:
yield self.appservice_handler.notify_interested_services(room_stream_id)
await self.appservice_handler.notify_interested_services(room_stream_id)
except Exception:
logger.exception("Error notifying application services of event")

Expand Down Expand Up @@ -475,20 +474,18 @@ async def check_for_updates(before_token, after_token):

return result

@defer.inlineCallbacks
def _get_room_ids(self, user, explicit_room_id):
joined_room_ids = yield self.store.get_rooms_for_user(user.to_string())
async def _get_room_ids(self, user, explicit_room_id):
joined_room_ids = await self.store.get_rooms_for_user(user.to_string())
if explicit_room_id:
if explicit_room_id in joined_room_ids:
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
raise AuthError(403, "Non-joined access not allowed")
return joined_room_ids, True

@defer.inlineCallbacks
def _is_world_readable(self, room_id):
state = yield self.state_handler.get_current_state(
async def _is_world_readable(self, room_id):
state = await self.state_handler.get_current_state(
room_id, EventTypes.RoomHistoryVisibility, ""
)
if state and "history_visibility" in state.content:
Expand Down

0 comments on commit 9c7e95a

Please sign in to comment.