extends Node class_name Stanza const disco_info_queury := "" const disco_items_queury := "" static func yield_as_is(): return yield() static func unwrap_query_result(iq: Xml.XmlElement) -> Sums.Result: if iq == null or iq.name != "iq" or not "type" in iq.attributes: return Sums.Result.make_error(ERR_INVALID_DATA) # todo: Delegate strctured XMPP error. if iq.attributes["type"] != "result": return Sums.Result.make_error(ERR_INVALID_DATA) for child in iq.children: if child.is_element() and child.name == "query": return Sums.Result.make_value(child) return Sums.Result.make_error(ERR_INVALID_DATA) static func form_presence(id: String, from: String, to: String, type, payload: String) -> String: if type != null: return """{payload}""".format({ "from": from.xml_escape(), "id": id.xml_escape(), "to": to.xml_escape(), "type": type, "payload": payload }) else: return """{payload}""".format({ "from": from.xml_escape(), "id": id.xml_escape(), "to": to.xml_escape(), "payload": payload }) static func presence_result(stanza: Xml.XmlElement) -> Sums.Result: if "type" in stanza.attributes and stanza.attributes["type"] == "error": return Sums.Result.make_error(stanza) else: return Sums.Result.make_value(stanza) static func extract_resource_part(jid: String) -> String: var parts = jid.rsplit("/") assert(parts.size() > 0) return parts[parts.size() - 1]