plugins/mod_pubsub.lua

changeset 3697
67c01f75af97
parent 3672
b24db47995ac
child 3698
77171fd1dc3c
equal deleted inserted replaced
3696:a96f275c42b5 3697:67c01f75af97
23 return true; 23 return true;
24 end 24 end
25 end 25 end
26 26
27 local pubsub_errors = { 27 local pubsub_errors = {
28 ["conflict"] = { "cancel", "conflict" };
28 ["invalid-jid"] = { "modify", "bad-request", nil, "invalid-jid" }; 29 ["invalid-jid"] = { "modify", "bad-request", nil, "invalid-jid" };
29 ["item-not-found"] = { "cancel", "item-not-found" }; 30 ["item-not-found"] = { "cancel", "item-not-found" };
30 }; 31 };
31 function pubsub_error_reply(stanza, error) 32 function pubsub_error_reply(stanza, error)
32 local e = pubsub_errors[error]; 33 local e = pubsub_errors[error];
48 if data then 49 if data then
49 reply = st.reply(stanza) 50 reply = st.reply(stanza)
50 :tag("pubsub", { xmlns = xmlns_pubsub }) 51 :tag("pubsub", { xmlns = xmlns_pubsub })
51 :add_child(data); 52 :add_child(data);
52 else 53 else
53 reply = st.error_reply(stanza, "cancel", "item-not-found", "Item could not be found in this node"); 54 reply = pubsub_error_reply(stanza, "item-not-found");
54 end 55 end
55 return origin.send(reply); 56 return origin.send(reply);
56 end 57 end
57 58
58 function handlers.set_create(origin, stanza, create) 59 function handlers.set_create(origin, stanza, create)
61 if node then 62 if node then
62 ok, ret = service:create(node, stanza.attr.from); 63 ok, ret = service:create(node, stanza.attr.from);
63 if ok then 64 if ok then
64 reply = st.reply(stanza); 65 reply = st.reply(stanza);
65 else 66 else
66 reply = st.error_reply(stanza, "cancel", ret); 67 reply = pubsub_error_reply(stanza, ret);
67 end 68 end
68 else 69 else
69 repeat 70 repeat
70 node = uuid_generate(); 71 node = uuid_generate();
71 ok, ret = service:create(node, stanza.attr.from); 72 ok, ret = service:create(node, stanza.attr.from);

mercurial