summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorDavid Baker <dbkr@users.noreply.github.com>2016-04-12 14:40:37 +0100
committerDavid Baker <dbkr@users.noreply.github.com>2016-04-12 14:40:37 +0100
commitd33d623f0d17189e23980d2bd93691c68c0ae22e (patch)
tree4623cb12949d697cac8554e48bca3118a49ad7b0 /synapse/storage
parentMerge pull request #717 from matrix-org/erikj/backfill_state (diff)
parentUnneccessarywhitespaceisunnecessary (diff)
downloadsynapse-d33d623f0d17189e23980d2bd93691c68c0ae22e.tar.xz
Merge pull request #716 from matrix-org/dbkr/get_pushers
Add get endpoint for pushers
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/pusher.py44
1 files changed, 30 insertions, 14 deletions
diff --git a/synapse/storage/pusher.py b/synapse/storage/pusher.py
index 19888a8e76..e64c0dce0a 100644
--- a/synapse/storage/pusher.py
+++ b/synapse/storage/pusher.py
@@ -56,24 +56,40 @@ class PusherStore(SQLBaseStore):
         )
         defer.returnValue(ret is not None)
 
-    @defer.inlineCallbacks
     def get_pushers_by_app_id_and_pushkey(self, app_id, pushkey):
-        def r(txn):
-            sql = (
-                "SELECT * FROM pushers"
-                " WHERE app_id = ? AND pushkey = ?"
-            )
+        return self.get_pushers_by({
+            "app_id": app_id,
+            "pushkey": pushkey,
+        })
 
-            txn.execute(sql, (app_id, pushkey,))
-            rows = self.cursor_to_dict(txn)
+    def get_pushers_by_user_id(self, user_id):
+        return self.get_pushers_by({
+            "user_name": user_id,
+        })
 
-            return self._decode_pushers_rows(rows)
-
-        rows = yield self.runInteraction(
-            "get_pushers_by_app_id_and_pushkey", r
+    @defer.inlineCallbacks
+    def get_pushers_by(self, keyvalues):
+        ret = yield self._simple_select_list(
+            "pushers", keyvalues,
+            [
+                "id",
+                "user_name",
+                "access_token",
+                "profile_tag",
+                "kind",
+                "app_id",
+                "app_display_name",
+                "device_display_name",
+                "pushkey",
+                "ts",
+                "lang",
+                "data",
+                "last_stream_ordering",
+                "last_success",
+                "failing_since",
+            ], desc="get_pushers_by"
         )
-
-        defer.returnValue(rows)
+        defer.returnValue(self._decode_pushers_rows(ret))
 
     @defer.inlineCallbacks
     def get_all_pushers(self):