comparison sat/plugins/plugin_exp_invitation.py @ 3351:19bad15f4c0a

plugin invitation: if "thumb_url" is not set, try to use one from list of interests
author Goffi <goffi@goffi.org>
date Sat, 05 Sep 2020 20:23:25 +0200
parents cc6164a4973b
children 000b6722bd35
comparison
equal deleted inserted replaced
3350:cc6164a4973b 3351:19bad15f4c0a
173 client, service, namespace, path, {invitee_jid: "member"} 173 client, service, namespace, path, {invitee_jid: "member"}
174 ) 174 )
175 except Exception as e: 175 except Exception as e:
176 log.warning(f"Can't set affiliation: {e}") 176 log.warning(f"Can't set affiliation: {e}")
177 177
178 if "thumb_url" not in extra:
179 # we have no thumbnail, we check in our own list of interests if there is one
180 try:
181 item_id = li_plg.getFileSharingId(service, namespace, path)
182 own_interest = await li_plg.get(client, item_id)
183 except exceptions.NotFound:
184 log.debug(
185 "no thumbnail found for file sharing interest at "
186 f"[{service}/{namespace}]{path}"
187 )
188 else:
189 try:
190 extra['thumb_url'] = own_interest['thumb_url']
191 except KeyError:
192 pass
193
178 mess_data, invitation_elt = self._generateBaseInvitation( 194 mess_data, invitation_elt = self._generateBaseInvitation(
179 client, invitee_jid, name, extra) 195 client, invitee_jid, name, extra)
180 file_sharing_elt = invitation_elt.addElement("file_sharing") 196 file_sharing_elt = invitation_elt.addElement("file_sharing")
181 file_sharing_elt["service"] = service.full() 197 file_sharing_elt["service"] = service.full()
182 if repos_type is not None: 198 if repos_type is not None: