From b7222c8828b4b634ad9121c485ecb1a94860dfea Mon Sep 17 00:00:00 2001 From: Badlop Date: Wed, 28 Aug 2019 16:09:37 +0200 Subject: [PATCH] Fixed problems detected with Xref and a few more Dialyzer (#277) --- mod_muc_log_http/src/mod_muc_log_http.erl | 4 +-- mod_rest/src/mod_rest.erl | 2 +- mod_shcommands/src/mod_shcommands.erl | 2 +- mod_webpresence/src/mod_webpresence.erl | 31 +++++++---------------- 4 files changed, 13 insertions(+), 26 deletions(-) diff --git a/mod_muc_log_http/src/mod_muc_log_http.erl b/mod_muc_log_http/src/mod_muc_log_http.erl index 098abaa..7f52941 100644 --- a/mod_muc_log_http/src/mod_muc_log_http.erl +++ b/mod_muc_log_http/src/mod_muc_log_http.erl @@ -89,7 +89,7 @@ get_room_pid(Name, Host) -> end. get_room_config(Room_pid) -> - {ok, C} = gen_fsm:sync_send_all_state_event(Room_pid, get_config), + {ok, C} = p1_fsm:sync_send_all_state_event(Room_pid, get_config), C. @@ -99,7 +99,7 @@ get_room_config(Room_pid) -> show_dir_listing(DirName, LocalPath) -> Header = io_lib:format("Name Last modified Size Description~n", []), - Address = io_lib:format("
ejabberd/~s Server
", [ejabberd_config:get_version()]), + Address = io_lib:format("
ejabberd/~s Server
", [ejabberd_config:version()]), {ok, Listing} = file:list_dir(DirName), Listing2 = lists:sort(Listing), diff --git a/mod_rest/src/mod_rest.erl b/mod_rest/src/mod_rest.erl index c434a6a..9dee8be 100644 --- a/mod_rest/src/mod_rest.erl +++ b/mod_rest/src/mod_rest.erl @@ -135,7 +135,7 @@ check_member_option(Host, Element, Option) -> AllowedValues -> lists:member(Element, AllowedValues) end. -ip_matches({Address, Port}, AllowedValues) -> +ip_matches({Address, _Port}, AllowedValues) -> lists:any(fun({Net, Mask}) -> acl:match_acl(global, {ip,{Net,Mask}}, #{ip => Address}) end, diff --git a/mod_shcommands/src/mod_shcommands.erl b/mod_shcommands/src/mod_shcommands.erl index ad9abba..7f66327 100644 --- a/mod_shcommands/src/mod_shcommands.erl +++ b/mod_shcommands/src/mod_shcommands.erl @@ -142,7 +142,7 @@ parse1_command(<<"executeshe">>, {_, _, Command}, Node) -> execute(Type, Node, C) -> GL = group_leader(), - Filename = "temp" ++ io_lib:format("~p", [random:uniform()*10000]), + Filename = <<"temp", (p1_rand:get_string())/binary>>, {ok, File} = file:open(Filename, [write]), group_leader(File, self()), Res = case Type of diff --git a/mod_webpresence/src/mod_webpresence.erl b/mod_webpresence/src/mod_webpresence.erl index aceaee2..66b6533 100644 --- a/mod_webpresence/src/mod_webpresence.erl +++ b/mod_webpresence/src/mod_webpresence.erl @@ -498,25 +498,12 @@ send_message_unregistered(To, Host, Lang) -> send_headline(Host, To, Subject, Body). send_headline(Host, To, Subject, Body) -> - ejabberd_router:route( - jid:make(<<"">>, Host, <<"">>), - To, - #xmlel{ - name = <<"message">>, - attrs = [{<<"type">>, <<"headline">>}], - children = [ - #xmlel{ - name = <<"subject">>, - attrs = [], - children = [{xmlcdata, Subject}] - }, - #xmlel{ - name = <<"body">>, - attrs = [], - children = [{xmlcdata, Body}] - } - ] - }). + Packet = #message{type = headline, + from = jid:make(Host), + to = To, + body = xmpp:mk_text(Body), + subject = xmpp:mk_text(Subject)}, + ejabberd_router:route(Packet). unregister_webpresence(From, Host, Lang) -> remove_user(From#jid.luser, From#jid.lserver), @@ -805,9 +792,9 @@ show_presence({avatar, WP, LUser, LServer}) -> IQ = #iq{type = get, from = JID, to = JID}, IQr = Module:Function(IQ), [VCard] = IQr#iq.sub_els, - Mime = fxml:get_path_s(VCard, [{elem, <<"PHOTO">>}, {elem, <<"TYPE">>}, cdata]), - BinVal = fxml:get_path_s(VCard, [{elem, <<"PHOTO">>}, {elem, <<"BINVAL">>}, cdata]), - Photo = misc:decode_base64(BinVal), + VCard2 = xmpp:decode(VCard), + Mime = (VCard2#vcard_temp.photo)#vcard_photo.type, + Photo = (VCard2#vcard_temp.photo)#vcard_photo.binval, {200, [{"Content-Type", Mime}], Photo}; show_presence({image_example, Theme, Show}) ->