Changeset

8252:63e505578d4f

mod_mam: Also return the preferences on set Fixes #995.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 19 Sep 2017 23:38:08 +0200
parents 8251:cb2d86f4b511
children 8253:3a6f5b0f56f0 8254:e3f7b6fa46ba
files plugins/mod_mam/mod_mam.lua
diffstat 1 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_mam/mod_mam.lua	Wed Sep 20 14:42:21 2017 +0100
+++ b/plugins/mod_mam/mod_mam.lua	Tue Sep 19 23:38:08 2017 +0200
@@ -67,20 +67,18 @@
 module:hook("iq/self/"..xmlns_mam..":prefs", function(event)
 	local origin, stanza = event.origin, event.stanza;
 	local user = origin.username;
-	if stanza.attr.type == "get" then
-		local prefs = prefs_to_stanza(get_prefs(user));
-		local reply = st.reply(stanza):add_child(prefs);
-		origin.send(reply);
-	else -- type == "set"
+	if stanza.attr.type == "set" then
 		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
 			origin.send(st.error_reply(stanza, "cancel", "internal-server-error", "Error storing preferences: "..tostring(err)));
-		else
-			origin.send(st.reply(stanza));
+			return true;
 		end
 	end
+	local prefs = prefs_to_stanza(get_prefs(user));
+	local reply = st.reply(stanza):add_child(prefs);
+	origin.send(reply);
 	return true;
 end);