mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-16 10:53:51 +01:00
Split out function to decide whether to notify or a given event
This commit is contained in:
parent
fead431c18
commit
70d0a453f3
1 changed files with 17 additions and 2 deletions
|
@ -49,6 +49,17 @@ class Pusher(object):
|
||||||
self.failing_since = failing_since
|
self.failing_since = failing_since
|
||||||
self.alive = True
|
self.alive = True
|
||||||
|
|
||||||
|
def _should_notify_for_event(self, ev):
|
||||||
|
"""
|
||||||
|
This should take into account notification settings that the user
|
||||||
|
has configured both globally and per-room when we have the ability
|
||||||
|
to do such things.
|
||||||
|
"""
|
||||||
|
if ev['user_id'] == self.user_name:
|
||||||
|
# let's assume you probably know about messages you sent yourself
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def start(self):
|
def start(self):
|
||||||
if not self.last_token:
|
if not self.last_token:
|
||||||
|
@ -85,8 +96,12 @@ class Pusher(object):
|
||||||
if not self.alive:
|
if not self.alive:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
ret = yield self.dispatch_push(single_event)
|
processed = False
|
||||||
if ret:
|
if self._should_notify_for_event(single_event):
|
||||||
|
processed = yield self.dispatch_push(single_event)
|
||||||
|
else:
|
||||||
|
processed = True
|
||||||
|
if processed:
|
||||||
self.backoff_delay = Pusher.INITIAL_BACKOFF
|
self.backoff_delay = Pusher.INITIAL_BACKOFF
|
||||||
self.last_token = chunk['end']
|
self.last_token = chunk['end']
|
||||||
self.store.update_pusher_last_token_and_success(
|
self.store.update_pusher_last_token_and_success(
|
||||||
|
|
Loading…
Reference in a new issue