Skip to content
Snippets Groups Projects
Commit 623a51d5 authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

fix bug when merging server logs of MUC conversations

parent 72420b0e
No related branches found
No related tags found
No related merge requests found
......@@ -1243,12 +1243,12 @@ class ConnectionVcard:
pass
elif self.awaiting_answers[id_][0] == ARCHIVING_COLLECTION_ARRIVED:
def save_if_not_exists(with_, direction, tim, payload):
def save_if_not_exists(with_, nick, direction, tim, payload):
assert len(payload) == 1, 'got several archiving messages in the' +\
' same time %s' % ''.join(payload)
if payload[0].getName() == 'body':
gajim.logger.save_if_not_exists(with_, direction, tim,
msg=payload[0].getData())
msg=payload[0].getData(), nick=nick)
elif payload[0].getName() == 'message':
print 'Not implemented'
chat = iq_obj.getTag('chat')
......@@ -1265,12 +1265,13 @@ class ConnectionVcard:
secs = 0
if secs:
tim += secs
nick = element.getAttr('name')
if element.getName() == 'from':
save_if_not_exists(with_, 'from', localtime(tim),
save_if_not_exists(with_, nick, 'from', localtime(tim),
element.getPayload())
nb += 1
if element.getName() == 'to':
save_if_not_exists(with_, 'to', localtime(tim),
save_if_not_exists(with_, nick, 'to', localtime(tim),
element.getPayload())
nb += 1
set_ = chat.getTag('set')
......
......@@ -981,16 +981,21 @@ class Logger:
(account_jid_id,))
self.con.commit()
def save_if_not_exists(self, with_, direction, tim, msg=''):
def save_if_not_exists(self, with_, direction, tim, msg='', nick=None):
if tim:
time_col = int(float(time.mktime(tim)))
else:
time_col = int(float(time.time()))
if msg:
if self.jid_is_from_pm(with_):
# We cannot know if it's a pm or groupchat message because we only
# get body of the message
type_ = 'gc_msg'
if self.jid_is_room_jid(with_) or nick:
# It's a groupchat message
if nick:
# It's a message from a groupchat occupent
type_ = 'gc_msg'
with_ = with_ + '/' + nick
else:
# It's a server message message, we don't log them
return
else:
if direction == 'from':
type_ = 'chat_msg_recv'
......
......@@ -179,12 +179,12 @@ class ConnectionArchive:
self.dispatch('ARCHIVING_CHANGED', ('itemremove',
item.getAttr('jid')))
def request_collections_list_page(self, with='', start=None, end=None,
def request_collections_list_page(self, with_='', start=None, end=None,
after=None, max=30, exact_match=False):
iq_ = common.xmpp.Iq('get')
list_ = iq_.setTag('list', namespace=common.xmpp.NS_ARCHIVE)
if with:
list_.setAttr('with', with)
if with_:
list_.setAttr('with', with_)
if exact_match:
list_.setAttr('exactmatch', 'true')
if start:
......@@ -200,11 +200,11 @@ class ConnectionArchive:
self.awaiting_answers[id_] = (ARCHIVING_COLLECTIONS_ARRIVED, )
self.connection.send(iq_)
def request_collection_page(self, with, start, end=None, after=None,
def request_collection_page(self, with_, start, end=None, after=None,
max=30, exact_match=False):
iq_ = common.xmpp.Iq('get')
retrieve = iq_.setTag('retrieve', namespace=common.xmpp.NS_ARCHIVE,
attrs={'with': with, 'start': start})
attrs={'with': with_, 'start': start})
if exact_match:
retrieve.setAttr('exactmatch', 'true')
set_ = retrieve.setTag('set', namespace=common.xmpp.NS_RSM)
......@@ -216,12 +216,12 @@ class ConnectionArchive:
self.awaiting_answers[id_] = (ARCHIVING_COLLECTION_ARRIVED, )
self.connection.send(iq_)
def remove_collection(self, with='', start=None, end=None,
def remove_collection(self, with_='', start=None, end=None,
exact_match=False, open=False):
iq_ = common.xmpp.Iq('set')
remove = iq_.setTag('remove', namespace=common.xmpp.NS_ARCHIVE)
if with:
remove.setAttr('with', with)
if with_:
remove.setAttr('with', with_)
if exact_match:
remove.setAttr('exactmatch', 'true')
if start:
......
......@@ -3405,7 +3405,6 @@ class Interface:
self.last_ftwindow_update = 0
self.music_track_changed_signal = None
self.create_ipython_window()
class PassphraseRequest:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment