Filter notifications by host
authorThierry Florac <tflorac@ulthar.net>
Wed, 26 Jun 2019 18:55:47 +0200
changeset 56 39d7bddcd810
parent 55 15d11232b0dc
child 57 acaa49debeb6
Filter notifications by host
src/pyams_notify/views/notification.py
--- a/src/pyams_notify/views/notification.py	Wed Jun 26 18:55:20 2019 +0200
+++ b/src/pyams_notify/views/notification.py	Wed Jun 26 18:55:47 2019 +0200
@@ -12,28 +12,26 @@
 
 __docformat__ = 'restructuredtext'
 
-
-# import standard library
 import pickle
 from datetime import datetime
 
-# import interfaces
+from pyramid.view import view_config
+
+from pyams_cache.cache import get_cache_handler
 from pyams_cache.interfaces import ICacheHandler
-from pyams_notify.interfaces import CACHE_QUEUE_KEY, CACHE_CONFIGURATION_KEY
+from pyams_notify.interfaces import CACHE_CONFIGURATION_KEY, CACHE_QUEUE_KEY
 from pyams_skin.layer import IPyAMSLayer
 from pyams_utils.date import format_datetime
 from pyams_utils.timezone import tztime
 
-# import packages
-from pyams_cache.cache import get_cache_handler
-from pyramid.view import view_config
-
 
 def get_user_notifications(cache_server, request):
     """Get notifications for given request"""
 
     def filtered(notification, request):
         """Filter notification against current request"""
+        if request.host != notification.get('host'):
+            return False
         target = notification.pop('target', {})
         return request.principal.id in target.get('principals', ())