comparison libervia/pages/chat/page_meta.py @ 1203:251eba911d4d

server (websockets): fixed websocket handling on HTTPS connections: Original request used to retrieve a page was stored on dynamic pages, but after the end of it, the channel was deleted, resulting in a isSecure() always returning False, and troubles in chain leading to the the use of the wrong session object. This patch fixes this by reworking the way original request is used, and creating a new wrapping class allowing to keep an API similar to iweb.IRequest, with data coming from both the original request and the websocket request. fix 327
author Goffi <goffi@goffi.org>
date Sun, 14 Jul 2019 14:45:51 +0200
parents 29eb15062416
children b2d067339de3
comparison
equal deleted inserted replaced
1202:3f791fbc1643 1203:251eba911d4d
53 if "conference" in [i[0] for i in disco[1]]: 53 if "conference" in [i[0] for i in disco[1]]:
54 chat_type = C.CHAT_GROUP 54 chat_type = C.CHAT_GROUP
55 join_ret = yield self.host.bridgeCall( 55 join_ret = yield self.host.bridgeCall(
56 u"mucJoin", target_jid.userhost(), "", "", profile 56 u"mucJoin", target_jid.userhost(), "", "", profile
57 ) 57 )
58 already_joined, room_jid_s, occupants, user_nick, room_subject, dummy = join_ret 58 already_joined, room_jid_s, occupants, user_nick, room_subject, __ = join_ret
59 template_data[u"subject"] = room_subject 59 template_data[u"subject"] = room_subject
60 own_jid = jid.JID(room_jid_s) 60 own_jid = jid.JID(room_jid_s)
61 own_jid.resource = user_nick 61 own_jid.resource = user_nick
62 else: 62 else:
63 chat_type = C.CHAT_ONE2ONE 63 chat_type = C.CHAT_ONE2ONE
79 identities = {} 79 identities = {}
80 for author in authors: 80 for author in authors:
81 identities[author] = yield self.host.bridgeCall(u"identityGet", author, profile) 81 identities[author] = yield self.host.bridgeCall(u"identityGet", author, profile)
82 82
83 template_data[u"messages"] = data_objects.Messages(history) 83 template_data[u"messages"] = data_objects.Messages(history)
84 template_data[u"identities"] = identities 84 rdata[u'identities'] = template_data[u"identities"] = identities
85 template_data[u"target_jid"] = target_jid 85 template_data[u"target_jid"] = target_jid
86 template_data[u"chat_type"] = chat_type 86 template_data[u"chat_type"] = chat_type
87 87
88 88
89 def on_data(self, request, data): 89 def on_data(self, request, data):
114 114
115 @defer.inlineCallbacks 115 @defer.inlineCallbacks
116 def on_signal(self, request, signal, *args): 116 def on_signal(self, request, signal, *args):
117 if signal == "messageNew": 117 if signal == "messageNew":
118 rdata = self.getRData(request) 118 rdata = self.getRData(request)
119 template_data = request.template_data
120 template_data_update = {u"msg": data_objects.Message((args))} 119 template_data_update = {u"msg": data_objects.Message((args))}
121 target_jid = rdata["target"] 120 target_jid = rdata["target"]
122 identities = template_data["identities"] 121 identities = rdata["identities"]
123 uid, timestamp, from_jid_s, to_jid_s, message, subject, mess_type, extra, dummy = ( 122 uid, timestamp, from_jid_s, to_jid_s, message, subject, mess_type, extra, __ = (
124 args 123 args
125 ) 124 )
126 from_jid = jid.JID(from_jid_s) 125 from_jid = jid.JID(from_jid_s)
127 to_jid = jid.JID(to_jid_s) 126 to_jid = jid.JID(to_jid_s)
128 if ( 127 if (