Mercurial > prosody-modules
comparison mod_group_bookmarks/mod_group_bookmarks.lua @ 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 |
comparison
equal
deleted
inserted
replaced
| 3260:9bb317400c4c | 3261:c2b1f64aaf97 |
|---|---|
| 46 local origin, stanza = event.origin, event.stanza; | 46 local origin, stanza = event.origin, event.stanza; |
| 47 local query = stanza.tags[1]; | 47 local query = stanza.tags[1]; |
| 48 if #query.tags == 1 then | 48 if #query.tags == 1 then |
| 49 local tag = query.tags[1]; | 49 local tag = query.tags[1]; |
| 50 local key = tag.name..":"..tag.attr.xmlns; | 50 local key = tag.name..":"..tag.attr.xmlns; |
| 51 if key ~= "storage:storage:bookmarks" then | |
| 52 return; | |
| 53 end | |
| 51 local data, err = dm_load(origin.username, origin.host, "private"); | 54 local data, err = dm_load(origin.username, origin.host, "private"); |
| 52 if err then | 55 if err then |
| 53 origin.send(st.error_reply(stanza, "wait", "internal-server-error")); | 56 origin.send(st.error_reply(stanza, "wait", "internal-server-error")); |
| 54 return true; | 57 return true; |
| 55 end | 58 end |
| 56 local data = data and data[key]; | 59 local data = data and data[key]; |
| 57 if (not data) and key == "storage:storage:bookmarks" then | 60 if not data then |
| 58 data = st.stanza("storage", { xmlns = "storage:bookmarks" }); | 61 data = st.stanza("storage", { xmlns = "storage:bookmarks" }); |
| 59 end | 62 end |
| 60 if data then | 63 data = st.deserialize(data); |
| 61 data = st.deserialize(data); | 64 data = inject_bookmarks(origin.username, origin.host, data); |
| 62 if key == "storage:storage:bookmarks" then | 65 origin.send(st.reply(stanza):tag("query", {xmlns = "jabber:iq:private"}) |
| 63 data = inject_bookmarks(origin.username, origin.host, data); | 66 :add_child(data)); |
| 64 end | |
| 65 origin.send(st.reply(stanza):tag("query", {xmlns = "jabber:iq:private"}) | |
| 66 :add_child(data)); | |
| 67 else | |
| 68 origin.send(st.reply(stanza):add_child(stanza.tags[1])); | |
| 69 end | |
| 70 return true; | 67 return true; |
| 71 end | 68 end |
| 72 end, 1); | 69 end, 1); |
| 73 | 70 |
| 74 function module.load() | 71 function module.load() |
