util.dataforms: Skip all fields for the 'cancel' form type
authorKim Alvefur <zash@zash.se>
Fri, 03 Aug 2018 21:06:59 +0200
changeset 9092 3a7a0b9f42f3
parent 9091 aa1b02411846
child 9093 56c52cb4d44e
util.dataforms: Skip all fields for the 'cancel' form type XEP-0004 says: > a data form of type "cancel" SHOULD NOT contain any <field/> elements. The title and instructions don't seem to be of much value in this case either. I'm not aware of 'cancel' being used anywhere, so this should break nothing. Early return is always nice.
util/dataforms.lua
--- a/util/dataforms.lua	Fri Aug 03 21:05:48 2018 +0200
+++ b/util/dataforms.lua	Fri Aug 03 21:06:59 2018 +0200
@@ -28,6 +28,9 @@
 function form_t.form(layout, data, formtype)
 	if not formtype then formtype = "form" end
 	local form = st.stanza("x", { xmlns = xmlns_forms, type = formtype });
+	if formtype == "cancel" then
+		return form;
+	end
 	if layout.title then
 		form:tag("title"):text(layout.title):up();
 	end