[docs]classXEP_0447(BasePlugin):""" XEP-0447: Stateless File Sharing Only support outgoing SFS, incoming is not handled at all. """name="xep_0447"description="XEP-0447: Stateless File Sharing"dependencies={"xep_0300","xep_0446"}stanza=stanzadefplugin_init(self):register_stanza_plugin(Message,stanza.StatelessFileSharing)register_stanza_plugin(stanza.StatelessFileSharing,stanza.Sources)register_stanza_plugin(stanza.StatelessFileSharing,self.xmpp["xep_0446"].stanza.File)register_stanza_plugin(stanza.Sources,stanza.UrlData,iterable=True)defget_sfs(self,path:Path,uris:Iterable[str],media_type:Optional[str],desc:Optional[str],):sfs=stanza.StatelessFileSharing()sfs["disposition"]="inline"foruriinuris:ref=stanza.UrlData()ref["target"]=urisfs["sources"].append(ref)ifmedia_type:sfs["file"]["media-type"]=media_typeifdesc:sfs["file"]["desc"]=descsfs["file"]["name"]=path.namestat=path.stat()sfs["file"]["size"]=stat.st_sizesfs["file"]["date"]=datetime.fromtimestamp(stat.st_mtime)h=self.xmpp.plugin["xep_0300"].compute_hash(path)h["value"]=h["value"].decode()sfs["file"].append(h)returnsfs