Mercurial > libervia-backend
comparison libervia/backend/plugins/plugin_xep_0234.py @ 4334:111dce64dcb5
plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Pydantic models are used more and more in Libervia, for the bridge API, and also to
convert `domish.Element` to internal representation.
Type hints have also been added in many places.
rel 453
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 03 Dec 2024 00:12:38 +0100 |
parents | 0d7bb4df2343 |
children |
comparison
equal
deleted
inserted
replaced
4333:e94799a0908f | 4334:111dce64dcb5 |
---|---|
435 progress_id = await progress_id_d | 435 progress_id = await progress_id_d |
436 return {"progress": progress_id, "session_id": session_id} | 436 return {"progress": progress_id, "session_id": session_id} |
437 | 437 |
438 def _file_jingle_request( | 438 def _file_jingle_request( |
439 self, | 439 self, |
440 peer_jid, | 440 peer_jid: str, |
441 filepath, | 441 filepath: str, |
442 name="", | 442 name: str = "", |
443 file_hash="", | 443 file_hash: str = "", |
444 hash_algo="", | 444 hash_algo: str = "", |
445 extra=None, | 445 extra: dict | None = None, |
446 profile=C.PROF_KEY_NONE, | 446 profile: str = C.PROF_KEY_NONE, |
447 ): | 447 ) -> defer.Deferred[str]: |
448 client = self.host.get_client(profile) | 448 client = self.host.get_client(profile) |
449 return defer.ensureDeferred( | 449 return defer.ensureDeferred( |
450 self.file_jingle_request( | 450 self.file_jingle_request( |
451 client, | 451 client, |
452 jid.JID(peer_jid), | 452 jid.JID(peer_jid), |
458 ) | 458 ) |
459 ) | 459 ) |
460 | 460 |
461 async def file_jingle_request( | 461 async def file_jingle_request( |
462 self, | 462 self, |
463 client, | 463 client: SatXMPPEntity, |
464 peer_jid, | 464 peer_jid: jid.JID, |
465 filepath, | 465 filepath: str, |
466 name=None, | 466 name: str | None = None, |
467 file_hash=None, | 467 file_hash: str | None = None, |
468 hash_algo=None, | 468 hash_algo: str | None = None, |
469 extra=None, | 469 extra: dict | None = None, |
470 ): | 470 ) -> str: |
471 """Request a file using jingle file transfer | 471 """Request a file using jingle file transfer |
472 | 472 |
473 @param peer_jid(jid.JID): destinee jid | 473 @param client: Profile session. |
474 @param filepath(str): absolute path where the file will be downloaded | 474 @param peer_jid: destinee jid |
475 @param name(unicode, None): name of the file | 475 @param filepath: absolute path where the file will be downloaded |
476 @param file_hash(unicode, None): hash of the file | 476 @param name: name of the file |
477 @return (D(unicode)): progress id | 477 @param file_hash: hash of the file |
478 @return: progress id | |
478 """ | 479 """ |
479 progress_id_d = defer.Deferred() | 480 progress_id_d = defer.Deferred() |
480 if extra is None: | 481 if extra is None: |
481 extra = {} | 482 extra = {} |
482 if file_hash is not None: | 483 if file_hash is not None: |