Store original host in websocket subscription
authorThierry Florac <tflorac@ulthar.net>
Wed, 26 Jun 2019 18:58:19 +0200
changeset 24 4f59f94ad901
parent 23 5d4441d834c7
child 25 bdb57ba75245
Store original host in websocket subscription
src/pyams_notify_ws/subscribe.py
--- a/src/pyams_notify_ws/subscribe.py	Wed Jun 26 11:13:45 2019 +0200
+++ b/src/pyams_notify_ws/subscribe.py	Wed Jun 26 18:58:19 2019 +0200
@@ -35,8 +35,9 @@
     subscription) for which we subscribe for a list of events types
     """
 
-    def __init__(self, principal):
+    def __init__(self, principal, host):
         self.principal = principal
+        self.host = host
         self.contexts = {}
 
     def update_contexts(self, new_contexts):
@@ -81,7 +82,7 @@
                 async with users_lock:
                     subscription = users.get(self.ws)
                     if subscription is None:
-                        subscription = WebsocketSubscription(principal)
+                        subscription = WebsocketSubscription(principal, message.get('host'))
                     subscription.update_contexts(message.get('context'))
                     users[self.ws] = subscription