diff options
author | Kegan Dougal <kegan@matrix.org> | 2015-02-03 11:26:33 +0000 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2015-02-03 11:26:33 +0000 |
commit | 197f3ea4bad066da251c7925336baab8bee296c9 (patch) | |
tree | a9851547fd6603298a66fd7d2c3abec1b6d7b59c /synapse/handlers | |
parent | Add defers in the right places. (diff) | |
download | synapse-197f3ea4bad066da251c7925336baab8bee296c9.tar.xz |
Implement regex checks for app services.
Expose handler.get_services_for_event which manages the checks for all services.
Diffstat (limited to 'synapse/handlers')
-rw-r--r-- | synapse/handlers/appservice.py | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/synapse/handlers/appservice.py b/synapse/handlers/appservice.py index da994ba8e0..9b8dd1bb49 100644 --- a/synapse/handlers/appservice.py +++ b/synapse/handlers/appservice.py @@ -34,9 +34,11 @@ class ApplicationServicesHandler(BaseHandler): logger.info("Register -> %s", app_service) # check the token is recognised try: - stored_service = yield self.store.get_app_service(app_service.token) + stored_service = yield self.store.get_app_service_by_token( + app_service.token + ) if not stored_service: - raise StoreError(404, "Application Service Not found") + raise StoreError(404, "Application service not found") except StoreError: raise SynapseError( 403, "Unrecognised application services token. " @@ -50,6 +52,25 @@ class ApplicationServicesHandler(BaseHandler): logger.info("Unregister as_token=%s", token) yield self.store.unregister_app_service(token) + def get_services_for_event(self, event): + """Retrieve a list of application services interested in this event. + + Args: + event(Event): The event to check. + Returns: + list<ApplicationService>: A list of services interested in this + event based on the service regex. + """ + # We need to know the aliases associated with this event.room_id, if any + alias_list = [] # TODO + + interested_list = [ + s for s in self.store.get_app_services() if ( + s.is_interested(event, alias_list) + ) + ] + return interested_list + def notify_interested_services(self, event): """Notifies (pushes) all application services interested in this event. |