changeset 1002:990e80aa43a9

pages (chat): fixed messages filtering + get identity of user if not already in cache.
author Goffi <goffi@goffi.org>
date Fri, 05 Jan 2018 16:30:05 +0100
parents ae7e9ce4c64c
children 05cc33d8e328
files src/pages/chat/page_meta.py
diffstat 1 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/pages/chat/page_meta.py	Fri Jan 05 16:30:05 2018 +0100
+++ b/src/pages/chat/page_meta.py	Fri Jan 05 16:30:05 2018 +0100
@@ -95,13 +95,23 @@
 @defer.inlineCallbacks
 def on_signal(self, request, signal, *args):
     if signal == 'messageNew':
-        profile = self.getProfile(request)
+        rdata = self.getRData(request)
         template_data = request.template_data
         template_data_update = {u"msg": data_objects.Message((args))}
+        target_jid = rdata['target']
         identities = template_data['identities']
-        uid, timestamp, from_jid, to_jid, message, subject, mess_type, extra, dummy = args
-        if from_jid not in identities:
-            identities[from_jid] = yield self.host.bridgeCall(u'identityGet', from_jid, profile)
+        uid, timestamp, from_jid_s, to_jid_s, message, subject, mess_type, extra, dummy = args
+        from_jid = jid.JID(from_jid_s)
+        to_jid = jid.JID(to_jid_s)
+        if (target_jid.userhostJID() != from_jid.userhostJID() and
+            target_jid.userhostJID() != to_jid.userhostJID()):
+            # the message is not linked with page's room/user
+            return
+
+
+        if from_jid_s not in identities:
+            profile = self.getProfile(request)
+            identities[from_jid_s] = yield self.host.bridgeCall(u'identityGet', from_jid_s, profile)
             template_data_update['identities'] = identities
         self.renderAndUpdate(request, u"chat/message.html", "#messages",
                              template_data_update)