changeset 3261:c2b1f64aaf97

mod_group_bookmarks: Return early when the key is not bookmarks.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 24 Aug 2018 19:38:17 +0200
parents 9bb317400c4c
children 0ccdd3f31435
files mod_group_bookmarks/mod_group_bookmarks.lua
diffstat 1 files changed, 8 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mod_group_bookmarks/mod_group_bookmarks.lua	Fri Aug 24 19:34:30 2018 +0200
+++ b/mod_group_bookmarks/mod_group_bookmarks.lua	Fri Aug 24 19:38:17 2018 +0200
@@ -48,25 +48,22 @@
 	if #query.tags == 1 then
 		local tag = query.tags[1];
 		local key = tag.name..":"..tag.attr.xmlns;
+		if key ~= "storage:storage:bookmarks" then
+			return;
+		end
 		local data, err = dm_load(origin.username, origin.host, "private");
 		if err then
 			origin.send(st.error_reply(stanza, "wait", "internal-server-error"));
 			return true;
 		end
 		local data = data and data[key];
-		if (not data) and key == "storage:storage:bookmarks" then
+		if not data then
 			data = st.stanza("storage", { xmlns = "storage:bookmarks" });
 		end
-		if data then
-			data = st.deserialize(data);
-			if key == "storage:storage:bookmarks" then
-				data = inject_bookmarks(origin.username, origin.host, data);
-			end
-			origin.send(st.reply(stanza):tag("query", {xmlns = "jabber:iq:private"})
-				:add_child(data));
-		else
-			origin.send(st.reply(stanza):add_child(stanza.tags[1]));
-		end
+		data = st.deserialize(data);
+		data = inject_bookmarks(origin.username, origin.host, data);
+		origin.send(st.reply(stanza):tag("query", {xmlns = "jabber:iq:private"})
+			:add_child(data));
 		return true;
 	end
 end, 1);