diff frontends/src/quick_frontend/quick_chat.py @ 2020:f67da1cab6d3

quick frontend, primitivus (chat, contact_list): fixed MUC private messages handling: - occupants can be clicked again - QuickChat.Occupant now keep room jid and real jid if available - history messages are filtered correctly when requesting history for MUC room or private conversation
author Goffi <goffi@goffi.org>
date Sun, 24 Jul 2016 18:07:45 +0200
parents c0ff84243650
children 88c41a195728
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_chat.py	Sun Jul 24 18:02:34 2016 +0200
+++ b/frontends/src/quick_frontend/quick_chat.py	Sun Jul 24 18:07:45 2016 +0200
@@ -120,15 +120,23 @@
         self.parent = parent
         self.profile = profile
         self.nick = data['nick']
-        self.entity = data.get('entity')
-        if not self.entity:
-            self.entity = jid.JID(u"{}/{}".format(parent.target.bare, self.nick)),
+        self._entity = data.get('entity')
         self.affiliation = data['affiliation']
         self.role = data['role']
         self.widgets = set()  # widgets linked to this occupant
         self._state = None
 
     @property
+    def jid(self):
+        """jid in the room"""
+        return jid.JID(u"{}/{}".format(self.parent.target.bare, self.nick))
+
+    @property
+    def real_jid(self):
+        """real jid if known else None"""
+        return self._entity
+
+    @property
     def host(self):
         return self.parent.host
 
@@ -321,7 +329,22 @@
             log_msg += _(u" ({} messages)".format(size))
         log.debug(log_msg)
 
-        target = self.target.bare
+        if self.type == C.CHAT_ONE2ONE:
+            special = self.host.contact_lists[self.profile].getCache(self.target, C.CONTACT_SPECIAL)
+            if special == C.CONTACT_SPECIAL_GROUP:
+                # we have a private conversation
+                # so we need full jid for the history
+                # (else we would get history from group itself)
+                # and to filter out groupchat message
+                target = self.target
+                filters['not_types'] = C.MESS_TYPE_GROUPCHAT
+            else:
+                target = self.target.bare
+        else:
+            # groupchat
+            target = self.target.bare
+            # FIXME: info not handled correctly
+            filters['types'] = C.MESS_TYPE_GROUPCHAT
 
         def _historyGetCb(history):
             # day_format = "%A, %d %b %Y"  # to display the day change