summary refs log tree commit diff
path: root/synapse/push
diff options
context:
space:
mode:
authorDavid Baker <dave@matrix.org>2015-01-20 11:49:48 +0000
committerDavid Baker <dave@matrix.org>2015-01-20 11:49:48 +0000
commitafb714f7bebf88ac27eac018cffa2078e2723310 (patch)
treec65a60cc08b0c5335a25b946f49255cbe4468202 /synapse/push
parentRequire device language when adding a pusher. (diff)
downloadsynapse-afb714f7bebf88ac27eac018cffa2078e2723310.tar.xz
add instance_handles to pushers so we have a way to refer to them even if the push token changes.
Diffstat (limited to 'synapse/push')
-rw-r--r--synapse/push/__init__.py3
-rw-r--r--synapse/push/httppusher.py3
-rw-r--r--synapse/push/pusherpool.py9
3 files changed, 10 insertions, 5 deletions
diff --git a/synapse/push/__init__.py b/synapse/push/__init__.py
index 5f4e833add..3ee652f3bc 100644
--- a/synapse/push/__init__.py
+++ b/synapse/push/__init__.py
@@ -30,13 +30,14 @@ class Pusher(object):
     MAX_BACKOFF = 60 * 60 * 1000
     GIVE_UP_AFTER = 24 * 60 * 60 * 1000
 
-    def __init__(self, _hs, user_name, app_id,
+    def __init__(self, _hs, instance_handle, user_name, app_id,
                  app_display_name, device_display_name, pushkey, pushkey_ts,
                  data, last_token, last_success, failing_since):
         self.hs = _hs
         self.evStreamHandler = self.hs.get_handlers().event_stream_handler
         self.store = self.hs.get_datastore()
         self.clock = self.hs.get_clock()
+        self.instance_handle = instance_handle,
         self.user_name = user_name
         self.app_id = app_id
         self.app_display_name = app_display_name
diff --git a/synapse/push/httppusher.py b/synapse/push/httppusher.py
index 7631a741fa..9a3e0be15e 100644
--- a/synapse/push/httppusher.py
+++ b/synapse/push/httppusher.py
@@ -24,11 +24,12 @@ logger = logging.getLogger(__name__)
 
 
 class HttpPusher(Pusher):
-    def __init__(self, _hs, user_name, app_id,
+    def __init__(self, _hs, instance_handle, user_name, app_id,
                  app_display_name, device_display_name, pushkey, pushkey_ts,
                  data, last_token, last_success, failing_since):
         super(HttpPusher, self).__init__(
             _hs,
+            instance_handle,
             user_name,
             app_id,
             app_display_name,
diff --git a/synapse/push/pusherpool.py b/synapse/push/pusherpool.py
index 8c77f4b668..2dfecf178b 100644
--- a/synapse/push/pusherpool.py
+++ b/synapse/push/pusherpool.py
@@ -40,7 +40,7 @@ class PusherPool:
         self._start_pushers(pushers)
 
     @defer.inlineCallbacks
-    def add_pusher(self, user_name, kind, app_id,
+    def add_pusher(self, user_name, instance_handle, kind, app_id,
                    app_display_name, device_display_name, pushkey, lang, data):
         # we try to create the pusher just to validate the config: it
         # will then get pulled out of the database,
@@ -49,6 +49,7 @@ class PusherPool:
         self._create_pusher({
             "user_name": user_name,
             "kind": kind,
+            "instance_handle": instance_handle,
             "app_id": app_id,
             "app_display_name": app_display_name,
             "device_display_name": device_display_name,
@@ -61,17 +62,18 @@ class PusherPool:
             "failing_since": None
         })
         yield self._add_pusher_to_store(
-            user_name, kind, app_id,
+            user_name, instance_handle, kind, app_id,
             app_display_name, device_display_name,
             pushkey, lang, data
         )
 
     @defer.inlineCallbacks
-    def _add_pusher_to_store(self, user_name, kind, app_id,
+    def _add_pusher_to_store(self, user_name, instance_handle, kind, app_id,
                              app_display_name, device_display_name,
                              pushkey, lang, data):
         yield self.store.add_pusher(
             user_name=user_name,
+            instance_handle=instance_handle,
             kind=kind,
             app_id=app_id,
             app_display_name=app_display_name,
@@ -87,6 +89,7 @@ class PusherPool:
         if pusherdict['kind'] == 'http':
             return HttpPusher(
                 self.hs,
+                instance_handle=pusherdict['instance_handle'],
                 user_name=pusherdict['user_name'],
                 app_id=pusherdict['app_id'],
                 app_display_name=pusherdict['app_display_name'],