mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-28 16:34:13 +01:00
fix invalid response on get_options when no options set (EJAB-1648)
This commit is contained in:
parent
b66e4fbdc4
commit
8621a8f006
@ -3682,26 +3682,33 @@ get_options_helper(JID, Lang, Node, NodeID, SubID, Type) ->
|
|||||||
{error,
|
{error,
|
||||||
extended_error(?ERR_NOT_ACCEPTABLE, <<"subid-required">>)};
|
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.
|
end.
|
||||||
|
|
||||||
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
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, notfound} ->
|
||||||
{error, extended_error(?ERR_NOT_ACCEPTABLE, <<"invalid-subid">>)};
|
[];
|
||||||
{result, #pubsub_subscription{options = Options}} ->
|
{result, #pubsub_subscription{options = Options}} ->
|
||||||
{result, XdataEl} = pubsub_subscription:get_options_xform(Lang, Options),
|
{result, XdataEl} = pubsub_subscription:get_options_xform(Lang, Options),
|
||||||
OptionsEl = #xmlel{name = <<"options">>,
|
[XdataEl]
|
||||||
attrs =
|
end,
|
||||||
[{<<"jid">>, jlib:jid_to_string(Subscriber)},
|
OptionsEl = #xmlel{name = <<"options">>,
|
||||||
{<<"subid">>, SubID}
|
attrs =
|
||||||
| nodeAttr(Node)],
|
[{<<"jid">>, jlib:jid_to_string(Subscriber)},
|
||||||
children = [XdataEl]},
|
{<<"subid">>, SubID}
|
||||||
PubsubEl = #xmlel{name = <<"pubsub">>,
|
| nodeAttr(Node)],
|
||||||
attrs = [{<<"xmlns">>, ?NS_PUBSUB}],
|
children = Children},
|
||||||
children = [OptionsEl]},
|
PubsubEl = #xmlel{name = <<"pubsub">>,
|
||||||
{result, PubsubEl}
|
attrs = [{<<"xmlns">>, ?NS_PUBSUB}],
|
||||||
end.
|
children = [OptionsEl]},
|
||||||
|
{result, PubsubEl}.
|
||||||
|
|
||||||
set_options(Host, Node, JID, SubID, Configuration) ->
|
set_options(Host, Node, JID, SubID, Configuration) ->
|
||||||
Action = fun (#pubsub_node{type = Type, id = NodeID}) ->
|
Action = fun (#pubsub_node{type = Type, id = NodeID}) ->
|
||||||
|
@ -3301,26 +3301,33 @@ get_options_helper(JID, Lang, Node, NodeID, SubID, Type) ->
|
|||||||
{error,
|
{error,
|
||||||
extended_error(?ERR_NOT_ACCEPTABLE, <<"subid-required">>)};
|
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.
|
end.
|
||||||
|
|
||||||
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
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, notfound} ->
|
||||||
{error, extended_error(?ERR_NOT_ACCEPTABLE, <<"invalid-subid">>)};
|
[];
|
||||||
{result, #pubsub_subscription{options = Options}} ->
|
{result, #pubsub_subscription{options = Options}} ->
|
||||||
{result, XdataEl} = pubsub_subscription_odbc:get_options_xform(Lang, Options),
|
{result, XdataEl} = pubsub_subscription_odbc:get_options_xform(Lang, Options),
|
||||||
OptionsEl = #xmlel{name = <<"options">>,
|
[XdataEl]
|
||||||
attrs =
|
end,
|
||||||
[{<<"jid">>, jlib:jid_to_string(Subscriber)},
|
OptionsEl = #xmlel{name = <<"options">>,
|
||||||
{<<"subid">>, SubID}
|
attrs =
|
||||||
| nodeAttr(Node)],
|
[{<<"jid">>, jlib:jid_to_string(Subscriber)},
|
||||||
children = [XdataEl]},
|
{<<"subid">>, SubID}
|
||||||
PubsubEl = #xmlel{name = <<"pubsub">>,
|
| nodeAttr(Node)],
|
||||||
attrs = [{<<"xmlns">>, ?NS_PUBSUB}],
|
children = Children},
|
||||||
children = [OptionsEl]},
|
PubsubEl = #xmlel{name = <<"pubsub">>,
|
||||||
{result, PubsubEl}
|
attrs = [{<<"xmlns">>, ?NS_PUBSUB}],
|
||||||
end.
|
children = [OptionsEl]},
|
||||||
|
{result, PubsubEl}.
|
||||||
|
|
||||||
set_options(Host, Node, JID, SubID, Configuration) ->
|
set_options(Host, Node, JID, SubID, Configuration) ->
|
||||||
Action = fun (#pubsub_node{type = Type, id = NodeID}) ->
|
Action = fun (#pubsub_node{type = Type, id = NodeID}) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user