summary refs log tree commit diff
path: root/synapse/storage/appservice.py
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2015-03-31 12:07:56 +0100
committerKegan Dougal <kegan@matrix.org>2015-03-31 12:07:56 +0100
commitc217504949a90712f41a0422215f923b4d114a17 (patch)
tree18faee338e1df4139394066673ebb9d8fd547a82 /synapse/storage/appservice.py
parentFix tests and missing returns on deferreds. (diff)
downloadsynapse-c217504949a90712f41a0422215f923b4d114a17.tar.xz
Edit SQL schema to use string IDs not ints. Use token as ID. Update tests.
Diffstat (limited to 'synapse/storage/appservice.py')
-rw-r--r--synapse/storage/appservice.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/synapse/storage/appservice.py b/synapse/storage/appservice.py
index a520a859d3..a8780eca1e 100644
--- a/synapse/storage/appservice.py
+++ b/synapse/storage/appservice.py
@@ -231,7 +231,8 @@ class ApplicationServiceStore(SQLBaseStore):
             url=as_info["url"],
             namespaces=as_info["namespaces"],
             hs_token=as_info["hs_token"],
-            sender=as_info["sender"]
+            sender=as_info["sender"],
+            id=as_info["as_token"]  # the token is the only unique thing here
         )
 
     def _populate_appservice_cache(self, config_files):
@@ -268,16 +269,20 @@ class ApplicationServiceTransactionStore(SQLBaseStore):
             A Deferred which resolves to a list of ApplicationServices, which
             may be empty.
         """
-        sql = (
-            "SELECT r.*, a.* FROM application_services_state AS s LEFT JOIN"
-            " application_services AS a ON a.id=s.as_id LEFT JOIN"
-            " application_services_regex AS r ON r.as_id=a.id WHERE state = ?"
-        )
-        results = yield self._execute_and_decode(
-            "get_appservices_by_state", sql, state
+        results = yield self._simple_select_list(
+            "application_services_state",
+            dict(state=state),
+            ["as_id"]
         )
         # NB: This assumes this class is linked with ApplicationServiceStore
-        defer.returnValue(self._parse_services_dict(results))
+        as_list = yield self.get_app_services()
+        services = []
+
+        for res in results:
+            for service in as_list:
+                if service.id == res["as_id"]:
+                    services.append(service)
+        defer.returnValue(services)
 
     @defer.inlineCallbacks
     def get_appservice_state(self, service):