summary refs log tree commit diff
path: root/synapse/push/__init__.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/__init__.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/__init__.py')
-rw-r--r--synapse/push/__init__.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/synapse/push/__init__.py b/synapse/push/__init__.py
index b6d01a82a0..4862d0de27 100644
--- a/synapse/push/__init__.py
+++ b/synapse/push/__init__.py
@@ -54,6 +54,9 @@ class Pusher(object):
         self.failing_since = failing_since
         self.alive = True
 
+        # The last value of last_active_time that we saw
+        self.last_last_active_time = 0
+
     @defer.inlineCallbacks
     def _actions_for_event(self, ev):
         """
@@ -273,6 +276,22 @@ class Pusher(object):
         """
         pass
 
+    def reset_badge_count(self):
+        pass
+
+    def presence_changed(self, state):
+        """
+        We clear badge counts whenever a user's last_active time is bumped
+        This is by no means perfect but I think it's the best we can do
+        without read receipts.
+        """
+        if 'last_active' in state.state:
+            last_active = state.state['last_active']
+            if last_active > self.last_last_active_time:
+                logger.info("Resetting badge count for %s", self.user_name)
+                self.reset_badge_count()
+                self.last_last_active_time = last_active
+
 
 def _value_for_dotted_key(dotted_key, event):
     parts = dotted_key.split(".")