aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristophe Romain <christophe.romain@process-one.net>2013-07-09 18:11:27 +0200
committerChristophe Romain <christophe.romain@process-one.net>2013-07-09 18:11:27 +0200
commit8621a8f0066cd053c209d228c0ff7bddd2039bbc (patch)
tree0568d75342d171912b470d5ecf0abc8b641feff2 /src
parentApparently configure.erl is not needed anymore (diff)
fix invalid response on get_options when no options set (EJAB-1648)
Diffstat (limited to 'src')
-rw-r--r--src/mod_pubsub.erl35
-rw-r--r--src/mod_pubsub_odbc.erl35
2 files changed, 42 insertions, 28 deletions
diff --git a/src/mod_pubsub.erl b/src/mod_pubsub.erl
index bfb971f8c..ba9870d9d 100644
--- a/src/mod_pubsub.erl
+++ b/src/mod_pubsub.erl
@@ -3682,26 +3682,33 @@ get_options_helper(JID, Lang, Node, NodeID, SubID, Type) ->
{error,
extended_error(?ERR_NOT_ACCEPTABLE, <<"subid-required">>)};
{_, _} ->
- read_sub(Subscriber, Node, NodeID, SubID, Lang)
+ ValidSubId = lists:member(SubID, SubIDs),
+ if ValidSubId ->
+ read_sub(Subscriber, Node, NodeID, SubID, Lang);
+ true ->
+ {error,
+ extended_error(?ERR_NOT_ACCEPTABLE, <<"invalid-subid">>)}
+ end
end.
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
- case pubsub_subscription:get_subscription(Subscriber, NodeID, SubID) of
+ Children = case pubsub_subscription:get_subscription(Subscriber, NodeID, SubID) of
{error, notfound} ->
- {error, extended_error(?ERR_NOT_ACCEPTABLE, <<"invalid-subid">>)};
+ [];
{result, #pubsub_subscription{options = Options}} ->
{result, XdataEl} = pubsub_subscription:get_options_xform(Lang, Options),
- OptionsEl = #xmlel{name = <<"options">>,
- attrs =
- [{<<"jid">>, jlib:jid_to_string(Subscriber)},
- {<<"subid">>, SubID}
- | nodeAttr(Node)],
- children = [XdataEl]},
- PubsubEl = #xmlel{name = <<"pubsub">>,
- attrs = [{<<"xmlns">>, ?NS_PUBSUB}],
- children = [OptionsEl]},
- {result, PubsubEl}
- end.
+ [XdataEl]
+ end,
+ OptionsEl = #xmlel{name = <<"options">>,
+ attrs =
+ [{<<"jid">>, jlib:jid_to_string(Subscriber)},
+ {<<"subid">>, SubID}
+ | nodeAttr(Node)],
+ children = Children},
+ PubsubEl = #xmlel{name = <<"pubsub">>,
+ attrs = [{<<"xmlns">>, ?NS_PUBSUB}],
+ children = [OptionsEl]},
+ {result, PubsubEl}.
set_options(Host, Node, JID, SubID, Configuration) ->
Action = fun (#pubsub_node{type = Type, id = NodeID}) ->
diff --git a/src/mod_pubsub_odbc.erl b/src/mod_pubsub_odbc.erl
index 5602b6ef9..6932a8fd6 100644
--- a/src/mod_pubsub_odbc.erl
+++ b/src/mod_pubsub_odbc.erl
@@ -3301,26 +3301,33 @@ get_options_helper(JID, Lang, Node, NodeID, SubID, Type) ->
{error,
extended_error(?ERR_NOT_ACCEPTABLE, <<"subid-required">>)};
{_, _} ->
- read_sub(Subscriber, Node, NodeID, SubID, Lang)
+ ValidSubId = lists:member(SubID, SubIDs),
+ if ValidSubId ->
+ read_sub(Subscriber, Node, NodeID, SubID, Lang);
+ true ->
+ {error,
+ extended_error(?ERR_NOT_ACCEPTABLE, <<"invalid-subid">>)}
+ end
end.
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
- case pubsub_subscription_odbc:get_subscription(Subscriber, NodeID, SubID) of
+ Children = case pubsub_subscription_odbc:get_subscription(Subscriber, NodeID, SubID) of
{error, notfound} ->
- {error, extended_error(?ERR_NOT_ACCEPTABLE, <<"invalid-subid">>)};
+ [];
{result, #pubsub_subscription{options = Options}} ->
{result, XdataEl} = pubsub_subscription_odbc:get_options_xform(Lang, Options),
- OptionsEl = #xmlel{name = <<"options">>,
- attrs =
- [{<<"jid">>, jlib:jid_to_string(Subscriber)},
- {<<"subid">>, SubID}
- | nodeAttr(Node)],
- children = [XdataEl]},
- PubsubEl = #xmlel{name = <<"pubsub">>,
- attrs = [{<<"xmlns">>, ?NS_PUBSUB}],
- children = [OptionsEl]},
- {result, PubsubEl}
- end.
+ [XdataEl]
+ end,
+ OptionsEl = #xmlel{name = <<"options">>,
+ attrs =
+ [{<<"jid">>, jlib:jid_to_string(Subscriber)},
+ {<<"subid">>, SubID}
+ | nodeAttr(Node)],
+ children = Children},
+ PubsubEl = #xmlel{name = <<"pubsub">>,
+ attrs = [{<<"xmlns">>, ?NS_PUBSUB}],
+ children = [OptionsEl]},
+ {result, PubsubEl}.
set_options(Host, Node, JID, SubID, Configuration) ->
Action = fun (#pubsub_node{type = Type, id = NodeID}) ->