summary refs log tree commit diff
path: root/synapse/push/httppusher.py
diff options
context:
space:
mode:
authorDavid Baker <dave@matrix.org>2015-01-28 11:55:49 +0000
committerDavid Baker <dave@matrix.org>2015-01-28 11:55:49 +0000
commit273b12729b99addf4474c9092f44ff300fd8153b (patch)
tree7a47bb891027e8f569618ae26708ac55aee4e396 /synapse/push/httppusher.py
parentOops, remove debugging (diff)
downloadsynapse-273b12729b99addf4474c9092f44ff300fd8153b.tar.xz
Reset badge count to zero when last active time is bumped
Diffstat (limited to 'synapse/push/httppusher.py')
-rw-r--r--synapse/push/httppusher.py38
1 files changed, 35 insertions, 3 deletions
diff --git a/synapse/push/httppusher.py b/synapse/push/httppusher.py
index 22532fcc6a..d592bc2fd2 100644
--- a/synapse/push/httppusher.py
+++ b/synapse/push/httppusher.py
@@ -71,11 +71,12 @@ class HttpPusher(Pusher):
                 # we may have to fetch this over federation and we
                 # can't trust it anyway: is it worth it?
                 #'from_display_name': 'Steve Stevington'
-                #'counts': { -- we don't mark messages as read yet so
+                'counts': { #-- we don't mark messages as read yet so
                 # we have no way of knowing
-                #    'unread': 1,
+                    # Just set the badge to 1 until we have read receipts
+                    'unread': 1,
                 #    'missed_calls': 2
-                # },
+                },
                 'devices': [
                     {
                         'app_id': self.app_id,
@@ -111,3 +112,34 @@ class HttpPusher(Pusher):
         if 'rejected' in resp:
             rejected = resp['rejected']
         defer.returnValue(rejected)
+
+    @defer.inlineCallbacks
+    def reset_badge_count(self):
+        d = {
+            'notification': {
+                'id': '',
+                'type': None,
+                'from': '',
+                'counts': {
+                    'unread': 0,
+                    'missed_calls': 0
+                },
+                'devices': [
+                    {
+                        'app_id': self.app_id,
+                        'pushkey': self.pushkey,
+                        'pushkey_ts': long(self.pushkey_ts / 1000),
+                        'data': self.data_minus_url,
+                    }
+                ]
+            }
+        }
+        try:
+            resp = yield self.httpCli.post_json_get_json(self.url, d)
+        except:
+            logger.exception("Failed to push %s ", self.url)
+            defer.returnValue(False)
+        rejected = []
+        if 'rejected' in resp:
+            rejected = resp['rejected']
+        defer.returnValue(rejected)
\ No newline at end of file