do not duplicate messages in the room when the connection is lost

This commit is contained in:
Denis Fomin 2012-02-18 22:48:03 +04:00
parent aa369ccce3
commit 09942f48e0
2 changed files with 8 additions and 3 deletions

View File

@ -2304,7 +2304,8 @@ class Connection(CommonConnection, ConnectionHandlers):
room_id=resp.getTag('unique').getData()))
self.connection.SendAndCallForResponse(iq, _on_response)
def join_gc(self, nick, room_jid, password, change_nick=False):
def join_gc(self, nick, room_jid, password, change_nick=False,
rejoin=False):
# FIXME: This room JID needs to be normalized; see #1364
if not gajim.account_is_connected(self.name):
return
@ -2353,6 +2354,10 @@ class Connection(CommonConnection, ConnectionHandlers):
last_date = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(
last_date))
tags['since'] = last_date
if rejoin:
tags['since'] = time.strftime('%Y-%m-%dT%H:%M:%SZ',
time.gmtime(gajim.logger.get_last_date_that_has_logs(
room_jid, is_room=True) + 1))
nb = gajim.config.get('muc_restore_lines')
if nb >= 0:
tags['maxstanzas'] = nb

View File

@ -1274,7 +1274,7 @@ class GroupchatControl(ChatControlBase):
gajim.gc_connected[obj.conn.name][self.room_jid]:
return
password = gajim.gc_passwords.get(self.room_jid, '')
obj.conn.join_gc(self.nick, self.room_jid, password)
obj.conn.join_gc(self.nick, self.room_jid, password, rejoin=True)
def _nec_decrypted_message_received(self, obj):
if obj.conn.name != self.account:
@ -1351,7 +1351,7 @@ class GroupchatControl(ChatControlBase):
return False
password = gajim.gc_passwords.get(self.room_jid, '')
gajim.connections[self.account].join_gc(self.nick, self.room_jid,
password)
password, rejoin=True)
return True
def draw_roster(self):