Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit b0cbc57

Browse files
authored
Convert the synapse.notifier module to async/await. (#7395)
1 parent 97ef147 commit b0cbc57

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

changelog.d/7395.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Convert synapse.notifier to async/await.

synapse/notifier.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,9 @@ def _on_new_room_event(self, event, room_stream_id, extra_users=[]):
273273
"room_key", room_stream_id, users=extra_users, rooms=[event.room_id]
274274
)
275275

276-
@defer.inlineCallbacks
277-
def _notify_app_services(self, room_stream_id):
276+
async def _notify_app_services(self, room_stream_id):
278277
try:
279-
yield self.appservice_handler.notify_interested_services(room_stream_id)
278+
await self.appservice_handler.notify_interested_services(room_stream_id)
280279
except Exception:
281280
logger.exception("Error notifying application services of event")
282281

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

476475
return result
477476

478-
@defer.inlineCallbacks
479-
def _get_room_ids(self, user, explicit_room_id):
480-
joined_room_ids = yield self.store.get_rooms_for_user(user.to_string())
477+
async def _get_room_ids(self, user, explicit_room_id):
478+
joined_room_ids = await self.store.get_rooms_for_user(user.to_string())
481479
if explicit_room_id:
482480
if explicit_room_id in joined_room_ids:
483481
return [explicit_room_id], True
484-
if (yield self._is_world_readable(explicit_room_id)):
482+
if await self._is_world_readable(explicit_room_id):
485483
return [explicit_room_id], False
486484
raise AuthError(403, "Non-joined access not allowed")
487485
return joined_room_ids, True
488486

489-
@defer.inlineCallbacks
490-
def _is_world_readable(self, room_id):
491-
state = yield self.state_handler.get_current_state(
487+
async def _is_world_readable(self, room_id):
488+
state = await self.state_handler.get_current_state(
492489
room_id, EventTypes.RoomHistoryVisibility, ""
493490
)
494491
if state and "history_visibility" in state.content:

0 commit comments

Comments
 (0)