diff options
author | lukasdenk <63459921+lukasdenk@users.noreply.github.com> | 2022-02-17 11:23:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-17 10:23:54 +0000 |
commit | 40771773909cb03d9296e3f0505e4e32372f10aa (patch) | |
tree | c493f554e17205af0633a1747f43d35e99de264d /synapse/push/httppusher.py | |
parent | Explain the meaning of spam checker callbacks' return values (#12003) (diff) | |
download | synapse-40771773909cb03d9296e3f0505e4e32372f10aa.tar.xz |
Prevent duplicate push notifications for room reads (#11835)
Diffstat (limited to '')
-rw-r--r-- | synapse/push/httppusher.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/synapse/push/httppusher.py b/synapse/push/httppusher.py index 96559081d0..49bcc06e0b 100644 --- a/synapse/push/httppusher.py +++ b/synapse/push/httppusher.py @@ -109,6 +109,7 @@ class HttpPusher(Pusher): self.data_minus_url = {} self.data_minus_url.update(self.data) del self.data_minus_url["url"] + self.badge_count_last_call: Optional[int] = None def on_started(self, should_check_for_notifs: bool) -> None: """Called when this pusher has been started. @@ -136,7 +137,9 @@ class HttpPusher(Pusher): self.user_id, group_by_room=self._group_unread_count_by_room, ) - await self._send_badge(badge) + if self.badge_count_last_call is None or self.badge_count_last_call != badge: + self.badge_count_last_call = badge + await self._send_badge(badge) def on_timer(self) -> None: self._start_processing() @@ -402,6 +405,8 @@ class HttpPusher(Pusher): rejected = [] if "rejected" in resp: rejected = resp["rejected"] + else: + self.badge_count_last_call = badge return rejected async def _send_badge(self, badge: int) -> None: |