comparison mod_pubsub_post/mod_pubsub_post.lua @ 3793:0d3926e49b55

mod_pubsub_post: Fix use of 'id' field in JSON object as pubsub item id `data` here is the source string, so there's no `id` field. Also only use the `id` field if it's a string.
author Kim Alvefur <zash@zash.se>
date Wed, 01 Jan 2020 10:11:08 +0100
parents 9ef5b229f73e
children f7381268a597
comparison
equal deleted inserted replaced
3792:aec772bbd558 3793:0d3926e49b55
41 end 41 end
42 if type(parsed) ~= "table" then 42 if type(parsed) ~= "table" then
43 return { status_code = 400; body = "object or array expected"; }; 43 return { status_code = 400; body = "object or array expected"; };
44 end 44 end
45 local wrapper = st.stanza("json", { xmlns="urn:xmpp:json:0" }):text(data); 45 local wrapper = st.stanza("json", { xmlns="urn:xmpp:json:0" }):text(data);
46 return publish_payload(node, actor, data.id or "current", wrapper); 46 return publish_payload(node, actor, type(parsed.id) == "string" and parsed.id or "current", wrapper);
47 end 47 end
48 48
49 local function publish_atom(node, actor, feed) 49 local function publish_atom(node, actor, feed)
50 for entry in feed:childtags("entry") do 50 for entry in feed:childtags("entry") do
51 local item_id = entry:get_child_text("id"); 51 local item_id = entry:get_child_text("id");