core, bridge, quick_frontend: MUC private messages history management:
- history now store message type
- sqlite3 storage: fixed resource management in getHistory
- bridge: added message type in getHistory return value
- quick_chats: (ugly) hacks to manage private history filtering/nickname printing
This commit is contained in:
parent
d5fac19b9e
commit
fef2b1a620
1 changed files with 52 additions and 30 deletions
|
|
@ -100,18 +100,28 @@ class QuickChat():
|
|||
debug (_("now we print history"))
|
||||
def onHistory(history):
|
||||
for line in history:
|
||||
timestamp, from_jid, to_jid, message = line
|
||||
timestamp, from_jid, to_jid, message, _type = line
|
||||
if ((self.type == 'group' and _type != 'groupchat') or
|
||||
(self.type == 'one2one' and _type == 'groupchat')):
|
||||
continue
|
||||
self.printMessage(JID(from_jid), message, profile, timestamp)
|
||||
|
||||
def onHistoryError(err):
|
||||
error (_("Can't get history"))
|
||||
|
||||
self.host.bridge.getHistory(self.host.profiles[profile]['whoami'].short, self.target.short, 20, callback=onHistory, errback=onHistoryError)
|
||||
if self.target.startswith(const_PRIVATE_PREFIX):
|
||||
target = unescapePrivate(self.target)
|
||||
else:
|
||||
target = self.target.short
|
||||
|
||||
self.host.bridge.getHistory(self.host.profiles[profile]['whoami'].short, target, 20, callback=onHistory, errback=onHistoryError)
|
||||
|
||||
def _get_nick(self, jid):
|
||||
"""Return nick of this jid when possible"""
|
||||
if jid.startswith(const_PRIVATE_PREFIX):
|
||||
return unescapePrivate(jid).resource
|
||||
if self.target.startswith(const_PRIVATE_PREFIX):
|
||||
unescaped = unescapePrivate(self.target)
|
||||
if jid.startswith(const_PRIVATE_PREFIX) or unescaped.short == jid.short:
|
||||
return unescaped.resource
|
||||
return jid.resource if self.type == "group" else (self.host.contact_list.getCache(jid,'nick') or self.host.contact_list.getCache(jid,'name') or jid.node)
|
||||
|
||||
def printMessage(self, from_jid, msg, profile, timestamp):
|
||||
|
|
|
|||
Loading…
Reference in a new issue