Mercurial > libervia-backend
changeset 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 | 142ecb7f6338 |
children | 7255286a298a |
files | sat_frontends/primitivus/chat.py |
diffstat | 1 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/sat_frontends/primitivus/chat.py Wed Feb 26 22:03:15 2020 +0100 +++ b/sat_frontends/primitivus/chat.py Wed Feb 26 22:03:15 2020 +0100 @@ -18,6 +18,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. from functools import total_ordering +from pathlib import Path import bisect import urwid from urwid_satext import sat_widgets @@ -442,6 +443,20 @@ False is generally used when printing history, when we don't want every message to be notified. """ + if message.attachments: + # FIXME: Q&D way to see attachments in Primitivus + # it should be done in a more user friendly way + for lang, body in message.message.items(): + for attachment in message.attachments: + if 'url' in attachment: + body+=f"\n{attachment['url']}" + elif 'path' in attachment: + path = Path(attachment['path']) + body+=f"\n{path.as_uri()}" + else: + log.warning(f'No "url" nor "path" in attachment: {attachment}') + message.message[lang] = body + if self.filters: if not all([f(message) for f in self.filters]): return