diff options
author | David Baker <dave@matrix.org> | 2015-01-13 13:14:41 +0000 |
---|---|---|
committer | David Baker <dave@matrix.org> | 2015-01-13 13:14:41 +0000 |
commit | 70d0a453f353bf350e02d5306a98126f6b318c88 (patch) | |
tree | 59a0a2e290fc60cb3aae91b71024706277b905d5 /synapse | |
parent | If we didn't get any events, advance the token or we'll just keep not getting... (diff) | |
download | synapse-70d0a453f353bf350e02d5306a98126f6b318c88.tar.xz |
Split out function to decide whether to notify or a given event
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/push/__init__.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/synapse/push/__init__.py b/synapse/push/__init__.py index c5586be7b9..f4795d559c 100644 --- a/synapse/push/__init__.py +++ b/synapse/push/__init__.py @@ -49,6 +49,17 @@ class Pusher(object): self.failing_since = failing_since 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 def start(self): if not self.last_token: @@ -85,8 +96,12 @@ class Pusher(object): if not self.alive: continue - ret = yield self.dispatch_push(single_event) - if ret: + processed = False + 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.last_token = chunk['end'] self.store.update_pusher_last_token_and_success( |