Removed 'target' attribute from received notifications
authorThierry Florac <thierry.florac@onf.fr>
Wed, 12 Jul 2017 12:14:20 +0200
changeset 8 a285b7e8217c
parent 7 d3490a8d7272
child 9 27631588832b
Removed 'target' attribute from received notifications
src/pyams_notify_ws/notify.py
--- a/src/pyams_notify_ws/notify.py	Thu Jun 01 16:45:38 2017 +0200
+++ b/src/pyams_notify_ws/notify.py	Wed Jul 12 12:14:20 2017 +0200
@@ -61,8 +61,10 @@
             action = message.get('action')
             if action == 'notify':
                 # dispatch notification to subscribers
-                json_message = json.dumps(message)
-                target = message.get('target').get('principals', ())
+                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():
                     if subscription.filter_target(target):
                         yield from connection.send(json_message)