Commit b0e76aeb authored by Emmanuel Gil Peyrot's avatar Emmanuel Gil Peyrot

Util: Fix circular import by moving get_form() to the dataforms module

parent 355cfbac
Pipeline #5443 failed with stages
in 5 seconds
......@@ -105,6 +105,22 @@ def extend_form(node):
return SimpleDataForm(extend=node)
def get_form(node, form_type):
forms = node.getTags('x', namespace=Namespace.DATA)
if not forms:
return None
for form in forms:
form = extend_form(node=form)
field = form.vars.get('FORM_TYPE')
if field is None:
continue
if field.value == form_type:
return form
return None
class DataField(ExtendedNode):
"""
Keeps data about one field - var, field type, labels, instructions... Base
......
......@@ -25,9 +25,9 @@ from nbxmpp.structs import ChangePasswordResult
from nbxmpp.util import call_on_response
from nbxmpp.util import callback
from nbxmpp.util import raise_error
from nbxmpp.util import get_form
from nbxmpp.const import REGISTER_FIELDS
from nbxmpp.modules.bits_of_binary import parse_bob_data
from nbxmpp.modules.dataforms import get_form
from nbxmpp.modules.dataforms import extend_form
from nbxmpp.modules.dataforms import create_field
from nbxmpp.modules.dataforms import SimpleDataForm
......
......@@ -342,22 +342,6 @@ def generate_id():
return str(uuid.uuid4())
def get_form(stanza, form_type):
forms = stanza.getTags('x', namespace=Namespace.DATA)
if not forms:
return None
for form in forms:
form = extend_form(node=form)
field = form.vars.get('FORM_TYPE')
if field is None:
continue
if field.value == form_type:
return form
return None
def validate_stream_header(stanza, domain, is_websocket):
attrs = stanza.getAttrs()
if attrs.get('from') != domain:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment