# HG changeset patch # User Thierry Florac # Date 1561568338 -7200 # Node ID bdb57ba752453f4ae19167cee1502845bf02847e # Parent 4f59f94ad901e718732b942dcb5ccbf6bdec102e Use message and subscriptions host to filter notifications diff -r 4f59f94ad901 -r bdb57ba75245 src/pyams_notify_ws/notify.py --- a/src/pyams_notify_ws/notify.py Wed Jun 26 18:58:19 2019 +0200 +++ b/src/pyams_notify_ws/notify.py Wed Jun 26 18:58:58 2019 +0200 @@ -55,6 +55,7 @@ action = message.get('action') if action == 'notify': # dispatch notification to subscribers + host = message.get('host') source = message.get('source', {}).get('id') target = message.get('target', {}).get('principals', ()) clean_message = message.copy() @@ -62,6 +63,9 @@ json_message = json.dumps(clean_message) async with users_lock: for connection, subscription in users.items(): + # don't send notification to other hosts + if host and (host != subscription.host): + continue # don't send notification to emitter if source and (source == subscription.principal['id']): continue