Fix the history numbers when re-joining a room

the <history/> element had a xmlns="" instead of the proper namespace.
This commit is contained in:
mathieui 2012-11-17 19:17:02 +01:00
parent 6781f67e80
commit ac806cbb41
4 changed files with 15 additions and 4 deletions

View file

@ -1682,7 +1682,8 @@ class Core(object):
if histo_length is not None:
histo_length= str(histo_length)
if tab and not tab.joined:
seconds = (int(time.time()) - tab.last_connection) if tab.last_connection != 0 else 0
seconds = (datetime.now() - tab.last_connection).total_seconds() if tab.last_connection is not None else 0
seconds = int(seconds)
muc.join_groupchat(self.xmpp, room, nick, password,
histo_length, current_status.message, current_status.show, seconds=seconds)
if not tab:

View file

@ -73,7 +73,7 @@ def join_groupchat(xmpp, jid, nick, passwd='', maxhistory=None, status=None, sho
passelement = ET.Element('password')
passelement.text = passwd
x.append(passelement)
history = ET.Element('history')
history = ET.Element('{http://jabber.org/protocol/muc}history')
history.attrib['seconds'] = str(seconds)
x.append(history)
stanza.append(x)

View file

@ -654,7 +654,6 @@ class MucTab(ChatTab):
self.info_header = windows.MucInfoWin()
self.input = windows.MessageInput()
self.ignores = [] # set of Users
self.last_connection = 0
# keys
self.key_func['^I'] = self.completion
self.key_func['M-u'] = self.scroll_user_list_down
@ -691,6 +690,13 @@ class MucTab(ChatTab):
def general_jid(self):
return self.get_name()
@property
def last_connection(self):
last_message = self._text_buffer.last_message
if last_message:
return last_message.time
return None
@refresh_wrapper.always
def go_to_next_hl(self):
"""
@ -1538,7 +1544,6 @@ class MucTab(ChatTab):
Set the state of the room as not joined, so
we can know if we can join it, send messages to it, etc
"""
self.last_connection = int(time.time())
self.users = []
if self is not self.core.current_tab():
self.state = 'disconnected'

View file

@ -35,6 +35,11 @@ class TextBuffer(object):
def add_window(self, win):
self.windows.append(win)
@property
def last_message(self):
return self.messages[-1] if self.messages else None
def make_message(self, txt, time, nickname, nick_color, history, user, identifier, str_time=None):
time = time or datetime.now()
if txt.startswith('/me '):