mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-12-02 23:47:34 -05:00
Reset badge count to zero when last active time is bumped
This commit is contained in:
parent
f7c4daa8f9
commit
273b12729b
4 changed files with 76 additions and 3 deletions
|
|
@ -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(".")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue