# HG changeset patch # User Emmanuel Gil Peyrot # Date 1535132070 -7200 # Node ID 9bb317400c4cc597bd4855a1055232f6373210f6 # Parent 6824a1f3d8c073e8740156397f7f64fc46d7682d mod_group_bookmarks: Use iq-get event instead of checking for stanza.attr.type == "get". diff -r 6824a1f3d8c0 -r 9bb317400c4c mod_group_bookmarks/mod_group_bookmarks.lua --- a/mod_group_bookmarks/mod_group_bookmarks.lua Fri Aug 24 19:29:34 2018 +0200 +++ b/mod_group_bookmarks/mod_group_bookmarks.lua Fri Aug 24 19:34:30 2018 +0200 @@ -42,9 +42,8 @@ return data; end -module:hook("iq/self/jabber:iq:private:query", function(event) +module:hook("iq-get/self/jabber:iq:private:query", function(event) local origin, stanza = event.origin, event.stanza; - local type = stanza.attr.type; local query = stanza.tags[1]; if #query.tags == 1 then local tag = query.tags[1]; @@ -54,23 +53,21 @@ origin.send(st.error_reply(stanza, "wait", "internal-server-error")); return true; end - if stanza.attr.type == "get" then - local data = data and data[key]; - if (not data) and key == "storage:storage:bookmarks" then - data = st.stanza("storage", { xmlns = "storage:bookmarks" }); + local data = data and data[key]; + if (not data) and key == "storage:storage:bookmarks" 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 - 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 - return true; + 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 + return true; end end, 1);