plugin XEP-0050: fix handling of form submitted in the first request:

form submitted on first request (without retrieval first) was broken, this patch fixes it.
This commit is contained in:
Goffi 2026-10-20 13:28:44 +02:00
commit da20bba2ab

View file

@ -580,16 +580,23 @@ class AdHocCommandHandler(XMPPHandler):
)
await self._send_error(Error.BAD_ACTION, session_id, iq_elt)
return
# This is the first request, if a initial form is specified, we return it
# directly.
# This is the first request, if an initial form is specified, we return it
# directly, unless the client already submitted it: we then record it as
# forms[0] and process them directly
if self.command.form is not None:
await self._send_answer(
AdHocCallbackData(form=self.command.form, status=Status.EXECUTING),
session_id,
session_data_private,
iq_elt,
)
return
if next(command_elt.elements(data_form.NS_X_DATA, "x"), None):
forms[0] = self.command.form
page_idx = session_data_private["page_idx"] = 1
else:
await self._send_answer(
AdHocCallbackData(
form=self.command.form, status=Status.EXECUTING
),
session_id,
session_data_private,
iq_elt,
)
return
if action == Action.CANCEL:
ret_data = AdHocCallbackData(form=None, status=Status.CANCELED)