24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-06-02 21:17:12 +02:00

Fix more mod_admin_extra commands

This commit is contained in:
Badlop 2015-03-26 20:41:16 +01:00
parent 9b3dda105d
commit 10dfd182f6

View File

@ -308,10 +308,10 @@ commands() ->
tags = [session], tags = [session],
desc = "Set presence of a session", desc = "Set presence of a session",
module = ?MODULE, function = set_presence, module = ?MODULE, function = set_presence,
args = [{user, string}, {host, string}, args = [{user, binary}, {host, binary},
{resource, string}, {type, string}, {resource, binary}, {type, binary},
{show, string}, {status, string}, {show, binary}, {status, binary},
{priority, string}], {priority, binary}],
result = {res, rescode}}, result = {res, rescode}},
#ejabberd_commands{name = set_nickname, tags = [vcard], #ejabberd_commands{name = set_nickname, tags = [vcard],
@ -546,10 +546,7 @@ commands() ->
%%% %%%
compile(File) -> compile(File) ->
case compile:file(File) of compile:file(File).
ok -> ok;
_ -> error
end.
load_config(Path) -> load_config(Path) ->
ok = ejabberd_config:load_file(Path). ok = ejabberd_config:load_file(Path).
@ -771,7 +768,7 @@ set_random_password(User, Server, Reason) ->
build_random_password(Reason) -> build_random_password(Reason) ->
Date = jlib:timestamp_to_iso(calendar:universal_time()), Date = jlib:timestamp_to_iso(calendar:universal_time()),
RandomString = randoms:get_string(), RandomString = randoms:get_string(),
"BANNED_ACCOUNT--" ++ Date ++ "--" ++ RandomString ++ "--" ++ Reason. <<"BANNED_ACCOUNT--", Date/binary, "--", RandomString/binary, "--", Reason/binary>>.
set_password_auth(User, Server, Password) -> set_password_auth(User, Server, Password) ->
ok = ejabberd_auth:set_password(User, Server, Password). ok = ejabberd_auth:set_password(User, Server, Password).
@ -804,11 +801,9 @@ kick_session(User, Server, Resource, ReasonText) ->
ok. ok.
kick_this_session(User, Server, Resource, Reason) -> kick_this_session(User, Server, Resource, Reason) ->
ejabberd_router:route( ejabberd_sm:route(jlib:make_jid(<<"">>, <<"">>, <<"">>),
jlib:make_jid(<<>>, <<>>, <<>>), jlib:make_jid(User, Server, Resource),
jlib:make_jid(User, Server, Resource), {broadcast, {exit, Reason}}).
{broadcast, {exit, Reason}}).
status_num(Host, Status) -> status_num(Host, Status) ->
length(get_status_list(Host, Status)). length(get_status_list(Host, Status)).
@ -886,8 +881,8 @@ stringize(String) ->
set_presence(User, Host, Resource, Type, Show, Status, Priority) -> set_presence(User, Host, Resource, Type, Show, Status, Priority) ->
Pid = ejabberd_sm:get_session_pid(User, Host, Resource), Pid = ejabberd_sm:get_session_pid(User, Host, Resource),
USR = User ++ "@" ++ Host ++ "/" ++ Resource, USR = jlib:make_jid(User, Host, Resource),
US = User ++ "@" ++ Host, US = jlib:make_jid(User, Host, <<>>),
Message = {route_xmlstreamelement, Message = {route_xmlstreamelement,
{xmlel, <<"presence">>, {xmlel, <<"presence">>,
[{<<"from">>, USR}, {<<"to">>, US}, {<<"type">>, Type}], [{<<"from">>, USR}, {<<"to">>, US}, {<<"type">>, Type}],
@ -1421,8 +1416,8 @@ send_stanza_c2s(Username, Host, Resource, Stanza) ->
p1_fsm:send_event(C2sPid, {xmlstreamelement, XmlEl}). p1_fsm:send_event(C2sPid, {xmlstreamelement, XmlEl}).
privacy_set(Username, Host, QueryS) -> privacy_set(Username, Host, QueryS) ->
From = jlib:string_to_jid(Username ++ "@" ++ Host), From = jlib:make_jid(Username, Host, <<"">>),
To = jlib:string_to_jid(Host), To = jlib:make_jid(<<"">>, Host, <<"">>),
QueryEl = xml_stream:parse_element(QueryS), QueryEl = xml_stream:parse_element(QueryS),
StanzaEl = {xmlel, <<"iq">>, [{<<"type">>, <<"set">>}], [QueryEl]}, StanzaEl = {xmlel, <<"iq">>, [{<<"type">>, <<"set">>}], [QueryEl]},
IQ = jlib:iq_query_info(StanzaEl), IQ = jlib:iq_query_info(StanzaEl),
@ -1534,7 +1529,7 @@ apply_action(delete, Key) ->
mnesia:dirty_delete(roster, Key), mnesia:dirty_delete(roster, Key),
R. R.
print_progress_line({Pr, 0, NV, ND}) -> print_progress_line({_Pr, 0, _NV, _ND}) ->
ok; ok;
print_progress_line({Pr, NT, NV, ND}) -> print_progress_line({Pr, NT, NV, ND}) ->
Pr2 = trunc((NV/NT)*100), Pr2 = trunc((NV/NT)*100),
@ -1592,7 +1587,7 @@ is_regexp_match(String, RegExp) ->
[RegExp, ErrDesc]), [RegExp, ErrDesc]),
false false
end. end.
is_glob_match(String, [$! | Glob]) -> is_glob_match(String, <<"!", Glob/binary>>) ->
not is_regexp_match(String, ejabberd_regexp:sh_to_awk(Glob)); not is_regexp_match(String, ejabberd_regexp:sh_to_awk(Glob));
is_glob_match(String, Glob) -> is_glob_match(String, Glob) ->
is_regexp_match(String, ejabberd_regexp:sh_to_awk(Glob)). is_regexp_match(String, ejabberd_regexp:sh_to_awk(Glob)).