comparison libervia/backend/plugins/plugin_xep_0234.py @ 4220:5a0bddfa34ac

plugin XEP-0234: fix action type when pre-flight file confirmation is confirmed: the `C.META_TYPE_FILE` can't be used in this case as it is a preflight and we don't have yet data such as progress ID. `C.META_TYPE_FILE` is used as a sub-type to help with dialog management in frontend.
author Goffi <goffi@goffi.org>
date Tue, 05 Mar 2024 17:31:49 +0100
parents 0da563780ffc
children e11b13418ba6
comparison
equal deleted inserted replaced
4219:1b5cf2ee1d86 4220:5a0bddfa34ac
441 '"{human_name}" session with you, this would leak your presence and ' 441 '"{human_name}" session with you, this would leak your presence and '
442 "possibly you IP (internet localisation), do you accept?" 442 "possibly you IP (internet localisation), do you accept?"
443 ).format(peer_jid=peer_jid, human_name=self.human_name) 443 ).format(peer_jid=peer_jid, human_name=self.human_name)
444 confirm_title = D_("File sent from an unknown contact") 444 confirm_title = D_("File sent from an unknown contact")
445 action_type = C.META_TYPE_NOT_IN_ROSTER_LEAK 445 action_type = C.META_TYPE_NOT_IN_ROSTER_LEAK
446 action_subtype = None
446 else: 447 else:
447 confirm_msg = D_( 448 confirm_msg = D_(
448 "{peer_jid} wants to send a file ro you, do you accept?" 449 "{peer_jid} wants to send a file to you, do you accept?"
449 ).format(peer_jid=peer_jid) 450 ).format(peer_jid=peer_jid)
450 confirm_title = D_("File Proposed") 451 confirm_title = D_("File Proposed")
451 action_type = C.META_TYPE_FILE 452 action_type = C.META_TYPE_CONFIRM
453 action_subtype = C.META_TYPE_FILE
454 action_extra = {
455 "type": action_type,
456 "session_id": session_id,
457 "from_jid": peer_jid.full(),
458 }
459 if action_subtype is not None:
460 action_extra["subtype"] = action_subtype
452 accepted = await xml_tools.defer_confirm( 461 accepted = await xml_tools.defer_confirm(
453 self.host, 462 self.host,
454 confirm_msg, 463 confirm_msg,
455 confirm_title, 464 confirm_title,
456 profile=client.profile, 465 profile=client.profile,
457 action_extra={ 466 action_extra=action_extra
458 "type": action_type,
459 "session_id": session_id,
460 "from_jid": peer_jid.full(),
461 },
462 ) 467 )
463 if accepted: 468 if accepted:
464 session["file_accepted"] = True 469 session["file_accepted"] = True
465 return accepted 470 return accepted
466 471
544 self.build_file_element_from_dict(client, file_data, file_elt=file_elt) 549 self.build_file_element_from_dict(client, file_data, file_elt=file_elt)
545 550
546 return desc_elt 551 return desc_elt
547 552
548 async def jingle_request_confirmation( 553 async def jingle_request_confirmation(
549 self, client, action, session, content_name, desc_elt 554 self,
555 client: SatXMPPEntity,
556 action: str,
557 session: dict,
558 content_name: str,
559 desc_elt: domish.Element,
550 ): 560 ):
551 """This method request confirmation for a jingle session""" 561 """This method request confirmation for a jingle session"""
552 content_data = session["contents"][content_name] 562 content_data = session["contents"][content_name]
553 senders = content_data["senders"] 563 senders = content_data["senders"]
554 if senders not in (self._j.ROLE_INITIATOR, self._j.ROLE_RESPONDER): 564 if senders not in (self._j.ROLE_INITIATOR, self._j.ROLE_RESPONDER):