Fix "show" for threads in boobmsg

This commit is contained in:
Florent 2014-10-10 14:56:40 +02:00
commit 768be7fcc6

View file

@ -27,6 +27,7 @@ from tempfile import NamedTemporaryFile
from lxml import etree from lxml import etree
from weboob.core import CallErrors from weboob.core import CallErrors
from weboob.capabilities.base import empty
from weboob.capabilities.messages import CapMessages, Message, Thread from weboob.capabilities.messages import CapMessages, Message, Thread
from weboob.capabilities.account import CapAccount from weboob.capabilities.account import CapAccount
from weboob.capabilities.contact import CapContact from weboob.capabilities.contact import CapContact
@ -437,9 +438,20 @@ class Boobmsg(ReplApplication):
try: try:
message = self.messages[int(arg) - 1] message = self.messages[int(arg) - 1]
except (IndexError, ValueError): except (IndexError, ValueError):
id, backend_name = self.parse_id(arg) # The message is not is the cache, we have now two cases:
cmd = self.do('get_thread', id, backends=backend_name) # 1) the user uses a number to get a thread in the cache
for thread in cmd: # 2) the user gives a thread id
try:
thread = self.threads[int(arg) - 1]
if not empty(thread.root):
message = thread.root
else:
for thread in self.do('get_thread', thread.id, backends=thread.backend):
if thread is not None:
message = thread.root
except (IndexError, ValueError):
_id, backend_name = self.parse_id(arg)
for thread in self.do('get_thread', _id, backends=backend_name):
if thread is not None: if thread is not None:
message = thread.root message = thread.root
if message is not None: if message is not None: