Diff

mod_mam/mod_mam.lua @ 1681:d20cfc5ba827

mod_mam: Always return true when a stanza event has been handled
author Kim Alvefur <zash@zash.se>
date Sun, 03 May 2015 13:20:04 +0200
parent 1678:9ee56cc1be2c
child 1682:6b2122630b92
line wrap: on
line diff
--- a/mod_mam/mod_mam.lua	Tue Apr 28 14:26:03 2015 +0100
+++ b/mod_mam/mod_mam.lua	Sun May 03 13:20:04 2015 +0200
@@ -52,16 +52,18 @@
 	if stanza.attr.type == "get" then
 		local prefs = prefs_to_stanza(get_prefs(user));
 		local reply = st.reply(stanza):add_child(prefs);
-		return origin.send(reply);
+		origin.send(reply);
 	else -- type == "set"
 		local new_prefs = stanza:get_child("prefs", xmlns_mam);
 		local prefs = prefs_from_stanza(new_prefs);
 		local ok, err = set_prefs(user, prefs);
 		if not ok then
-			return origin.send(st.error_reply(stanza, "cancel", "internal-server-error", "Error storing preferences: "..tostring(err)));
+			origin.send(st.error_reply(stanza, "cancel", "internal-server-error", "Error storing preferences: "..tostring(err)));
+		else
+			origin.send(st.reply(stanza));
 		end
-		return origin.send(st.reply(stanza));
 	end
+	return true;
 end);
 
 local query_form = dataform {
@@ -74,7 +76,8 @@
 -- Serve form
 module:hook("iq-get/self/"..xmlns_mam..":query", function(event)
 	local origin, stanza = event.origin, event.stanza;
-	return origin.send(st.reply(stanza):add_child(query_form:form()));
+	origin.send(st.reply(stanza):add_child(query_form:form()));
+	return true;
 end);
 
 -- Handle archive queries
@@ -90,7 +93,8 @@
 		local err;
 		form, err = query_form:data(form);
 		if err then
-			return origin.send(st.error_reply(stanza, "modify", "bad-request", select(2, next(err))))
+			origin.send(st.error_reply(stanza, "modify", "bad-request", select(2, next(err))))
+			return true;
 		end
 		qwith, qstart, qend = form["with"], form["start"], form["end"];
 		qwith = qwith and jid_bare(qwith); -- dataforms does jidprep
@@ -127,7 +131,8 @@
 	});
 
 	if not data then
-		return origin.send(st.error_reply(stanza, "cancel", "internal-server-error", err));
+		origin.send(st.error_reply(stanza, "cancel", "internal-server-error", err));
+		return true;
 	end
 	local count = err;
 
@@ -157,10 +162,11 @@
 	module:log("debug", "Archive query %s completed", tostring(qid));
 
 	if reverse then first, last = last, first; end
-	return origin.send(st.message(msg_reply_attr)
+	origin.send(st.message(msg_reply_attr)
 		:tag("fin", { xmlns = xmlns_mam, queryid = qid })
 			:add_child(rsm.generate {
 				first = first, last = last, count = count }));
+	return true;
 end);
 
 local function has_in_roster(user, who)