comparison sat_frontends/primitivus/chat.py @ 3190:1c6dacbfcf27

primitivus (chat) Q&D way to see attachments
author Goffi <goffi@goffi.org>
date Wed, 26 Feb 2020 22:03:15 +0100
parents 30e08d904208
children be6d91572633
comparison
equal deleted inserted replaced
3189:142ecb7f6338 3190:1c6dacbfcf27
16 16
17 # You should have received a copy of the GNU Affero General Public License 17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20 from functools import total_ordering 20 from functools import total_ordering
21 from pathlib import Path
21 import bisect 22 import bisect
22 import urwid 23 import urwid
23 from urwid_satext import sat_widgets 24 from urwid_satext import sat_widgets
24 from sat.core.i18n import _ 25 from sat.core.i18n import _
25 from sat.core import log as logging 26 from sat.core import log as logging
440 If False, notification are not shown except if we have an important one 441 If False, notification are not shown except if we have an important one
441 (like a mention). 442 (like a mention).
442 False is generally used when printing history, when we don't want every 443 False is generally used when printing history, when we don't want every
443 message to be notified. 444 message to be notified.
444 """ 445 """
446 if message.attachments:
447 # FIXME: Q&D way to see attachments in Primitivus
448 # it should be done in a more user friendly way
449 for lang, body in message.message.items():
450 for attachment in message.attachments:
451 if 'url' in attachment:
452 body+=f"\n{attachment['url']}"
453 elif 'path' in attachment:
454 path = Path(attachment['path'])
455 body+=f"\n{path.as_uri()}"
456 else:
457 log.warning(f'No "url" nor "path" in attachment: {attachment}')
458 message.message[lang] = body
459
445 if self.filters: 460 if self.filters:
446 if not all([f(message) for f in self.filters]): 461 if not all([f(message) for f in self.filters]):
447 return 462 return
448 463
449 if self.handleUserMoved(message): 464 if self.handleUserMoved(message):