Switch to newer fast_xml and xmpp and update record fields in the code

This commit is contained in:
Evgeniy Khramtsov 2018-01-25 20:02:47 +03:00
parent 56d4224e08
commit 2269d290d8
12 changed files with 19 additions and 19 deletions

View File

@ -24,8 +24,8 @@
{cache_tab, ".*", {git, "https://github.com/processone/cache_tab", {tag, "1.0.12"}}},
{fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.20"}}},
{stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.10"}}},
{fast_xml, ".*", {git, "https://github.com/processone/fast_xml", {tag, "1.1.28"}}},
{xmpp, ".*", {git, "https://github.com/processone/xmpp", {tag, "1.1.19"}}},
{fast_xml, ".*", {git, "https://github.com/processone/fast_xml", {tag, "dbf173f"}}},
{xmpp, ".*", {git, "https://github.com/processone/xmpp", {tag, "cd4aacf"}}},
{fast_yaml, ".*", {git, "https://github.com/processone/fast_yaml", {tag, "1.0.12"}}},
{jiffy, ".*", {git, "https://github.com/davisp/jiffy", {tag, "0.14.8"}}},
{p1_oauth2, ".*", {git, "https://github.com/processone/p1_oauth2", {tag, "0.6.2"}}},

View File

@ -277,7 +277,7 @@ get_roster(User, Server) ->
get_private(User, Server) ->
case mod_private:get_data(User, Server) of
[_|_] = Els ->
[xmpp:encode(#private{xml_els = Els})];
[xmpp:encode(#private{sub_els = Els})];
_ ->
[]
end.

View File

@ -1461,7 +1461,7 @@ private_get(Username, Host, Element, Ns) ->
ElementXml = #xmlel{name = Element, attrs = [{<<"xmlns">>, Ns}]},
Els = mod_private:get_data(jid:nodeprep(Username), jid:nameprep(Host),
[{Ns, ElementXml}]),
binary_to_list(fxml:element_to_binary(xmpp:encode(#private{xml_els = Els}))).
binary_to_list(fxml:element_to_binary(xmpp:encode(#private{sub_els = Els}))).
private_set(Username, Host, ElementString) ->
case fxml_stream:parse_element(ElementString) of

View File

@ -247,7 +247,7 @@ send_copies(JID, To, Packet, Direction)->
-spec build_forward_packet(jid(), message(), jid(), jid(), direction()) -> message().
build_forward_packet(JID, #message{type = T} = Msg, Sender, Dest, Direction) ->
Forwarded = #forwarded{xml_els = [xmpp:encode(complete_packet(JID, Msg, Direction))]},
Forwarded = #forwarded{sub_els = [complete_packet(JID, Msg, Direction)]},
Carbon = case Direction of
sent -> #carbons_sent{forwarded = Forwarded};
received -> #carbons_received{forwarded = Forwarded}

View File

@ -242,7 +242,7 @@ process_iq(#iq{to = To, lang = Lang, sub_els = [SubEl]} = IQ, Type) ->
case dict:find({NS, Type}, Delegations) of
{ok, {Host, _}} ->
Delegation = #delegation{
forwarded = #forwarded{xml_els = [xmpp:encode(IQ)]}},
forwarded = #forwarded{sub_els = [IQ]}},
NewFrom = jid:make(LServer),
NewTo = jid:make(Host),
ejabberd_router:route_iq(
@ -261,7 +261,7 @@ process_iq(#iq{to = To, lang = Lang, sub_els = [SubEl]} = IQ, Type) ->
process_iq_result(#iq{from = From, to = To, id = ID, lang = Lang} = IQ,
#iq{type = result} = ResIQ) ->
try
#delegation{forwarded = #forwarded{xml_els = [SubEl]}} =
#delegation{forwarded = #forwarded{sub_els = [SubEl]}} =
xmpp:get_subtag(ResIQ, #delegation{}),
case xmpp:decode(SubEl, ?NS_CLIENT, [ignore_els]) of
#iq{from = To, to = From, type = Type, id = ID} = Reply

View File

@ -924,7 +924,7 @@ msg_to_el(#archive_msg{timestamp = TS, packet = El, nick = Nick,
Pkt3 = maybe_update_from_to(
Pkt2, JidRequestor, JidArchive, Peer, MsgType, Nick),
Delay = #delay{stamp = TS, from = jid:make(LServer)},
{ok, #forwarded{xml_els = [xmpp:encode(Pkt3)], delay = Delay}}
{ok, #forwarded{sub_els = [Pkt3], delay = Delay}}
catch _:{xmpp_codec, Why} ->
?ERROR_MSG("Failed to decode raw element ~p from message "
"archive of user ~s: ~s",

View File

@ -4102,7 +4102,7 @@ send_subscriptions_change_notifications(From, Nick, Type, State) ->
node = ?NS_MUCSUB_NODES_SUBSCRIBERS,
items = [#ps_item{
id = randoms:get_string(),
xml_els = [xmpp:encode(Payload)]}]}}]},
sub_els = [Payload]}]}}]},
ejabberd_router:route(xmpp:set_from_to(Packet, From, JID));
false ->
ok
@ -4138,14 +4138,14 @@ send_wrapped(From, To, Packet, Node, State) ->
-spec wrap(jid(), jid(), stanza(), binary()) -> message().
wrap(From, To, Packet, Node) ->
El = xmpp:encode(xmpp:set_from_to(Packet, From, To)),
El = xmpp:set_from_to(Packet, From, To),
#message{
sub_els = [#ps_event{
items = #ps_items{
node = Node,
items = [#ps_item{
id = randoms:get_string(),
xml_els = [El]}]}}]}.
sub_els = [El]}]}}]}.
%% -spec send_multiple(jid(), binary(), [#user{}], stanza()) -> ok.
%% send_multiple(From, Server, Users, Packet) ->

View File

@ -91,7 +91,7 @@ reload(Host, NewOpts, OldOpts) ->
process_sm_iq(#iq{type = Type, lang = Lang,
from = #jid{luser = LUser, lserver = LServer},
to = #jid{luser = LUser, lserver = LServer},
sub_els = [#private{xml_els = Els0}]} = IQ) ->
sub_els = [#private{sub_els = Els0}]} = IQ) ->
case filter_xmlels(Els0) of
[] ->
Txt = <<"No private data found in this query">>,
@ -112,7 +112,7 @@ process_sm_iq(#iq{type = Type, lang = Lang,
Err = xmpp:err_internal_server_error(Txt, Lang),
xmpp:make_error(IQ, Err);
Els ->
xmpp:make_iq_result(IQ, #private{xml_els = Els})
xmpp:make_iq_result(IQ, #private{sub_els = Els})
end
end;
process_sm_iq(#iq{lang = Lang} = IQ) ->

View File

@ -277,7 +277,7 @@ forward_message(#message{to = To} = Msg) ->
ServerHost = To#jid.lserver,
Lang = xmpp:get_lang(Msg),
try xmpp:try_subtag(Msg, #privilege{}) of
#privilege{forwarded = #forwarded{xml_els = [SubEl]}} ->
#privilege{forwarded = #forwarded{sub_els = [SubEl]}} ->
try xmpp:decode(SubEl, ?NS_CLIENT, [ignore_els]) of
#message{} = NewMsg ->
case NewMsg#message.from of

View File

@ -1113,7 +1113,7 @@ iq_pubsub(Host, Access, #iq{from = From, type = IQType, lang = Lang,
publish_options = XData, configure = _, _ = undefined}} ->
ServerHost = serverhost(Host),
case Items of
[#ps_item{id = ItemId, xml_els = Payload}] ->
[#ps_item{id = ItemId, sub_els = Payload}] ->
case decode_publish_options(XData, Lang) of
{error, _} = Err ->
Err;
@ -2659,7 +2659,7 @@ broadcast_publish_item(Host, Node, Nidx, Type, NodeOptions, ItemId, From, Payloa
case get_collection_subscriptions(Host, Node) of
SubsByDepth when is_list(SubsByDepth) ->
EventItem0 = case get_option(NodeOptions, deliver_payloads) of
true -> #ps_item{xml_els = Payload, id = ItemId};
true -> #ps_item{sub_els = Payload, id = ItemId};
false -> #ps_item{id = ItemId}
end,
EventItem = case get_option(NodeOptions, itemreply, none) of
@ -3743,7 +3743,7 @@ uniqid() ->
-spec itemsEls([#pubsub_item{}]) -> [ps_item()].
itemsEls(Items) ->
[#ps_item{id = ItemId, xml_els = Payload}
[#ps_item{id = ItemId, sub_els = Payload}
|| #pubsub_item{itemid = {ItemId, _}, payload = Payload} <- Items].
-spec add_message_type(message(), message_type()) -> message().

View File

@ -446,7 +446,7 @@ notify(LUser, LServer, Clients) ->
fun((iq() | timeout) -> any())) -> ok.
notify(LServer, PushLJID, Node, XData, HandleResponse) ->
From = jid:make(LServer),
Item = #ps_item{xml_els = [xmpp:encode(#push_notification{})]},
Item = #ps_item{sub_els = [#push_notification{}]},
PubSub = #pubsub{publish = #ps_publish{node = Node, items = [Item]},
publish_options = XData},
IQ = #iq{type = set,

View File

@ -72,7 +72,7 @@ log_packet(Packet, Host) ->
ForwardedMsg = #message{from = jid:make(Host),
id = randoms:get_string(),
sub_els = [#forwarded{
xml_els = [xmpp:encode(Packet)]}]},
sub_els = [Packet]}]},
lists:foreach(
fun(Logger) ->
ejabberd_router:route(xmpp:set_to(ForwardedMsg, jid:make(Logger)))