Browse files

* Fixed bloated IQ result stanzas

vertebra_cmd twiddled received IQ set stanzas into IQ result stanzas by changing the to and from attrs.
This caused the stanzas to include waaay more info than needed. This commit cleans this behavior up.
  • Loading branch information...
1 parent 08bcfd5 commit 7d45dd2ad49641b2347c858d678fea62b74bbc1f @ksmith ksmith committed Mar 4, 2009
Showing with 12 additions and 9 deletions.
  1. +12 −9 lib/vertebra/src/vertebra_cmd.erl
View
21 lib/vertebra/src/vertebra_cmd.erl
@@ -132,18 +132,18 @@ handle_info({packet, {xmlelement, "iq", Attrs, [{xmlelement, "final", _, _}=Stan
?ERROR_TRACKING_DISABLED,
proplists:get_value("id", Attrs),
From,
- Stanza),
+ prepare_result_stanza(Stanza)),
#state{client={pid, ClientRef}} = State,
ClientRef ! {xmpp_command_result, From, lists:flatten(State#state.results)},
{stop, normal, State};
handle_info({packet, {xmlelement, "iq", Attrs, [{xmlelement, "error", _, [Reason]}=Stanza]}}, State) ->
From = proplists:get_value("from", Attrs),
vertebra_xmpp:send_result(State#state.connection,
- ?ERROR_TRACKING_DISABLED,
- proplists:get_value("id", Attrs),
- From,
- Stanza),
+ ?ERROR_TRACKING_DISABLED,
+ proplists:get_value("id", Attrs),
+ From,
+ prepare_result_stanza(Stanza)),
#state{client={pid, ClientRef}} = State,
{ok, {string, ReasonDesc}} = xml_util:convert(from, Reason),
ClientRef ! {xmpp_command_result, From, {error, ReasonDesc}},
@@ -152,10 +152,10 @@ handle_info({packet, {xmlelement, "iq", Attrs, [{xmlelement, "error", _, [Reason
handle_info({packet, {xmlelement, "iq", Attrs, [{xmlelement, "data", _, Results}=Result]}}, State) ->
vertebra_xmpp:send_result(State#state.connection,
- ?ERROR_TRACKING_DISABLED,
- proplists:get_value("id", Attrs),
- proplists:get_value("from", Attrs),
- Result),
+ ?ERROR_TRACKING_DISABLED,
+ proplists:get_value("id", Attrs),
+ proplists:get_value("from", Attrs),
+ prepare_result_stanza(Result)),
{noreply, State#state{results=[Results|State#state.results]}};
handle_info({packet, {xmlelement, "iq", Attrs, [{xmlelement, "ack", _, _}=Ack]}}, State) ->
@@ -193,3 +193,6 @@ handle_reply(Reply) ->
Result ->
Result
end.
+
+prepare_result_stanza({xmlelement, Type, Attrs, _}) ->
+ {xmlelement, Type, Attrs, []}.

0 comments on commit 7d45dd2

Please sign in to comment.