src/pyams_notify_ws/notify.py
changeset 12 167cc4ab3313
parent 8 a285b7e8217c
child 15 6472be90626a
--- 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