Changeset

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
parents 4339:63304d323983
children 4341:225d46be7301
files plugins/mod_pubsub.lua
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_pubsub.lua	Wed Aug 10 17:49:37 2011 -0400
+++ b/plugins/mod_pubsub.lua	Sun Aug 14 13:36:54 2011 -0400
@@ -110,7 +110,11 @@
 
 function handlers.set_subscribe(origin, stanza, subscribe)
 	local node, jid = subscribe.attr.node, subscribe.attr.jid;
-	local ok, ret = service:add_subscription(node, stanza.attr.from, jid);
+	local options_tag, options = stanza.tags[1]:get_child("options"), nil;
+	if options_tag then
+		options = options_form:data(options_tag.tags[1]);
+	end
+	local ok, ret = service:add_subscription(node, stanza.attr.from, jid, options);
 	local reply;
 	if ok then
 		reply = st.reply(stanza)
@@ -119,7 +123,10 @@
 					node = node,
 					jid = jid,
 					subscription = "subscribed"
-				});
+				}):up();
+		if options_tag then
+			reply:add_child(options_tag);
+		end
 	else
 		reply = pubsub_error_reply(stanza, ret);
 	end