changeset 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 ded41172dcb5
children ae7e9ce4c64c
files src/pages/chat/page_meta.py
diffstat 1 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/pages/chat/page_meta.py	Fri Jan 05 16:30:03 2018 +0100
+++ b/src/pages/chat/page_meta.py	Fri Jan 05 16:30:05 2018 +0100
@@ -16,18 +16,14 @@
 dynamic = True
 
 
-@defer.inlineCallbacks
 def parse_url(self, request):
-    session = self.host.getSessionData(request, session_iface.ISATSession)
     rdata = self.getRData(request)
-    template_data = request.template_data
-    profile = session.profile
 
     try:
         target_jid_s = self.nextPath(request)
     except IndexError:
-        log.warning(_(u"missing chat jid"))
-        self.pageError(request, C.HTTP_BAD_REQUEST)
+        # not chat jid, we redirect to jid selection page
+        self.pageRedirect(u"chat_select", request)
 
     try:
         target_jid = jid.JID(target_jid_s)
@@ -41,6 +37,15 @@
     else:
         rdata['target'] = target_jid
 
+
+@defer.inlineCallbacks
+def prepare_render(self, request):
+    # FIXME: bug on room filtering (currently display messages from all rooms)
+    session = self.host.getSessionData(request, session_iface.ISATSession)
+    template_data = request.template_data
+    rdata = self.getRData(request)
+    target_jid = rdata['target']
+    profile = session.profile
     profile_jid = session.jid
     if profile_jid is None:
         jid_s = yield self.host.bridgeCall(u'getParamA', "JabberID", "Connection", profile_key=profile)