Software /
code /
prosody
Comparison
plugins/mod_pubsub.lua @ 4340:76420412520e
mod_pubsub: Handle options tag in subscription request (currently doesn't work as options_form is not defined)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 14 Aug 2011 13:36:54 -0400 |
parent | 4246:d0767040236f |
child | 4341:225d46be7301 |
comparison
equal
deleted
inserted
replaced
4339:63304d323983 | 4340:76420412520e |
---|---|
108 return origin.send(reply); | 108 return origin.send(reply); |
109 end | 109 end |
110 | 110 |
111 function handlers.set_subscribe(origin, stanza, subscribe) | 111 function handlers.set_subscribe(origin, stanza, subscribe) |
112 local node, jid = subscribe.attr.node, subscribe.attr.jid; | 112 local node, jid = subscribe.attr.node, subscribe.attr.jid; |
113 local ok, ret = service:add_subscription(node, stanza.attr.from, jid); | 113 local options_tag, options = stanza.tags[1]:get_child("options"), nil; |
114 if options_tag then | |
115 options = options_form:data(options_tag.tags[1]); | |
116 end | |
117 local ok, ret = service:add_subscription(node, stanza.attr.from, jid, options); | |
114 local reply; | 118 local reply; |
115 if ok then | 119 if ok then |
116 reply = st.reply(stanza) | 120 reply = st.reply(stanza) |
117 :tag("pubsub", { xmlns = xmlns_pubsub }) | 121 :tag("pubsub", { xmlns = xmlns_pubsub }) |
118 :tag("subscription", { | 122 :tag("subscription", { |
119 node = node, | 123 node = node, |
120 jid = jid, | 124 jid = jid, |
121 subscription = "subscribed" | 125 subscription = "subscribed" |
122 }); | 126 }):up(); |
127 if options_tag then | |
128 reply:add_child(options_tag); | |
129 end | |
123 else | 130 else |
124 reply = pubsub_error_reply(stanza, ret); | 131 reply = pubsub_error_reply(stanza, ret); |
125 end | 132 end |
126 return origin.send(reply); | 133 return origin.send(reply); |
127 end | 134 end |