From fead37d1c5f26df901b3338655938410067e5926 Mon Sep 17 00:00:00 2001 From: Pablo Polvorin Date: Fri, 27 Jan 2012 16:08:28 -0300 Subject: [PATCH 1/2] Avoid multiple disco#info request for caps. Only send it when we receive the presence from the user, if the user sends caps and we don't have it cached. --- src/mod_caps.erl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mod_caps.erl b/src/mod_caps.erl index b98db6ac7..1f89b6cc3 100644 --- a/src/mod_caps.erl +++ b/src/mod_caps.erl @@ -168,7 +168,11 @@ user_receive_packet(_DebugFlag, #jid{lserver = Server}, From, _To, {xmlelement, "presence", Attrs, Els}) -> Type = xml:get_attr_s("type", Attrs), - if Type == ""; Type == "available" -> + IsRemote = not lists:member(From#jid.lserver, ?MYHOSTS), + %% Local users presence caps are already handled by user_send_packet. + %% Otherwise we could send multiple request when broadcasting presence + %% to every local subscriber. + if IsRemote and ((Type == "") or (Type == "available")) -> case read_caps(Els) of nothing -> ok; From b4d107301d394f20f16ebcfc599502aaffec8771 Mon Sep 17 00:00:00 2001 From: Jerome Sautret Date: Fri, 3 Feb 2012 10:44:49 +0100 Subject: [PATCH 2/2] Added generic sha:to_hexlist/1 API function to convert sha results from binary to hexadecimal string (TECH-1383). --- src/sha.erl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sha.erl b/src/sha.erl index 33a82b889..d98c7848d 100644 --- a/src/sha.erl +++ b/src/sha.erl @@ -1,7 +1,7 @@ %%%---------------------------------------------------------------------- %%% File : sha.erl %%% Author : Alexey Shchepin -%%% Purpose : +%%% Purpose : %%% Created : 20 Dec 2002 by Alexey Shchepin %%% %%% @@ -28,7 +28,7 @@ -author('alexey@process-one.net'). -export([start/0, sha/1, sha1/1, sha224/1, sha256/1, sha384/1, - sha512/1]). + sha512/1, to_hexlist/1]). -ifdef(HAVE_MD2). -export([md2/1]). @@ -61,6 +61,9 @@ digit_to_xchar(D) -> sha(Text) -> Bin = crypto:sha(Text), + to_hexlist(Bin). + +to_hexlist(Bin) -> lists:reverse(ints_to_rxstr(binary_to_list(Bin), [])). ints_to_rxstr([], Res) ->