Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/python-nbxmpp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlovetox <philipp@hoerist.com>2021-05-27 21:38:15 +0300
committerlovetox <philipp@hoerist.com>2021-05-27 21:38:15 +0300
commit589fd69983bac85a6947004e010f3e22b5cb5053 (patch)
tree17f5f811a64aac7679e86587424282bfbbb95399
parent73c4352f706ed9a9bea0ec577065995844338ced (diff)
AdHoc: Don’t expect session id for one stage commands
-rw-r--r--nbxmpp/modules/adhoc.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/nbxmpp/modules/adhoc.py b/nbxmpp/modules/adhoc.py
index e0415f0..e01127b 100644
--- a/nbxmpp/modules/adhoc.py
+++ b/nbxmpp/modules/adhoc.py
@@ -66,18 +66,18 @@ class AdHoc(BaseModule):
yield command_list
@iq_request_task
- def execute_command(self, command, action=None, dataform=None):
+ def execute_command(self, cmd, action=None, dataform=None):
_task = yield
if action is None:
action = AdHocAction.EXECUTE
- attrs = {'node': command.node,
+ attrs = {'node': cmd.node,
'xmlns': Namespace.COMMANDS,
'action': action.value}
- if command.sessionid is not None:
- attrs['sessionid'] = command.sessionid
+ if cmd.sessionid is not None:
+ attrs['sessionid'] = cmd.sessionid
- response = yield _make_command(command, attrs, dataform)
+ response = yield _make_command(cmd, attrs, dataform)
if response.isError():
raise StanzaError(response)
@@ -89,10 +89,6 @@ class AdHoc(BaseModule):
if node is None:
raise MalformedStanzaError('node attribute missing', response)
- sessionid = command.getAttr('sessionid')
- if sessionid is None:
- raise MalformedStanzaError('sessionid attribute missing', response)
-
status = command.getAttr('status')
if status is None:
raise MalformedStanzaError('status attribute missing', response)
@@ -103,6 +99,10 @@ class AdHoc(BaseModule):
status = AdHocStatus(status)
+ sessionid = command.getAttr('sessionid')
+ if sessionid is None and _expect_sessionid(status, cmd.sessionid):
+ raise MalformedStanzaError('sessionid attribute missing', response)
+
try:
notes = _parse_notes(command)
except ValueError as error:
@@ -192,3 +192,9 @@ def _parse_actions(command):
default = actions[0]
return actions, default
+
+
+def _expect_sessionid(status, sent_sessionid):
+ # Session id should only be expected for multiple stage commands
+ # or when we initialize the session (set the session attribute)
+ return status != status.COMPLETED or sent_sessionid is not None