summary refs log tree commit diff
path: root/synapse/push/httppusher.py
diff options
context:
space:
mode:
authorDavid Baker <dbkr@matrix.org>2014-12-03 13:37:02 +0000
committerDavid Baker <dbkr@matrix.org>2014-12-03 13:37:02 +0000
commit88af58d41d561f1d9f6bbbfb2a1e8bd00dbbe638 (patch)
tree71510c1925db68589d2509b01acbcb4fb172cb0c /synapse/push/httppusher.py
parentconvert to spaces before I start a holy war (diff)
downloadsynapse-88af58d41d561f1d9f6bbbfb2a1e8bd00dbbe638.tar.xz
Update to app_id / app_instance_id (partially) and mangle to be PEP8 compliant.
Diffstat (limited to 'synapse/push/httppusher.py')
-rw-r--r--synapse/push/httppusher.py75
1 files changed, 42 insertions, 33 deletions
diff --git a/synapse/push/httppusher.py b/synapse/push/httppusher.py
index 33d735b974..fd7fe4e39c 100644
--- a/synapse/push/httppusher.py
+++ b/synapse/push/httppusher.py
@@ -22,21 +22,28 @@ import logging
 
 logger = logging.getLogger(__name__)
 
+
 class HttpPusher(Pusher):
-    def __init__(self, _hs, user_name, app, app_display_name, device_display_name, pushkey, data,
+    def __init__(self, _hs, user_name, app_id, app_instance_id,
+                 app_display_name, device_display_name, pushkey, data,
                  last_token, last_success, failing_since):
-        super(HttpPusher, self).__init__(_hs,
-                                         user_name,
-                                         app,
-                                         app_display_name,
-                                         device_display_name,
-                                         pushkey,
-                                         data,
-                                         last_token,
-                                         last_success,
-                                         failing_since)
+        super(HttpPusher, self).__init__(
+            _hs,
+            user_name,
+            app_id,
+            app_instance_id,
+            app_display_name,
+            device_display_name,
+            pushkey,
+            data,
+            last_token,
+            last_success,
+            failing_since
+        )
         if 'url' not in data:
-            raise PusherConfigException("'url' required in data for HTTP pusher")
+            raise PusherConfigException(
+                "'url' required in data for HTTP pusher"
+            )
         self.url = data['url']
         self.httpCli = SimpleHttpClient(self.hs)
         self.data_minus_url = {}
@@ -53,34 +60,36 @@ class HttpPusher(Pusher):
             return None
 
         return {
-           'notification': {
-               'transition' : 'new', # everything is new for now: we don't have read receipts
-               'id': event['event_id'],
-               'type': event['type'],
-               'from': event['user_id'],
-               # we may have to fetch this over federation and we can't trust it anyway: is it worth it?
-               #'fromDisplayName': 'Steve Stevington'
-           },
-           #'counts': { -- we don't mark messages as read yet so we have no way of knowing
-           #    'unread': 1,
-           #    'missedCalls': 2
-           # },
-           'devices': {
-               self.pushkey: {
-                   'data' : self.data_minus_url
+            'notification': {
+                'transition': 'new',
+                # everything is new for now: we don't have read receipts
+                'id': event['event_id'],
+                'type': event['type'],
+                'from': event['user_id'],
+                # we may have to fetch this over federation and we
+                # can't trust it anyway: is it worth it?
+                #'fromDisplayName': 'Steve Stevington'
+            },
+            #'counts': { -- we don't mark messages as read yet so
+            # we have no way of knowing
+            #    'unread': 1,
+            #    'missedCalls': 2
+            # },
+            'devices': {
+                self.pushkey: {
+                    'data': self.data_minus_url
                 }
-           }
+            }
         }
 
     @defer.inlineCallbacks
-    def dispatchPush(self, event):
-        notificationDict = self._build_notification_dict(event)
-        if not notificationDict:
+    def dispatch_push(self, event):
+        notification_dict = self._build_notification_dict(event)
+        if not notification_dict:
             defer.returnValue(True)
         try:
-            yield self.httpCli.post_json_get_json(self.url, notificationDict)
+            yield self.httpCli.post_json_get_json(self.url, notification_dict)
         except:
             logger.exception("Failed to push %s ", self.url)
             defer.returnValue(False)
         defer.returnValue(True)
-