From 5ec9d7ffec27ab632c694eb81dc48b42bcb52b51 Mon Sep 17 00:00:00 2001 From: Goffi Date: Sat, 5 Sep 2020 20:23:25 +0200 Subject: [PATCH] plugin invitation: if "thumb_url" is not set, try to use one from list of interests --- sat/plugins/plugin_exp_invitation.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sat/plugins/plugin_exp_invitation.py b/sat/plugins/plugin_exp_invitation.py index a7d69c52..889459b7 100644 --- a/sat/plugins/plugin_exp_invitation.py +++ b/sat/plugins/plugin_exp_invitation.py @@ -175,6 +175,22 @@ class Invitation(object): except Exception as e: log.warning(f"Can't set affiliation: {e}") + if "thumb_url" not in extra: + # we have no thumbnail, we check in our own list of interests if there is one + try: + item_id = li_plg.getFileSharingId(service, namespace, path) + own_interest = await li_plg.get(client, item_id) + except exceptions.NotFound: + log.debug( + "no thumbnail found for file sharing interest at " + f"[{service}/{namespace}]{path}" + ) + else: + try: + extra['thumb_url'] = own_interest['thumb_url'] + except KeyError: + pass + mess_data, invitation_elt = self._generateBaseInvitation( client, invitee_jid, name, extra) file_sharing_elt = invitation_elt.addElement("file_sharing")