comparison sat/plugins/plugin_xep_0060.py @ 3859:3ef988734869

core: fix calls to `domish.Element.elements`: domish.Element.elements should be called with namespace and element name as 2 arguments, but it has been confused in several places with the call to `domish.Element.addElement` which is often done with a `(namespace, name)` tuple. Unfortunately calling with a tuple is accepted and doesn't raise any error in `elements`, but this result in a wrong element returned. This patch fixes the erroneous calls.
author Goffi <goffi@goffi.org>
date Wed, 20 Jul 2022 17:12:29 +0200
parents 8a2c46122a11
children e417c478b488
comparison
equal deleted inserted replaced
3858:6e785662dd7d 3859:3ef988734869
964 request.nodeIdentifier = nodeIdentifier 964 request.nodeIdentifier = nodeIdentifier
965 965
966 def cb(iq_elt): 966 def cb(iq_elt):
967 try: 967 try:
968 affiliations_elt = next( 968 affiliations_elt = next(
969 iq_elt.pubsub.elements((pubsub.NS_PUBSUB, "affiliations")) 969 iq_elt.pubsub.elements(pubsub.NS_PUBSUB, "affiliations")
970 ) 970 )
971 except StopIteration: 971 except StopIteration:
972 raise ValueError( 972 raise ValueError(
973 _("Invalid result: missing <affiliations> element: {}").format( 973 _("Invalid result: missing <affiliations> element: {}").format(
974 iq_elt.toXml 974 iq_elt.toXml
975 ) 975 )
976 ) 976 )
977 try: 977 try:
978 return { 978 return {
979 e["node"]: e["affiliation"] 979 e["node"]: e["affiliation"]
980 for e in affiliations_elt.elements((pubsub.NS_PUBSUB, "affiliation")) 980 for e in affiliations_elt.elements(pubsub.NS_PUBSUB, "affiliation")
981 } 981 }
982 except KeyError: 982 except KeyError:
983 raise ValueError( 983 raise ValueError(
984 _("Invalid result: bad <affiliation> element: {}").format( 984 _("Invalid result: bad <affiliation> element: {}").format(
985 iq_elt.toXml 985 iq_elt.toXml
1007 request.nodeIdentifier = nodeIdentifier 1007 request.nodeIdentifier = nodeIdentifier
1008 1008
1009 def cb(iq_elt): 1009 def cb(iq_elt):
1010 try: 1010 try:
1011 affiliations_elt = next( 1011 affiliations_elt = next(
1012 iq_elt.pubsub.elements((pubsub.NS_PUBSUB_OWNER, "affiliations")) 1012 iq_elt.pubsub.elements(pubsub.NS_PUBSUB_OWNER, "affiliations")
1013 ) 1013 )
1014 except StopIteration: 1014 except StopIteration:
1015 raise ValueError( 1015 raise ValueError(
1016 _("Invalid result: missing <affiliations> element: {}").format( 1016 _("Invalid result: missing <affiliations> element: {}").format(
1017 iq_elt.toXml 1017 iq_elt.toXml
1400 request.nodeIdentifier = nodeIdentifier 1400 request.nodeIdentifier = nodeIdentifier
1401 1401
1402 iq_elt = await request.send(client.xmlstream) 1402 iq_elt = await request.send(client.xmlstream)
1403 try: 1403 try:
1404 subscriptions_elt = next( 1404 subscriptions_elt = next(
1405 iq_elt.pubsub.elements((pubsub.NS_PUBSUB, "subscriptions")) 1405 iq_elt.pubsub.elements(pubsub.NS_PUBSUB, "subscriptions")
1406 ) 1406 )
1407 except StopIteration: 1407 except StopIteration:
1408 raise ValueError( 1408 raise ValueError(
1409 _("Invalid result: missing <subscriptions> element: {}").format( 1409 _("Invalid result: missing <subscriptions> element: {}").format(
1410 iq_elt.toXml 1410 iq_elt.toXml