mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-26 16:26:24 +01:00
fix subscriptions, subscribe, and configure options (thanks to Karim Gemayel)
This commit is contained in:
parent
7814527e0d
commit
44abf1ff28
@ -1286,7 +1286,7 @@ iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang, Access, Plugins) ->
|
|||||||
end;
|
end;
|
||||||
{set, 'subscribe'} ->
|
{set, 'subscribe'} ->
|
||||||
Config = case Rest of
|
Config = case Rest of
|
||||||
[#xmlel{name = 'configure', children = C}] -> C;
|
[#xmlel{name = 'options', children = C}] -> C;
|
||||||
_ -> []
|
_ -> []
|
||||||
end,
|
end,
|
||||||
JID = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'jid', ""),
|
JID = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'jid', ""),
|
||||||
@ -1312,11 +1312,11 @@ iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang, Access, Plugins) ->
|
|||||||
get_subscriptions(Host, Node, From, Plugins);
|
get_subscriptions(Host, Node, From, Plugins);
|
||||||
{get, 'affiliations'} ->
|
{get, 'affiliations'} ->
|
||||||
get_affiliations(Host, From, Plugins);
|
get_affiliations(Host, From, Plugins);
|
||||||
{get, "options"} ->
|
{get, 'options'} ->
|
||||||
SubID = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'subid', ""),
|
SubID = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'subid', ""),
|
||||||
JID = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'jid', ""),
|
JID = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'jid', ""),
|
||||||
get_options(Host, Node, JID, SubID, Lang);
|
get_options(Host, Node, JID, SubID, Lang);
|
||||||
{set, "options"} ->
|
{set, 'options'} ->
|
||||||
SubID = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'subid', ""),
|
SubID = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'subid', ""),
|
||||||
JID = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'jid', ""),
|
JID = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'jid', ""),
|
||||||
set_options(Host, Node, JID, SubID, Els);
|
set_options(Host, Node, JID, SubID, Els);
|
||||||
@ -2542,16 +2542,16 @@ get_options(Host, Node, JID, SubID, Lang) ->
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
case transaction(Host, Node, Action, sync_dirty) of
|
case transaction(Host, Node, Action, sync_dirty) of
|
||||||
{result, {_Node, XForm}} -> {result, [XForm]};
|
{result, {_Node, XForm}} -> {result, XForm};
|
||||||
Error -> Error
|
Error -> Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
get_options_helper(JID, Lang, Node, NodeID, SubID, Type) ->
|
get_options_helper(JID, Lang, Node, NodeID, SubID, Type) ->
|
||||||
Subscriber = try exmpp_jid:parse(JID) of
|
Subscriber = try exmpp_jid:parse(JID) of
|
||||||
J -> jlib:short_jid(J)
|
J -> J
|
||||||
catch
|
catch
|
||||||
_ ->
|
_ ->
|
||||||
{"", "", ""} %%pablo TODO: "" or <<>> ?. short_jid uses exmpp_jid:node/1, etc. that returns binaries
|
exmpp_jid:make("", "", "")
|
||||||
end,
|
end,
|
||||||
{result, Subs} = node_call(Type, get_subscriptions,
|
{result, Subs} = node_call(Type, get_subscriptions,
|
||||||
[NodeID, Subscriber]),
|
[NodeID, Subscriber]),
|
||||||
@ -2579,7 +2579,7 @@ read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
|||||||
{result, XdataEl} = pubsub_subscription:get_options_xform(Lang, Options),
|
{result, XdataEl} = pubsub_subscription:get_options_xform(Lang, Options),
|
||||||
OptionsEl = #xmlel{ns = ?NS_PUBSUB, name = 'options',
|
OptionsEl = #xmlel{ns = ?NS_PUBSUB, name = 'options',
|
||||||
attrs = [ ?XMLATTR('jid', exmpp_jid:to_binary(Subscriber)),
|
attrs = [ ?XMLATTR('jid', exmpp_jid:to_binary(Subscriber)),
|
||||||
?XMLATTR('Subid', SubID) | nodeAttr(Node)],
|
?XMLATTR('subid', SubID) | nodeAttr(Node)],
|
||||||
children = [XdataEl]},
|
children = [XdataEl]},
|
||||||
PubsubEl = #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children = [OptionsEl]},
|
PubsubEl = #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children = [OptionsEl]},
|
||||||
{result, PubsubEl}
|
{result, PubsubEl}
|
||||||
@ -2608,9 +2608,9 @@ set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
|
|||||||
_ -> invalid
|
_ -> invalid
|
||||||
end,
|
end,
|
||||||
Subscriber = try exmpp_jid:parse(JID) of
|
Subscriber = try exmpp_jid:parse(JID) of
|
||||||
J -> jlib:short_jid(J)
|
J -> J
|
||||||
catch
|
catch
|
||||||
_ -> {"", "", ""} %%pablo TODO: "" or <<>> ?. short_jid uses exmpp_jid:node/1, etc. that returns binaries
|
_ -> exmpp_jid:make("", "", "")
|
||||||
end,
|
end,
|
||||||
{result, Subs} = node_call(Type, get_subscriptions,
|
{result, Subs} = node_call(Type, get_subscriptions,
|
||||||
[NodeID, Subscriber]),
|
[NodeID, Subscriber]),
|
||||||
|
@ -129,7 +129,7 @@ get_options_xform(Lang, Options) ->
|
|||||||
Keys = [deliver, show_values, subscription_type, subscription_depth],
|
Keys = [deliver, show_values, subscription_type, subscription_depth],
|
||||||
XFields = [get_option_xfield(Lang, Key, Options) || Key <- Keys],
|
XFields = [get_option_xfield(Lang, Key, Options) || Key <- Keys],
|
||||||
|
|
||||||
{result, #xmlel{ns = ?NS_DATA_FORMS, name = 'x', children =
|
{result, #xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [?XMLATTR('type', <<"form">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS,
|
[#xmlel{ns = ?NS_DATA_FORMS,
|
||||||
name = 'field',
|
name = 'field',
|
||||||
attrs = [?XMLATTR('var', <<"FORM_TYPE">>), ?XMLATTR('type', <<"hidden">>)],
|
attrs = [?XMLATTR('var', <<"FORM_TYPE">>), ?XMLATTR('type', <<"hidden">>)],
|
||||||
@ -140,7 +140,7 @@ get_options_xform(Lang, Options) ->
|
|||||||
parse_options_xform(XFields) ->
|
parse_options_xform(XFields) ->
|
||||||
case XFields of
|
case XFields of
|
||||||
[] -> {result, []};
|
[] -> {result, []};
|
||||||
_ -> case exmpp_xml:get_child_elements(XFields) of
|
_ -> case exmpp_xml:remove_cdata_from_list(XFields) of
|
||||||
[] -> {result, []};
|
[] -> {result, []};
|
||||||
[#xmlel{name = 'x'} = XEl] ->
|
[#xmlel{name = 'x'} = XEl] ->
|
||||||
case jlib:parse_xdata_submit(XEl) of
|
case jlib:parse_xdata_submit(XEl) of
|
||||||
@ -271,7 +271,7 @@ type_and_options(Type, _Lang) ->
|
|||||||
tr_xfield_options({Value, Label}, Lang) ->
|
tr_xfield_options({Value, Label}, Lang) ->
|
||||||
#xmlel{ns = ?NS_DATA_FORMS,
|
#xmlel{ns = ?NS_DATA_FORMS,
|
||||||
name = 'option',
|
name = 'option',
|
||||||
attrs = [?XMLATTR('label', transalte:translate(Lang, Label))],
|
attrs = [?XMLATTR('label', translate:translate(Lang, Label))],
|
||||||
children = [#xmlel{ns = ?NS_DATA_FORMS,
|
children = [#xmlel{ns = ?NS_DATA_FORMS,
|
||||||
name = 'value',
|
name = 'value',
|
||||||
children = [?XMLCDATA(Value)]}]}.
|
children = [?XMLCDATA(Value)]}]}.
|
||||||
|
Loading…
Reference in New Issue
Block a user