Software /
code /
prosody
Comparison
plugins/mod_pubsub.lua @ 3699:150e58d69e60
mod_pubsub: Support item retraction
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Sun, 05 Dec 2010 04:19:23 +0100 |
parent | 3698:77171fd1dc3c |
child | 3700:c8fcd63e9526 |
comparison
equal
deleted
inserted
replaced
3698:77171fd1dc3c | 3699:150e58d69e60 |
---|---|
74 until ok; | 74 until ok; |
75 reply = st.reply(stanza) | 75 reply = st.reply(stanza) |
76 :tag("pubsub", { xmlns = xmlns_pubsub }) | 76 :tag("pubsub", { xmlns = xmlns_pubsub }) |
77 :tag("create", { node = node }); | 77 :tag("create", { node = node }); |
78 end | 78 end |
79 origin.send(reply); | 79 return origin.send(reply); |
80 end | 80 end |
81 | 81 |
82 function handlers.set_subscribe(origin, stanza, subscribe) | 82 function handlers.set_subscribe(origin, stanza, subscribe) |
83 local node, jid = subscribe.attr.node, subscribe.attr.jid; | 83 local node, jid = subscribe.attr.node, subscribe.attr.jid; |
84 if jid_bare(jid) ~= jid_bare(stanza.attr.from) then | 84 if jid_bare(jid) ~= jid_bare(stanza.attr.from) then |
130 reply = pubsub_error_reply(stanza, ret); | 130 reply = pubsub_error_reply(stanza, ret); |
131 end | 131 end |
132 return origin.send(reply); | 132 return origin.send(reply); |
133 end | 133 end |
134 | 134 |
135 function handlers.set_retract(origin, stanza, retract) | |
136 local node, notify = retract.attr.node, retract.attr.notify; | |
137 notify = (notify == "1") or (notify == "true"); | |
138 local item = retract:get_child("item"); | |
139 local id = item and item.attr.id | |
140 local reply, notifier; | |
141 if notify then | |
142 notifier = st.stanza("retract", { id = id }); | |
143 end | |
144 local ok, ret = service:retract(node, stanza.attr.from, id, notifier); | |
145 if ok then | |
146 reply = st.reply(stanza); | |
147 else | |
148 reply = pubsub_error_reply(stanza, ret); | |
149 end | |
150 return origin.send(reply); | |
151 end | |
152 | |
135 function simple_broadcast(node, jids, item) | 153 function simple_broadcast(node, jids, item) |
136 local message = st.message({ from = module.host, type = "headline" }) | 154 local message = st.message({ from = module.host, type = "headline" }) |
137 :tag("event", { xmlns = xmlns_pubsub_event }) | 155 :tag("event", { xmlns = xmlns_pubsub_event }) |
138 :tag("items", { node = node }) | 156 :tag("items", { node = node }) |
139 :add_child(item); | 157 :add_child(item); |