plugin invitation: if "thumb_url" is not set, try to use one from list of interests

This commit is contained in:
Goffi 2020-09-05 20:23:25 +02:00
commit 5ec9d7ffec

View file

@ -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")