Comparison

mod_pubsub_post/mod_pubsub_post.lua @ 4522:08b71d02c6dc

mod_pubsub_post: Allow specifying item id by a special mapping If `{http://jabber.org/protocol/pubsub}id` exists as an attribute at the top level then it is used, otherwise the previous behavior (.id if string)
author Kim Alvefur <zash@zash.se>
date Mon, 22 Mar 2021 21:20:03 +0100
parent 4521:f7381268a597
child 4552:c87181a98f29
comparison
equal deleted inserted replaced
4521:f7381268a597 4522:08b71d02c6dc
61 end 61 end
62 if type(parsed) ~= "table" then 62 if type(parsed) ~= "table" then
63 return { status_code = 400; body = "object or array expected"; }; 63 return { status_code = 400; body = "object or array expected"; };
64 end 64 end
65 local payload = wrap(node, parsed, data) 65 local payload = wrap(node, parsed, data)
66 return publish_payload(node, actor, type(parsed.id) == "string" and parsed.id or "current", payload); 66 local item_id = "current";
67 if payload.attr["http://jabber.org/protocol/pubsub\1id"] then
68 item_id = payload.attr["http://jabber.org/protocol/pubsub\1id"];
69 payload.attr["http://jabber.org/protocol/pubsub\1id"] = nil;
70 elseif type(parsed.id) == "string" then
71 item_id = parsed.id;
72 end
73 return publish_payload(node, actor, item_id, payload);
67 end 74 end
68 75
69 local function publish_atom(node, actor, feed) 76 local function publish_atom(node, actor, feed)
70 for entry in feed:childtags("entry") do 77 for entry in feed:childtags("entry") do
71 local item_id = entry:get_child_text("id"); 78 local item_id = entry:get_child_text("id");