changeset 1256:4b27b9bf31b0

plugin XEP-0045: use HISTORY_LIMIT param to retrieve the MUC history
author souliane <souliane@mailoo.org>
date Wed, 22 Oct 2014 14:16:01 +0200
parents 38fb8823cee8
children 83ed877541e3
files src/plugins/plugin_xep_0045.py
diffstat 1 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0045.py	Wed Oct 22 11:42:15 2014 +0200
+++ b/src/plugins/plugin_xep_0045.py	Wed Oct 22 14:16:01 2014 +0200
@@ -342,7 +342,12 @@
             return _errDeferred()
         log.info(_("[%(profile)s] is joining room %(room)s with nick %(nick)s") % {'profile': profile, 'room': room_jid.userhost(), 'nick': nick})
 
-        history_options = options["history"] == "True" if "history" in options else None
+        if "history" in options:
+            history_limit = int(options["history"])
+        else:
+            history_limit = int(self.host.memory.getParamA(C.HISTORY_LIMIT, 'General', profile_key=profile))
+        # http://xmpp.org/extensions/xep-0045.html#enter-managehistory
+        history_options = muc.HistoryOptions(maxStanzas=history_limit)
         password = options["password"] if "password" in options else None
 
         return self.clients[profile].join(room_jid, nick, history_options, password).addCallbacks(self.__room_joined, self.__err_joining_room, callbackKeywords={'profile': profile}, errbackArgs=[room_jid, nick, history_options, password, profile])
@@ -690,9 +695,6 @@
             self.__changing_nicks.discard(presence.nick)
             self.userLeftRoom(room, user)
 
-    def receivedGroupChat(self, room, user, body):
-        log.debug('receivedGroupChat: room=%s user=%s body=%s' % (room, user, body))
-
     def userJoinedRoom(self, room, user):
         self.host.memory.updateEntityData(room.roomJID, "type", "chatroom", self.parent.profile)
         if user.nick in self.__changing_nicks:
@@ -726,7 +728,16 @@
     def userUpdatedStatus(self, room, user, show, status):
         self.host.bridge.presenceUpdate(room.roomJID.userhost() + '/' + user.nick, show or '', 0, {'default': status or ''}, self.parent.profile)
 
+    def receivedGroupChat(self, room, user, body):
+        log.debug('receivedGroupChat: room=%s user=%s body=%s' % (room.roomJID.full(), user, body))
+
+    def receivedHistory(self, room, user, message):
+        # http://xmpp.org/extensions/xep-0045.html#enter-history
+        #log.debug('receivedHistory: room=%s user=%s body=%s' % (room.roomJID.full(), user, message))
+        pass
+
     def receivedSubject(self, room, user, subject):
+        # http://xmpp.org/extensions/xep-0045.html#enter-subject
         log.debug(_("New subject for room (%(room_id)s): %(subject)s") % {'room_id': room.roomJID.full(), 'subject': subject})
         self.rec_subjects[room.roomJID.userhost()] = (room.roomJID.userhost(), subject)
         self.host.bridge.roomNewSubject(room.roomJID.userhost(), subject, self.parent.profile)