Don't send notification to event transmitter
authorThierry Florac <thierry.florac@onf.fr>
Fri, 10 Nov 2017 13:29:53 +0100
changeset 12 167cc4ab3313
parent 11 c4fef7638a60
child 13 173d6e8e62e2
Don't send notification to event transmitter
src/pyams_notify_ws/notify.py
--- a/src/pyams_notify_ws/notify.py	Fri Oct 13 10:20:29 2017 +0200
+++ b/src/pyams_notify_ws/notify.py	Fri Nov 10 13:29:53 2017 +0100
@@ -61,11 +61,15 @@
             action = message.get('action')
             if action == 'notify':
                 # dispatch notification to subscribers
+                source = message.get('source', {}).get('id')
                 target = message.get('target', {}).get('principals', ())
                 clean_message = message.copy()
                 clean_message.pop('target')
                 json_message = json.dumps(clean_message)
                 for connection, subscription in users.items():
+                    # don't send notification to emitter
+                    if source and (source == subscription.principal['id']):
+                        continue
                     if subscription.filter_target(target):
                         yield from connection.send(json_message)
                 # store message in memcached_queue