fix: test for callback existance before running it
This commit is contained in:
parent
f570579fb4
commit
7183358f48
1 changed files with 5 additions and 5 deletions
|
@ -58,11 +58,9 @@ class AppService:
|
|||
self.logger.warn("unhandled event of type %s, ignoring", event["type"])
|
||||
continue
|
||||
self.logger.debug("dispatching event %s for %s", event.type)
|
||||
if event.type not in self._callbacks:
|
||||
self._callbacks[event.type] = {}
|
||||
asyncio.get_event_loop().create_task(
|
||||
self._callbacks[event.type][event.room_id](event)
|
||||
)
|
||||
callback = self._callbacks.get(event.type, {}).get(event.room_id, None)
|
||||
if callback is not None:
|
||||
asyncio.get_event_loop().create_task(callback(event))
|
||||
|
||||
return web.Response()
|
||||
|
||||
|
@ -72,6 +70,8 @@ class AppService:
|
|||
key = EventType[event]
|
||||
else:
|
||||
key = event
|
||||
if event.type not in self._callbacks:
|
||||
self._callbacks[event.type] = {}
|
||||
self._callbacks[key][room] = func
|
||||
return func
|
||||
return wrapper
|
||||
|
|
Loading…
Reference in a new issue