Another detail.
When I ask the subscription option form, the resulting form should be wrapped into PUBSUB and OPTIONS tags, according to paragraph 6.3.3:
<?xml version="1.0"?>
<xml>
<iq id="3" from="clochix" to="pubsub" type="get">
<pubsub xmlns="http://jabber.org/protocol/pubsub">
<options node="/tmp" jid="clochix" subid="4E336F469C59F"/>
</pubsub>
</iq>
</xml>
<?xml version="1.0"?>
<xml>
<iq from="pubsub" to="clochix" id="3" type="result">
<x xmlns="jabber:x:data">
<field var="FORM_TYPE" type="hidden">
<value>http://jabber.org/protocol/pubsub#subscribe_options</value>
</field>
I think I should get:
<?xml version="1.0"?>
<xml>
<iq from="pubsub" to="clochix" id="3" type="result">
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<options node='/tmp' jid='clochix'>
<x xmlns="jabber:x:data">
Here is a small patch for
Here is a small patch for ejabberd trunk SVN that I've written following your description:
--- a/src/mod_pubsub/mod_pubsub.erl +++ b/src/mod_pubsub/mod_pubsub.erl @@ -2464,7 +2464,10 @@ read_sub(Subscriber, NodeID, SubID, Lang) -> {error, notfound} -> {error, ?ERR_EXTENDED(?ERR_NOT_ACCEPTABLE, "invalid-subid")}; {result, #pubsub_subscription{options = Options}} -> - pubsub_subscription:get_options_xform(Lang, Options) + XdataEl = pubsub_subscription:get_options_xform(Lang, Options), + OptionsEl = {xmlelement, "options", [{"node", NodeID}, {"jid", Subscriber}], [XdataEl]}, + PubsubEl = {xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}], [OptionsEl]}, + PubsubEl end. set_options(Host, Node, JID, SubID, Configuration) ->I didn't try it and I am not mod_pubsub expert.
If you try it, please comment if it solves the problem completely or not.
Another try
Thanks. Actually, it didn't work and throw an error.
Here's another try :
@@ -2464,9 +2464,11 @@ {error, notfound} -> {error, ?ERR_EXTENDED(?ERR_NOT_ACCEPTABLE, "invalid-subid")}; {result, #pubsub_subscription{options = Options}} -> - pubsub_subscription:get_options_xform(Lang, Options) + {result, XdataEl} = pubsub_subscription:get_options_xform(Lang, Options), + OptionsEl = {xmlelement, "options", [{"jid", jlib:jid_to_string(Subscriber)}, {"subid", SubID}], [XdataEl]}, + PubsubEl = {xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}], [OptionsEl]}, + {result, PubsubEl} end.The node attribute is missing, I don't know how to convert from NodeID to a node name.
Can you try this patch? It
Can you try this patch? It includes your improvements and the NodeID string. Again, I didn't test it.
--- a/src/mod_pubsub/mod_pubsub.erl +++ b/src/mod_pubsub/mod_pubsub.erl @@ -2464,7 +2464,13 @@ read_sub(Subscriber, NodeID, SubID, Lang) -> {error, notfound} -> {error, ?ERR_EXTENDED(?ERR_NOT_ACCEPTABLE, "invalid-subid")}; {result, #pubsub_subscription{options = Options}} -> - pubsub_subscription:get_options_xform(Lang, Options) + XdataEl = pubsub_subscription:get_options_xform(Lang, Options), + [N] = mnesia:dirty_match_object({pubsub_node,'_',NodeID,'_','_','_','_'}), + {'_',NodeIDStr} = N#pubsub_node.nodeid, + SubscriberStr = jlib:jid_to_string(Subscriber), + OptionsEl = {xmlelement, "options", [{"node", NodeIDStr}, {"jid", SubscriberStr}, {"subid", SubID}], [XdataEl]}, + PubsubEl = {xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}], [OptionsEl]}, + PubsubEl end. set_options(Host, Node, JID, SubID, Configuration) ->We are almost there. This one
We are almost there.
This one works for me:
@@ -2464,9 +2464,15 @@ {error, notfound} -> {error, ?ERR_EXTENDED(?ERR_NOT_ACCEPTABLE, "invalid-subid")}; {result, #pubsub_subscription{options = Options}} -> - pubsub_subscription:get_options_xform(Lang, Options) + {result, XdataEl} = pubsub_subscription:get_options_xform(Lang, Options), + [N] = mnesia:dirty_match_object({pubsub_node,'_',NodeID,'_','_','_','_'}), + {_,Node} = N#pubsub_node.nodeid, + NodeIDStr = node_to_string(Node), + SubscriberStr = jlib:jid_to_string(Subscriber), + OptionsEl = {xmlelement, "options", [{"node", NodeIDStr}, {"jid", SubscriberStr}, {"subid", SubID}], [XdataEl]}, + PubsubEl = {xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}], [OptionsEl]}, + {result, PubsubEl} end. - set_options(Host, Node, JID, SubID, Configuration) -> Action = fun(#pubsub_node{type = Type, id = NodeID}) -> case lists:member("subscription-options", features(Type)) ofPlease note that pubsub_subscription:get_options_xform return a tuple {result, xmlelement}, and read_sub should also return a tuple.
Ok, I've committed that last
Ok, I've committed that last patch to SVN.