comparison src/pages/chat/page_meta.py @ 1000:4cc4d49e1d0f

pages (chat): moved rendering preparation in prepare_render, and redirect to page_select if no jid is specified.
author Goffi <goffi@goffi.org>
date Fri, 05 Jan 2018 16:30:05 +0100
parents d821c112e656
children ae7e9ce4c64c
comparison
equal deleted inserted replaced
999:ded41172dcb5 1000:4cc4d49e1d0f
14 access = C.PAGES_ACCESS_PROFILE 14 access = C.PAGES_ACCESS_PROFILE
15 template = u"chat/chat.html" 15 template = u"chat/chat.html"
16 dynamic = True 16 dynamic = True
17 17
18 18
19 @defer.inlineCallbacks
20 def parse_url(self, request): 19 def parse_url(self, request):
21 session = self.host.getSessionData(request, session_iface.ISATSession)
22 rdata = self.getRData(request) 20 rdata = self.getRData(request)
23 template_data = request.template_data
24 profile = session.profile
25 21
26 try: 22 try:
27 target_jid_s = self.nextPath(request) 23 target_jid_s = self.nextPath(request)
28 except IndexError: 24 except IndexError:
29 log.warning(_(u"missing chat jid")) 25 # not chat jid, we redirect to jid selection page
30 self.pageError(request, C.HTTP_BAD_REQUEST) 26 self.pageRedirect(u"chat_select", request)
31 27
32 try: 28 try:
33 target_jid = jid.JID(target_jid_s) 29 target_jid = jid.JID(target_jid_s)
34 if not target_jid.user: 30 if not target_jid.user:
35 raise ValueError(_(u"invalid jid for chat (no local part)")) 31 raise ValueError(_(u"invalid jid for chat (no local part)"))
39 msg = e)) 35 msg = e))
40 self.pageError(request, C.HTTP_BAD_REQUEST) 36 self.pageError(request, C.HTTP_BAD_REQUEST)
41 else: 37 else:
42 rdata['target'] = target_jid 38 rdata['target'] = target_jid
43 39
40
41 @defer.inlineCallbacks
42 def prepare_render(self, request):
43 # FIXME: bug on room filtering (currently display messages from all rooms)
44 session = self.host.getSessionData(request, session_iface.ISATSession)
45 template_data = request.template_data
46 rdata = self.getRData(request)
47 target_jid = rdata['target']
48 profile = session.profile
44 profile_jid = session.jid 49 profile_jid = session.jid
45 if profile_jid is None: 50 if profile_jid is None:
46 jid_s = yield self.host.bridgeCall(u'getParamA', "JabberID", "Connection", profile_key=profile) 51 jid_s = yield self.host.bridgeCall(u'getParamA', "JabberID", "Connection", profile_key=profile)
47 profile_jid = session.jid = jid.JID(jid_s) 52 profile_jid = session.jid = jid.JID(jid_s)
48 53