mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Move JID related functions to jid.erl (#847)
This commit is contained in:
parent
7eddfe073b
commit
95265dd3ad
@ -208,13 +208,13 @@ b(S) ->
|
||||
iolist_to_binary(S).
|
||||
|
||||
nodeprep(S) ->
|
||||
jlib:nodeprep(b(S)).
|
||||
jid:nodeprep(b(S)).
|
||||
|
||||
nameprep(S) ->
|
||||
jlib:nameprep(b(S)).
|
||||
jid:nameprep(b(S)).
|
||||
|
||||
resourceprep(S) ->
|
||||
jlib:resourceprep(b(S)).
|
||||
jid:resourceprep(b(S)).
|
||||
|
||||
normalize_spec(Spec) ->
|
||||
case Spec of
|
||||
@ -295,7 +295,7 @@ match_acl(ACL, IP, Host) when tuple_size(IP) == 4;
|
||||
false
|
||||
end, get_aclspecs(ACL, Host));
|
||||
match_acl(ACL, JID, Host) ->
|
||||
{User, Server, Resource} = jlib:jid_tolower(JID),
|
||||
{User, Server, Resource} = jid:tolower(JID),
|
||||
lists:any(
|
||||
fun(#acl{aclspec = Spec}) ->
|
||||
case Spec of
|
||||
|
@ -112,12 +112,12 @@ register_mechanism(Mechanism, Module, PasswordType) ->
|
||||
%%-include("jlib.hrl").
|
||||
%%check_authzid(_State, Props) ->
|
||||
%% AuthzId = xml:get_attr_s(authzid, Props),
|
||||
%% case jlib:string_to_jid(AuthzId) of
|
||||
%% case jid:from_string(AuthzId) of
|
||||
%% error ->
|
||||
%% {error, "invalid-authzid"};
|
||||
%% JID ->
|
||||
%% LUser = jlib:nodeprep(xml:get_attr_s(username, Props)),
|
||||
%% {U, S, R} = jlib:jid_tolower(JID),
|
||||
%% LUser = jid:nodeprep(xml:get_attr_s(username, Props)),
|
||||
%% {U, S, R} = jid:tolower(JID),
|
||||
%% case R of
|
||||
%% "" ->
|
||||
%% {error, "invalid-authzid"};
|
||||
@ -133,7 +133,7 @@ register_mechanism(Mechanism, Module, PasswordType) ->
|
||||
|
||||
check_credentials(_State, Props) ->
|
||||
User = proplists:get_value(username, Props, <<>>),
|
||||
case jlib:nodeprep(User) of
|
||||
case jid:nodeprep(User) of
|
||||
error -> {error, <<"not-authorized">>};
|
||||
<<"">> -> {error, <<"not-authorized">>};
|
||||
_LUser -> ok
|
||||
|
@ -79,7 +79,7 @@ mech_step(#state{step = 2} = State, ClientIn) ->
|
||||
case parse_attribute(ClientNonceAttribute) of
|
||||
{$r, ClientNonce} ->
|
||||
{Ret, _AuthModule} = (State#state.get_password)(UserName),
|
||||
case {Ret, jlib:resourceprep(Ret)} of
|
||||
case {Ret, jid:resourceprep(Ret)} of
|
||||
{false, _} -> {error, <<"not-authorized">>, UserName};
|
||||
{_, error} when is_binary(Ret) -> ?WARNING_MSG("invalid plain password", []), {error, <<"not-authorized">>, UserName};
|
||||
{Ret, _} ->
|
||||
|
@ -43,7 +43,7 @@
|
||||
start(normal, _Args) ->
|
||||
ejabberd_logger:start(),
|
||||
write_pid_file(),
|
||||
jlib:start(),
|
||||
jid:start(),
|
||||
start_apps(),
|
||||
ejabberd:check_app(ejabberd),
|
||||
randoms:start(),
|
||||
|
@ -187,7 +187,7 @@ try_register(User, Server, Password) ->
|
||||
case is_user_exists(User, Server) of
|
||||
true -> {atomic, exists};
|
||||
false ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
case lists:member(LServer, ?MYHOSTS) of
|
||||
true ->
|
||||
Res = lists:foldl(fun (_M, {atomic, ok} = Res) -> Res;
|
||||
@ -358,7 +358,7 @@ remove_user(User, Server) ->
|
||||
lists:foreach(fun (M) -> M:remove_user(User, Server)
|
||||
end,
|
||||
auth_modules(Server)),
|
||||
ejabberd_hooks:run(remove_user, jlib:nameprep(Server),
|
||||
ejabberd_hooks:run(remove_user, jid:nameprep(Server),
|
||||
[User, Server]),
|
||||
ok.
|
||||
|
||||
@ -376,7 +376,7 @@ remove_user(User, Server, Password) ->
|
||||
error, auth_modules(Server)),
|
||||
case R of
|
||||
ok ->
|
||||
ejabberd_hooks:run(remove_user, jlib:nameprep(Server),
|
||||
ejabberd_hooks:run(remove_user, jid:nameprep(Server),
|
||||
[User, Server]);
|
||||
_ -> none
|
||||
end,
|
||||
@ -427,7 +427,7 @@ auth_modules() ->
|
||||
|
||||
%% Return the list of authenticated modules for a given host
|
||||
auth_modules(Server) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
Default = case gen_mod:default_db(LServer) of
|
||||
mnesia -> internal;
|
||||
DBType -> DBType
|
||||
|
@ -122,8 +122,8 @@ allow_multiple_connections(Host) ->
|
||||
|
||||
%% Check if user exist in the anonymus database
|
||||
anonymous_user_exist(User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
US = {LUser, LServer},
|
||||
case catch mnesia:dirty_read({anonymous, US}) of
|
||||
[] ->
|
||||
|
@ -70,7 +70,7 @@ start(Host) ->
|
||||
update_reg_users_counter_table(Server) ->
|
||||
Set = get_vh_registered_users(Server),
|
||||
Size = length(Set),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
F = fun () ->
|
||||
mnesia:write(#reg_users_counter{vhost = LServer,
|
||||
count = Size})
|
||||
@ -87,8 +87,8 @@ store_type() ->
|
||||
end.
|
||||
|
||||
check_password(User, Server, Password) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
US = {LUser, LServer},
|
||||
case catch mnesia:dirty_read({passwd, US}) of
|
||||
[#passwd{password = Password}]
|
||||
@ -102,8 +102,8 @@ check_password(User, Server, Password) ->
|
||||
|
||||
check_password(User, Server, Password, Digest,
|
||||
DigestGen) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
US = {LUser, LServer},
|
||||
case catch mnesia:dirty_read({passwd, US}) of
|
||||
[#passwd{password = Passwd}] when is_binary(Passwd) ->
|
||||
@ -130,8 +130,8 @@ check_password(User, Server, Password, Digest,
|
||||
%% @spec (User::string(), Server::string(), Password::string()) ->
|
||||
%% ok | {error, invalid_jid}
|
||||
set_password(User, Server, Password) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
US = {LUser, LServer},
|
||||
if (LUser == error) or (LServer == error) ->
|
||||
{error, invalid_jid};
|
||||
@ -150,8 +150,8 @@ set_password(User, Server, Password) ->
|
||||
|
||||
%% @spec (User, Server, Password) -> {atomic, ok} | {atomic, exists} | {error, invalid_jid} | {error, not_allowed} | {error, Reason}
|
||||
try_register(User, Server, PasswordList) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
Password = if is_list(PasswordList); is_binary(PasswordList) ->
|
||||
iolist_to_binary(PasswordList);
|
||||
true -> PasswordList
|
||||
@ -185,7 +185,7 @@ dirty_get_registered_users() ->
|
||||
mnesia:dirty_all_keys(passwd).
|
||||
|
||||
get_vh_registered_users(Server) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
mnesia:dirty_select(passwd,
|
||||
[{#passwd{us = '$1', _ = '_'},
|
||||
[{'==', {element, 2, '$1'}, LServer}], ['$1']}]).
|
||||
@ -244,7 +244,7 @@ get_vh_registered_users(Server, _) ->
|
||||
get_vh_registered_users(Server).
|
||||
|
||||
get_vh_registered_users_number(Server) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
Query = mnesia:dirty_select(reg_users_counter,
|
||||
[{#reg_users_counter{vhost = LServer,
|
||||
count = '$1'},
|
||||
@ -265,8 +265,8 @@ get_vh_registered_users_number(Server, _) ->
|
||||
get_vh_registered_users_number(Server).
|
||||
|
||||
get_password(User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
US = {LUser, LServer},
|
||||
case catch mnesia:dirty_read(passwd, US) of
|
||||
[#passwd{password = Password}]
|
||||
@ -282,8 +282,8 @@ get_password(User, Server) ->
|
||||
end.
|
||||
|
||||
get_password_s(User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
US = {LUser, LServer},
|
||||
case catch mnesia:dirty_read(passwd, US) of
|
||||
[#passwd{password = Password}]
|
||||
@ -297,8 +297,8 @@ get_password_s(User, Server) ->
|
||||
|
||||
%% @spec (User, Server) -> true | false | {error, Error}
|
||||
is_user_exists(User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
US = {LUser, LServer},
|
||||
case catch mnesia:dirty_read({passwd, US}) of
|
||||
[] -> false;
|
||||
@ -310,8 +310,8 @@ is_user_exists(User, Server) ->
|
||||
%% @doc Remove user.
|
||||
%% Note: it returns ok even if there was some problem removing the user.
|
||||
remove_user(User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
US = {LUser, LServer},
|
||||
F = fun () ->
|
||||
mnesia:delete({passwd, US}),
|
||||
@ -324,8 +324,8 @@ remove_user(User, Server) ->
|
||||
%% @spec (User, Server, Password) -> ok | not_exists | not_allowed | bad_request
|
||||
%% @doc Remove user if the provided password is correct.
|
||||
remove_user(User, Server, Password) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
US = {LUser, LServer},
|
||||
F = fun () ->
|
||||
case mnesia:read({passwd, US}) of
|
||||
|
@ -228,11 +228,11 @@ get_vh_registered_users_ldap(Server) ->
|
||||
UIDFormat)
|
||||
of
|
||||
{ok, U} ->
|
||||
case jlib:nodeprep(U) of
|
||||
case jid:nodeprep(U) of
|
||||
error -> [];
|
||||
LU ->
|
||||
[{LU,
|
||||
jlib:nameprep(Server)}]
|
||||
jid:nameprep(Server)}]
|
||||
end;
|
||||
_ -> []
|
||||
end
|
||||
|
@ -65,8 +65,8 @@ store_type() ->
|
||||
|
||||
%% @spec (User, Server, Password) -> true | false | {error, Error}
|
||||
check_password(User, Server, Password) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
if (LUser == error) or (LServer == error) ->
|
||||
false;
|
||||
(LUser == <<>>) or (LServer == <<>>) ->
|
||||
@ -115,8 +115,8 @@ check_password(User, Server, Password) ->
|
||||
%% @spec (User, Server, Password, Digest, DigestGen) -> true | false | {error, Error}
|
||||
check_password(User, Server, Password, Digest,
|
||||
DigestGen) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
if (LUser == error) or (LServer == error) ->
|
||||
false;
|
||||
(LUser == <<>>) or (LServer == <<>>) ->
|
||||
@ -151,8 +151,8 @@ check_password(User, Server, Password, Digest,
|
||||
%% @spec (User::string(), Server::string(), Password::string()) ->
|
||||
%% ok | {error, invalid_jid}
|
||||
set_password(User, Server, Password) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
if (LUser == error) or (LServer == error) ->
|
||||
{error, invalid_jid};
|
||||
(LUser == <<>>) or (LServer == <<>>) ->
|
||||
@ -187,8 +187,8 @@ set_password(User, Server, Password) ->
|
||||
|
||||
%% @spec (User, Server, Password) -> {atomic, ok} | {atomic, exists} | {error, invalid_jid}
|
||||
try_register(User, Server, Password) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
if (LUser == error) or (LServer == error) ->
|
||||
{error, invalid_jid};
|
||||
(LUser == <<>>) or (LServer == <<>>) ->
|
||||
@ -228,7 +228,7 @@ dirty_get_registered_users() ->
|
||||
Servers).
|
||||
|
||||
get_vh_registered_users(Server) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
case catch odbc_queries:list_users(LServer) of
|
||||
{selected, [<<"username">>], Res} ->
|
||||
[{U, LServer} || [U] <- Res];
|
||||
@ -236,7 +236,7 @@ get_vh_registered_users(Server) ->
|
||||
end.
|
||||
|
||||
get_vh_registered_users(Server, Opts) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
case catch odbc_queries:list_users(LServer, Opts) of
|
||||
{selected, [<<"username">>], Res} ->
|
||||
[{U, LServer} || [U] <- Res];
|
||||
@ -244,7 +244,7 @@ get_vh_registered_users(Server, Opts) ->
|
||||
end.
|
||||
|
||||
get_vh_registered_users_number(Server) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
case catch odbc_queries:users_number(LServer) of
|
||||
{selected, [_], [[Res]]} ->
|
||||
jlib:binary_to_integer(Res);
|
||||
@ -252,7 +252,7 @@ get_vh_registered_users_number(Server) ->
|
||||
end.
|
||||
|
||||
get_vh_registered_users_number(Server, Opts) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
case catch odbc_queries:users_number(LServer, Opts) of
|
||||
{selected, [_], [[Res]]} ->
|
||||
jlib:binary_to_integer(Res);
|
||||
@ -260,8 +260,8 @@ get_vh_registered_users_number(Server, Opts) ->
|
||||
end.
|
||||
|
||||
get_password(User, Server) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
if (LUser == error) or (LServer == error) ->
|
||||
false;
|
||||
(LUser == <<>>) or (LServer == <<>>) ->
|
||||
@ -291,8 +291,8 @@ get_password(User, Server) ->
|
||||
end.
|
||||
|
||||
get_password_s(User, Server) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
if (LUser == error) or (LServer == error) ->
|
||||
<<"">>;
|
||||
(LUser == <<>>) or (LServer == <<>>) ->
|
||||
@ -311,11 +311,11 @@ get_password_s(User, Server) ->
|
||||
|
||||
%% @spec (User, Server) -> true | false | {error, Error}
|
||||
is_user_exists(User, Server) ->
|
||||
case jlib:nodeprep(User) of
|
||||
case jid:nodeprep(User) of
|
||||
error -> false;
|
||||
LUser ->
|
||||
Username = ejabberd_odbc:escape(LUser),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
try odbc_queries:get_password(LServer, Username) of
|
||||
{selected, [<<"password">>], [[_Password]]} ->
|
||||
true; %% Account exists
|
||||
@ -331,11 +331,11 @@ is_user_exists(User, Server) ->
|
||||
%% @doc Remove user.
|
||||
%% Note: it may return ok even if there was some problem removing the user.
|
||||
remove_user(User, Server) ->
|
||||
case jlib:nodeprep(User) of
|
||||
case jid:nodeprep(User) of
|
||||
error -> error;
|
||||
LUser ->
|
||||
Username = ejabberd_odbc:escape(LUser),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
catch odbc_queries:del_user(LServer, Username),
|
||||
ok
|
||||
end.
|
||||
@ -343,8 +343,8 @@ remove_user(User, Server) ->
|
||||
%% @spec (User, Server, Password) -> ok | error | not_exists | not_allowed
|
||||
%% @doc Remove user if the provided password is correct.
|
||||
remove_user(User, Server, Password) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
if (LUser == error) or (LServer == error) ->
|
||||
error;
|
||||
(LUser == <<>>) or (LServer == <<>>) ->
|
||||
@ -429,7 +429,7 @@ set_password_scram_t(Username,
|
||||
<<"'">>]).
|
||||
|
||||
convert_to_scram(Server) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
if
|
||||
LServer == error;
|
||||
LServer == <<>> ->
|
||||
|
@ -67,8 +67,8 @@ passwd_schema() ->
|
||||
{record_info(fields, passwd), #passwd{}}.
|
||||
|
||||
check_password(User, Server, Password) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
case ejabberd_riak:get(passwd, passwd_schema(), {LUser, LServer}) of
|
||||
{ok, #passwd{password = Password}} when is_binary(Password) ->
|
||||
Password /= <<"">>;
|
||||
@ -80,8 +80,8 @@ check_password(User, Server, Password) ->
|
||||
|
||||
check_password(User, Server, Password, Digest,
|
||||
DigestGen) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
case ejabberd_riak:get(passwd, passwd_schema(), {LUser, LServer}) of
|
||||
{ok, #passwd{password = Passwd}} when is_binary(Passwd) ->
|
||||
DigRes = if Digest /= <<"">> ->
|
||||
@ -105,8 +105,8 @@ check_password(User, Server, Password, Digest,
|
||||
end.
|
||||
|
||||
set_password(User, Server, Password) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
US = {LUser, LServer},
|
||||
if (LUser == error) or (LServer == error) ->
|
||||
{error, invalid_jid};
|
||||
@ -122,8 +122,8 @@ set_password(User, Server, Password) ->
|
||||
end.
|
||||
|
||||
try_register(User, Server, PasswordList) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
Password = if is_list(PasswordList); is_binary(PasswordList) ->
|
||||
iolist_to_binary(PasswordList);
|
||||
true -> PasswordList
|
||||
@ -159,7 +159,7 @@ dirty_get_registered_users() ->
|
||||
end, ejabberd_config:get_vh_by_auth_method(riak)).
|
||||
|
||||
get_vh_registered_users(Server) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
case ejabberd_riak:get_keys_by_index(passwd, <<"host">>, LServer) of
|
||||
{ok, Users} ->
|
||||
Users;
|
||||
@ -171,7 +171,7 @@ get_vh_registered_users(Server, _) ->
|
||||
get_vh_registered_users(Server).
|
||||
|
||||
get_vh_registered_users_number(Server) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
case ejabberd_riak:count_by_index(passwd, <<"host">>, LServer) of
|
||||
{ok, N} ->
|
||||
N;
|
||||
@ -183,8 +183,8 @@ get_vh_registered_users_number(Server, _) ->
|
||||
get_vh_registered_users_number(Server).
|
||||
|
||||
get_password(User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
case ejabberd_riak:get(passwd, passwd_schema(), {LUser, LServer}) of
|
||||
{ok, #passwd{password = Password}}
|
||||
when is_binary(Password) ->
|
||||
@ -199,8 +199,8 @@ get_password(User, Server) ->
|
||||
end.
|
||||
|
||||
get_password_s(User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
case ejabberd_riak:get(passwd, passwd_schema(), {LUser, LServer}) of
|
||||
{ok, #passwd{password = Password}}
|
||||
when is_binary(Password) ->
|
||||
@ -212,8 +212,8 @@ get_password_s(User, Server) ->
|
||||
end.
|
||||
|
||||
is_user_exists(User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
case ejabberd_riak:get(passwd, passwd_schema(), {LUser, LServer}) of
|
||||
{error, notfound} -> false;
|
||||
{ok, _} -> true;
|
||||
@ -221,14 +221,14 @@ is_user_exists(User, Server) ->
|
||||
end.
|
||||
|
||||
remove_user(User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
ejabberd_riak:delete(passwd, {LUser, LServer}),
|
||||
ok.
|
||||
|
||||
remove_user(User, Server, Password) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
case ejabberd_riak:get(passwd, passwd_schema(), {LUser, LServer}) of
|
||||
{ok, #passwd{password = Password}}
|
||||
when is_binary(Password) ->
|
||||
|
@ -224,7 +224,7 @@ del_aux_field(Key, #state{aux_fields = Opts} = State) ->
|
||||
State#state{aux_fields = Opts1}.
|
||||
|
||||
get_subscription(From = #jid{}, StateData) ->
|
||||
get_subscription(jlib:jid_tolower(From), StateData);
|
||||
get_subscription(jid:tolower(From), StateData);
|
||||
get_subscription(LFrom, StateData) ->
|
||||
LBFrom = setelement(3, LFrom, <<"">>),
|
||||
F = (?SETS):is_element(LFrom, StateData#state.pres_f)
|
||||
@ -347,7 +347,7 @@ wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) ->
|
||||
Server =
|
||||
case StateData#state.server of
|
||||
<<"">> ->
|
||||
jlib:nameprep(xml:get_attr_s(<<"to">>, Attrs));
|
||||
jid:nameprep(xml:get_attr_s(<<"to">>, Attrs));
|
||||
S -> S
|
||||
end,
|
||||
Lang = case xml:get_attr_s(<<"xml:lang">>, Attrs) of
|
||||
@ -366,7 +366,7 @@ wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) ->
|
||||
IsBlacklistedIP = is_ip_blacklisted(StateData#state.ip, Lang),
|
||||
case lists:member(Server, ?MYHOSTS) of
|
||||
true when IsBlacklistedIP == false ->
|
||||
change_shaper(StateData, jlib:make_jid(<<"">>, Server, <<"">>)),
|
||||
change_shaper(StateData, jid:make(<<"">>, Server, <<"">>)),
|
||||
case xml:get_attr_s(<<"version">>, Attrs) of
|
||||
<<"1.0">> ->
|
||||
send_header(StateData, Server, <<"1.0">>, DefaultLang),
|
||||
@ -605,7 +605,7 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
|
||||
send_element(StateData, Err),
|
||||
fsm_next_state(wait_for_auth, StateData);
|
||||
{auth, _ID, set, {U, P, D, R}} ->
|
||||
JID = jlib:make_jid(U, StateData#state.server, R),
|
||||
JID = jid:make(U, StateData#state.server, R),
|
||||
case JID /= error andalso
|
||||
acl:match_rule(StateData#state.server,
|
||||
StateData#state.access, JID)
|
||||
@ -622,7 +622,7 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
|
||||
{true, AuthModule} ->
|
||||
?INFO_MSG("(~w) Accepted legacy authentication for ~s by ~p from ~s",
|
||||
[StateData#state.socket,
|
||||
jlib:jid_to_string(JID), AuthModule,
|
||||
jid:to_string(JID), AuthModule,
|
||||
ejabberd_config:may_hide_data(jlib:ip_to_list(StateData#state.ip))]),
|
||||
ejabberd_hooks:run(c2s_auth_result, StateData#state.server,
|
||||
[true, U, StateData#state.server,
|
||||
@ -642,7 +642,7 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
|
||||
StateData#state.server,
|
||||
{[], []},
|
||||
[U, StateData#state.server]),
|
||||
LJID = jlib:jid_tolower(jlib:jid_remove_resource(JID)),
|
||||
LJID = jid:tolower(jid:remove_resource(JID)),
|
||||
Fs1 = [LJID | Fs],
|
||||
Ts1 = [LJID | Ts],
|
||||
PrivList = ejabberd_hooks:run_fold(privacy_get_user_list,
|
||||
@ -661,7 +661,7 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
|
||||
_ ->
|
||||
?INFO_MSG("(~w) Failed legacy authentication for ~s from ~s",
|
||||
[StateData#state.socket,
|
||||
jlib:jid_to_string(JID),
|
||||
jid:to_string(JID),
|
||||
ejabberd_config:may_hide_data(jlib:ip_to_list(StateData#state.ip))]),
|
||||
ejabberd_hooks:run(c2s_auth_result, StateData#state.server,
|
||||
[false, U, StateData#state.server,
|
||||
@ -682,7 +682,7 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
|
||||
?INFO_MSG("(~w) Forbidden legacy authentication "
|
||||
"for ~s from ~s",
|
||||
[StateData#state.socket,
|
||||
jlib:jid_to_string(JID),
|
||||
jid:to_string(JID),
|
||||
ejabberd_config:may_hide_data(jlib:ip_to_list(StateData#state.ip))]),
|
||||
ejabberd_hooks:run(c2s_auth_result, StateData#state.server,
|
||||
[false, U, StateData#state.server,
|
||||
@ -1038,7 +1038,7 @@ wait_for_bind({xmlstreamelement, El}, StateData) ->
|
||||
U = StateData#state.user,
|
||||
R1 = xml:get_path_s(SubEl,
|
||||
[{elem, <<"resource">>}, cdata]),
|
||||
R = case jlib:resourceprep(R1) of
|
||||
R = case jid:resourceprep(R1) of
|
||||
error -> error;
|
||||
<<"">> ->
|
||||
iolist_to_binary([randoms:get_string()
|
||||
@ -1063,7 +1063,7 @@ wait_for_bind({xmlstreamelement, El}, StateData) ->
|
||||
send_element(StateData, Err),
|
||||
fsm_next_state(wait_for_bind, StateData);
|
||||
{accept_resource, R2} ->
|
||||
JID = jlib:make_jid(U, StateData#state.server, R2),
|
||||
JID = jid:make(U, StateData#state.server, R2),
|
||||
Res = IQ#iq{type = result,
|
||||
sub_el =
|
||||
[#xmlel{name = <<"bind">>,
|
||||
@ -1073,7 +1073,7 @@ wait_for_bind({xmlstreamelement, El}, StateData) ->
|
||||
attrs = [],
|
||||
children =
|
||||
[{xmlcdata,
|
||||
jlib:jid_to_string(JID)}]}]}]},
|
||||
jid:to_string(JID)}]}]}]},
|
||||
send_element(StateData, jlib:iq_to_xml(Res)),
|
||||
fsm_next_state(wait_for_session,
|
||||
StateData#state{resource = R2, jid = JID})
|
||||
@ -1108,7 +1108,7 @@ wait_for_session({xmlstreamelement, El}, StateData) ->
|
||||
NewStateData#state.access, JID) of
|
||||
allow ->
|
||||
?INFO_MSG("(~w) Opened session for ~s",
|
||||
[NewStateData#state.socket, jlib:jid_to_string(JID)]),
|
||||
[NewStateData#state.socket, jid:to_string(JID)]),
|
||||
Res = jlib:make_result_iq_reply(El#xmlel{children = []}),
|
||||
NewState = send_stanza(NewStateData, Res),
|
||||
change_shaper(NewState, JID),
|
||||
@ -1117,7 +1117,7 @@ wait_for_session({xmlstreamelement, El}, StateData) ->
|
||||
NewState#state.server,
|
||||
{[], []},
|
||||
[U, NewState#state.server]),
|
||||
LJID = jlib:jid_tolower(jlib:jid_remove_resource(JID)),
|
||||
LJID = jid:tolower(jid:remove_resource(JID)),
|
||||
Fs1 = [LJID | Fs],
|
||||
Ts1 = [LJID | Ts],
|
||||
PrivList =
|
||||
@ -1143,7 +1143,7 @@ wait_for_session({xmlstreamelement, El}, StateData) ->
|
||||
ejabberd_hooks:run(forbidden_session_hook,
|
||||
NewStateData#state.server, [JID]),
|
||||
?INFO_MSG("(~w) Forbidden session for ~s",
|
||||
[NewStateData#state.socket, jlib:jid_to_string(JID)]),
|
||||
[NewStateData#state.socket, jid:to_string(JID)]),
|
||||
Err = jlib:make_error_reply(El, ?ERR_NOT_ALLOWED),
|
||||
send_element(NewStateData, Err),
|
||||
fsm_next_state(wait_for_session, NewStateData)
|
||||
@ -1226,8 +1226,8 @@ session_established2(El, StateData) ->
|
||||
FromJID = NewStateData#state.jid,
|
||||
To = xml:get_attr_s(<<"to">>, Attrs),
|
||||
ToJID = case To of
|
||||
<<"">> -> jlib:make_jid(User, Server, <<"">>);
|
||||
_ -> jlib:string_to_jid(To)
|
||||
<<"">> -> jid:make(User, Server, <<"">>);
|
||||
_ -> jid:from_string(To)
|
||||
end,
|
||||
NewEl1 = jlib:remove_attr(<<"xmlns">>, El),
|
||||
NewEl = case xml:get_attr_s(<<"xml:lang">>, Attrs) of
|
||||
@ -1303,7 +1303,7 @@ wait_for_resume({xmlstreamelement, _El} = Event, StateData) ->
|
||||
fsm_next_state(wait_for_resume, StateData);
|
||||
wait_for_resume(timeout, StateData) ->
|
||||
?DEBUG("Timed out waiting for resumption of stream for ~s",
|
||||
[jlib:jid_to_string(StateData#state.jid)]),
|
||||
[jid:to_string(StateData#state.jid)]),
|
||||
{stop, normal, StateData};
|
||||
wait_for_resume(Event, StateData) ->
|
||||
?DEBUG("Ignoring event while waiting for resumption: ~p", [Event]),
|
||||
@ -1395,7 +1395,7 @@ handle_info({route, _From, _To, {broadcast, Data}},
|
||||
PrivListName}],
|
||||
children = []}]}]},
|
||||
PrivPushEl = jlib:replace_from_to(
|
||||
jlib:jid_remove_resource(StateData#state.jid),
|
||||
jid:remove_resource(StateData#state.jid),
|
||||
StateData#state.jid,
|
||||
jlib:iq_to_xml(PrivPushIQ)),
|
||||
NewState = send_stanza(
|
||||
@ -1423,9 +1423,9 @@ handle_info({route, From, To,
|
||||
Packet}]),
|
||||
case xml:get_attr_s(<<"type">>, Attrs) of
|
||||
<<"probe">> ->
|
||||
LFrom = jlib:jid_tolower(From),
|
||||
LFrom = jid:tolower(From),
|
||||
LBFrom =
|
||||
jlib:jid_remove_resource(LFrom),
|
||||
jid:remove_resource(LFrom),
|
||||
NewStateData = case
|
||||
(?SETS):is_element(LFrom,
|
||||
State#state.pres_a)
|
||||
@ -1468,7 +1468,7 @@ handle_info({route, From, To,
|
||||
{false, Attrs, NewStateData};
|
||||
<<"error">> ->
|
||||
NewA =
|
||||
remove_element(jlib:jid_tolower(From),
|
||||
remove_element(jid:tolower(From),
|
||||
State#state.pres_a),
|
||||
{true, Attrs,
|
||||
State#state{pres_a = NewA}};
|
||||
@ -1504,9 +1504,9 @@ handle_info({route, From, To,
|
||||
of
|
||||
allow ->
|
||||
LFrom =
|
||||
jlib:jid_tolower(From),
|
||||
jid:tolower(From),
|
||||
LBFrom =
|
||||
jlib:jid_remove_resource(LFrom),
|
||||
jid:remove_resource(LFrom),
|
||||
case
|
||||
(?SETS):is_element(LFrom,
|
||||
State#state.pres_a)
|
||||
@ -1557,9 +1557,9 @@ handle_info({route, From, To,
|
||||
IQ = jlib:iq_query_info(Packet),
|
||||
case IQ of
|
||||
#iq{xmlns = ?NS_LAST} ->
|
||||
LFrom = jlib:jid_tolower(From),
|
||||
LFrom = jid:tolower(From),
|
||||
LBFrom =
|
||||
jlib:jid_remove_resource(LFrom),
|
||||
jid:remove_resource(LFrom),
|
||||
HasFromSub =
|
||||
((?SETS):is_element(LFrom,
|
||||
StateData#state.pres_f)
|
||||
@ -1654,8 +1654,8 @@ handle_info({route, From, To,
|
||||
end,
|
||||
if Pass ->
|
||||
Attrs2 =
|
||||
jlib:replace_from_to_attrs(jlib:jid_to_string(From),
|
||||
jlib:jid_to_string(To), NewAttrs),
|
||||
jlib:replace_from_to_attrs(jid:to_string(From),
|
||||
jid:to_string(To), NewAttrs),
|
||||
FixedPacket0 = #xmlel{name = Name, attrs = Attrs2, children = Els},
|
||||
FixedPacket = ejabberd_hooks:run_fold(
|
||||
user_receive_packet,
|
||||
@ -1717,8 +1717,8 @@ handle_info({send_filtered, Feature, From, To, Packet}, StateName, StateData) ->
|
||||
Feature, To, Packet]),
|
||||
NewStateData = if Drop ->
|
||||
?DEBUG("Dropping packet from ~p to ~p",
|
||||
[jlib:jid_to_string(From),
|
||||
jlib:jid_to_string(To)]),
|
||||
[jid:to_string(From),
|
||||
jid:to_string(To)]),
|
||||
StateData;
|
||||
true ->
|
||||
FinalPacket = jlib:replace_from_to(From, To, Packet),
|
||||
@ -1745,7 +1745,7 @@ handle_info({broadcast, Type, From, Packet}, StateName, StateData) ->
|
||||
lists:foreach(
|
||||
fun(USR) ->
|
||||
ejabberd_router:route(
|
||||
From, jlib:make_jid(USR), Packet)
|
||||
From, jid:make(USR), Packet)
|
||||
end, lists:usort(Recipients)),
|
||||
fsm_next_state(StateName, StateData);
|
||||
handle_info(Info, StateName, StateData) ->
|
||||
@ -1761,7 +1761,7 @@ terminate(_Reason, StateName, StateData) ->
|
||||
case StateData#state.mgmt_state of
|
||||
resumed ->
|
||||
?INFO_MSG("Closing former stream of resumed session for ~s",
|
||||
[jlib:jid_to_string(StateData#state.jid)]);
|
||||
[jid:to_string(StateData#state.jid)]);
|
||||
_ ->
|
||||
if StateName == session_established;
|
||||
StateName == wait_for_resume ->
|
||||
@ -1769,7 +1769,7 @@ terminate(_Reason, StateName, StateData) ->
|
||||
replaced ->
|
||||
?INFO_MSG("(~w) Replaced session for ~s",
|
||||
[StateData#state.socket,
|
||||
jlib:jid_to_string(StateData#state.jid)]),
|
||||
jid:to_string(StateData#state.jid)]),
|
||||
From = StateData#state.jid,
|
||||
Packet = #xmlel{name = <<"presence">>,
|
||||
attrs = [{<<"type">>, <<"unavailable">>}],
|
||||
@ -1789,7 +1789,7 @@ terminate(_Reason, StateName, StateData) ->
|
||||
_ ->
|
||||
?INFO_MSG("(~w) Close session for ~s",
|
||||
[StateData#state.socket,
|
||||
jlib:jid_to_string(StateData#state.jid)]),
|
||||
jid:to_string(StateData#state.jid)]),
|
||||
EmptySet = (?SETS):new(),
|
||||
case StateData of
|
||||
#state{pres_last = undefined, pres_a = EmptySet} ->
|
||||
@ -1978,7 +1978,7 @@ get_conn_type(StateData) ->
|
||||
end.
|
||||
|
||||
process_presence_probe(From, To, StateData) ->
|
||||
LFrom = jlib:jid_tolower(From),
|
||||
LFrom = jid:tolower(From),
|
||||
LBFrom = setelement(3, LFrom, <<"">>),
|
||||
case StateData#state.pres_last of
|
||||
undefined ->
|
||||
@ -2076,7 +2076,7 @@ presence_update(From, Packet, StateData) ->
|
||||
%% User sends a directed presence packet
|
||||
presence_track(From, To, Packet, StateData) ->
|
||||
#xmlel{attrs = Attrs} = Packet,
|
||||
LTo = jlib:jid_tolower(To),
|
||||
LTo = jid:tolower(To),
|
||||
User = StateData#state.user,
|
||||
Server = StateData#state.server,
|
||||
case xml:get_attr_s(<<"type">>, Attrs) of
|
||||
@ -2089,14 +2089,14 @@ presence_track(From, To, Packet, StateData) ->
|
||||
ejabberd_hooks:run(roster_out_subscription, Server,
|
||||
[User, Server, To, subscribed]),
|
||||
check_privacy_route(From, StateData,
|
||||
jlib:jid_remove_resource(From), To, Packet);
|
||||
jid:remove_resource(From), To, Packet);
|
||||
<<"unsubscribe">> ->
|
||||
try_roster_subscribe(unsubscribe, User, Server, From, To, Packet, StateData);
|
||||
<<"unsubscribed">> ->
|
||||
ejabberd_hooks:run(roster_out_subscription, Server,
|
||||
[User, Server, To, unsubscribed]),
|
||||
check_privacy_route(From, StateData,
|
||||
jlib:jid_remove_resource(From), To, Packet);
|
||||
jid:remove_resource(From), To, Packet);
|
||||
<<"error">> ->
|
||||
check_privacy_route(From, StateData, From, To, Packet);
|
||||
<<"probe">> ->
|
||||
@ -2139,7 +2139,7 @@ is_privacy_allow(StateData, From, To, Packet, Dir) ->
|
||||
|
||||
%%% Check ACL before allowing to send a subscription stanza
|
||||
try_roster_subscribe(Type, User, Server, From, To, Packet, StateData) ->
|
||||
JID1 = jlib:make_jid(User, Server, <<"">>),
|
||||
JID1 = jid:make(User, Server, <<"">>),
|
||||
Access = gen_mod:get_module_opt(Server, mod_roster, access, fun(A) when is_atom(A) -> A end, all),
|
||||
case acl:match_rule(Server, Access, JID1) of
|
||||
deny ->
|
||||
@ -2149,7 +2149,7 @@ try_roster_subscribe(Type, User, Server, From, To, Packet, StateData) ->
|
||||
ejabberd_hooks:run(roster_out_subscription,
|
||||
Server,
|
||||
[User, Server, To, Type]),
|
||||
check_privacy_route(From, StateData, jlib:jid_remove_resource(From),
|
||||
check_privacy_route(From, StateData, jid:remove_resource(From),
|
||||
To, Packet)
|
||||
end.
|
||||
|
||||
@ -2191,7 +2191,7 @@ presence_broadcast_first(From, StateData, Packet) ->
|
||||
StateData#state{pres_a = As}.
|
||||
|
||||
format_and_check_privacy(From, StateData, Packet, JIDs, Dir) ->
|
||||
FJIDs = [jlib:make_jid(JID) || JID <- JIDs],
|
||||
FJIDs = [jid:make(JID) || JID <- JIDs],
|
||||
lists:filter(
|
||||
fun(FJID) ->
|
||||
case ejabberd_hooks:run_fold(
|
||||
@ -2218,7 +2218,7 @@ remove_element(E, Set) ->
|
||||
end.
|
||||
|
||||
roster_change(IJID, ISubscription, StateData) ->
|
||||
LIJID = jlib:jid_tolower(IJID),
|
||||
LIJID = jid:tolower(IJID),
|
||||
IsFrom = (ISubscription == both) or (ISubscription == from),
|
||||
IsTo = (ISubscription == both) or (ISubscription == to),
|
||||
OldIsFrom = (?SETS):is_element(LIJID, StateData#state.pres_f),
|
||||
@ -2237,7 +2237,7 @@ roster_change(IJID, ISubscription, StateData) ->
|
||||
?DEBUG("roster changed for ~p~n",
|
||||
[StateData#state.user]),
|
||||
From = StateData#state.jid,
|
||||
To = jlib:make_jid(IJID),
|
||||
To = jid:make(IJID),
|
||||
Cond1 = IsFrom andalso not OldIsFrom,
|
||||
Cond2 = not IsFrom andalso OldIsFrom andalso
|
||||
((?SETS):is_element(LIJID, StateData#state.pres_a)),
|
||||
@ -2385,10 +2385,10 @@ process_unauthenticated_stanza(StateData, El) ->
|
||||
empty ->
|
||||
ResIQ = IQ#iq{type = error,
|
||||
sub_el = [?ERR_SERVICE_UNAVAILABLE]},
|
||||
Res1 = jlib:replace_from_to(jlib:make_jid(<<"">>,
|
||||
Res1 = jlib:replace_from_to(jid:make(<<"">>,
|
||||
StateData#state.server,
|
||||
<<"">>),
|
||||
jlib:make_jid(<<"">>, <<"">>,
|
||||
jid:make(<<"">>, <<"">>,
|
||||
<<"">>),
|
||||
jlib:iq_to_xml(ResIQ)),
|
||||
send_element(StateData,
|
||||
@ -2426,7 +2426,7 @@ fsm_next_state_gc(StateName, PackedStateData) ->
|
||||
fsm_next_state(session_established, #state{mgmt_max_queue = exceeded} =
|
||||
StateData) ->
|
||||
?WARNING_MSG("ACK queue too long, terminating session for ~s",
|
||||
[jlib:jid_to_string(StateData#state.jid)]),
|
||||
[jid:to_string(StateData#state.jid)]),
|
||||
Err = ?SERRT_POLICY_VIOLATION(StateData#state.lang,
|
||||
<<"Too many unacked stanzas">>),
|
||||
send_element(StateData, Err),
|
||||
@ -2442,7 +2442,7 @@ fsm_next_state(wait_for_resume, #state{mgmt_timeout = 0} = StateData) ->
|
||||
fsm_next_state(wait_for_resume, #state{mgmt_pending_since = undefined} =
|
||||
StateData) ->
|
||||
?INFO_MSG("Waiting for resumption of stream for ~s",
|
||||
[jlib:jid_to_string(StateData#state.jid)]),
|
||||
[jid:to_string(StateData#state.jid)]),
|
||||
{next_state, wait_for_resume,
|
||||
StateData#state{mgmt_state = pending, mgmt_pending_since = os:timestamp()},
|
||||
StateData#state.mgmt_timeout};
|
||||
@ -2477,7 +2477,7 @@ check_from(El, FromJID) ->
|
||||
false ->
|
||||
El;
|
||||
{value, SJID} ->
|
||||
JID = jlib:string_to_jid(SJID),
|
||||
JID = jid:from_string(SJID),
|
||||
case JID of
|
||||
error ->
|
||||
'invalid-from';
|
||||
@ -2530,7 +2530,7 @@ route_blocking(What, StateData) ->
|
||||
#xmlel{name = <<"item">>,
|
||||
attrs =
|
||||
[{<<"jid">>,
|
||||
jlib:jid_to_string(JID)}],
|
||||
jid:to_string(JID)}],
|
||||
children = []}
|
||||
end,
|
||||
JIDs)};
|
||||
@ -2542,7 +2542,7 @@ route_blocking(What, StateData) ->
|
||||
#xmlel{name = <<"item">>,
|
||||
attrs =
|
||||
[{<<"jid">>,
|
||||
jlib:jid_to_string(JID)}],
|
||||
jid:to_string(JID)}],
|
||||
children = []}
|
||||
end,
|
||||
JIDs)};
|
||||
@ -2552,7 +2552,7 @@ route_blocking(What, StateData) ->
|
||||
end,
|
||||
PrivPushIQ = #iq{type = set, id = <<"push">>, sub_el = [SubEl]},
|
||||
PrivPushEl =
|
||||
jlib:replace_from_to(jlib:jid_remove_resource(StateData#state.jid),
|
||||
jlib:replace_from_to(jid:remove_resource(StateData#state.jid),
|
||||
StateData#state.jid, jlib:iq_to_xml(PrivPushIQ)),
|
||||
%% No need to replace active privacy list here,
|
||||
%% blocking pushes are always accompanied by
|
||||
@ -2653,13 +2653,13 @@ handle_enable(#state{mgmt_timeout = DefaultTimeout,
|
||||
ResAttrs = [{<<"xmlns">>, StateData#state.mgmt_xmlns}] ++
|
||||
if Timeout > 0 ->
|
||||
?INFO_MSG("Stream management with resumption enabled for ~s",
|
||||
[jlib:jid_to_string(StateData#state.jid)]),
|
||||
[jid:to_string(StateData#state.jid)]),
|
||||
[{<<"id">>, make_resume_id(StateData)},
|
||||
{<<"resume">>, <<"true">>},
|
||||
{<<"max">>, jlib:integer_to_binary(Timeout)}];
|
||||
true ->
|
||||
?INFO_MSG("Stream management without resumption enabled for ~s",
|
||||
[jlib:jid_to_string(StateData#state.jid)]),
|
||||
[jid:to_string(StateData#state.jid)]),
|
||||
[]
|
||||
end,
|
||||
Res = #xmlel{name = <<"enabled">>,
|
||||
@ -2685,7 +2685,7 @@ handle_a(StateData, Attrs) ->
|
||||
check_h_attribute(StateData, H);
|
||||
_ ->
|
||||
?DEBUG("Ignoring invalid ACK element from ~s",
|
||||
[jlib:jid_to_string(StateData#state.jid)]),
|
||||
[jid:to_string(StateData#state.jid)]),
|
||||
StateData
|
||||
end.
|
||||
|
||||
@ -2740,7 +2740,7 @@ handle_resume(StateData, Attrs) ->
|
||||
FlushedState = csi_queue_flush(NewState),
|
||||
NewStateData = FlushedState#state{csi_state = active},
|
||||
?INFO_MSG("Resumed session for ~s",
|
||||
[jlib:jid_to_string(NewStateData#state.jid)]),
|
||||
[jid:to_string(NewStateData#state.jid)]),
|
||||
{ok, NewStateData};
|
||||
{error, El, Msg} ->
|
||||
send_element(StateData, El),
|
||||
@ -2752,11 +2752,11 @@ handle_resume(StateData, Attrs) ->
|
||||
check_h_attribute(#state{mgmt_stanzas_out = NumStanzasOut} = StateData, H)
|
||||
when H > NumStanzasOut ->
|
||||
?DEBUG("~s acknowledged ~B stanzas, but only ~B were sent",
|
||||
[jlib:jid_to_string(StateData#state.jid), H, NumStanzasOut]),
|
||||
[jid:to_string(StateData#state.jid), H, NumStanzasOut]),
|
||||
mgmt_queue_drop(StateData#state{mgmt_stanzas_out = H}, NumStanzasOut);
|
||||
check_h_attribute(#state{mgmt_stanzas_out = NumStanzasOut} = StateData, H) ->
|
||||
?DEBUG("~s acknowledged ~B of ~B stanzas",
|
||||
[jlib:jid_to_string(StateData#state.jid), H, NumStanzasOut]),
|
||||
[jid:to_string(StateData#state.jid), H, NumStanzasOut]),
|
||||
mgmt_queue_drop(StateData, H).
|
||||
|
||||
update_num_stanzas_in(#state{mgmt_state = active} = StateData, El) ->
|
||||
@ -2823,13 +2823,13 @@ handle_unacked_stanzas(StateData, F)
|
||||
ok;
|
||||
N ->
|
||||
?INFO_MSG("~B stanzas were not acknowledged by ~s",
|
||||
[N, jlib:jid_to_string(StateData#state.jid)]),
|
||||
[N, jid:to_string(StateData#state.jid)]),
|
||||
lists:foreach(
|
||||
fun({_, Time, #xmlel{attrs = Attrs} = El}) ->
|
||||
From_s = xml:get_attr_s(<<"from">>, Attrs),
|
||||
From = jlib:string_to_jid(From_s),
|
||||
From = jid:from_string(From_s),
|
||||
To_s = xml:get_attr_s(<<"to">>, Attrs),
|
||||
To = jlib:string_to_jid(To_s),
|
||||
To = jid:from_string(To_s),
|
||||
F(From, To, El, Time)
|
||||
end, queue:to_list(Queue))
|
||||
end;
|
||||
@ -2863,7 +2863,7 @@ handle_unacked_stanzas(StateData)
|
||||
end,
|
||||
F = fun(From, _To, #xmlel{name = <<"presence">>}, _Time) ->
|
||||
?DEBUG("Dropping presence stanza from ~s",
|
||||
[jlib:jid_to_string(From)]);
|
||||
[jid:to_string(From)]);
|
||||
(From, To, #xmlel{name = <<"iq">>} = El, _Time) ->
|
||||
Err = jlib:make_error_reply(El, ?ERR_SERVICE_UNAVAILABLE),
|
||||
ejabberd_router:route(To, From, Err);
|
||||
@ -2986,7 +2986,7 @@ csi_filter_stanza(#state{csi_state = CsiState, jid = JID} = StateData,
|
||||
StateData#state.server,
|
||||
send, [Stanza]),
|
||||
?DEBUG("Going to ~p stanza for inactive client ~p",
|
||||
[Action, jlib:jid_to_string(JID)]),
|
||||
[Action, jid:to_string(JID)]),
|
||||
case Action of
|
||||
queue -> csi_queue_add(StateData, Stanza);
|
||||
drop -> StateData;
|
||||
@ -3021,7 +3021,7 @@ csi_queue_send(#state{csi_queue = Queue, csi_state = CsiState, server = Host} =
|
||||
|
||||
csi_queue_flush(#state{csi_queue = Queue, csi_state = CsiState, jid = JID,
|
||||
server = Host} = StateData) ->
|
||||
?DEBUG("Flushing CSI queue for ~s", [jlib:jid_to_string(JID)]),
|
||||
?DEBUG("Flushing CSI queue for ~s", [jid:to_string(JID)]),
|
||||
NewStateData =
|
||||
lists:foldl(fun({_From, Time, Stanza}, AccState) ->
|
||||
NewStanza =
|
||||
|
@ -88,7 +88,7 @@ create_captcha(SID, From, To, Lang, Limiter, Args) ->
|
||||
{ok, Type, Key, Image} ->
|
||||
Id = <<(randoms:get_string())/binary>>,
|
||||
B64Image = jlib:encode_base64((Image)),
|
||||
JID = jlib:jid_to_string(From),
|
||||
JID = jid:to_string(From),
|
||||
CID = <<"sha1+", (p1_sha:sha(Image))/binary,
|
||||
"@bob.xmpp.org">>,
|
||||
Data = #xmlel{name = <<"data">>,
|
||||
@ -109,7 +109,7 @@ create_captcha(SID, From, To, Lang, Limiter, Args) ->
|
||||
{xmlcdata, ?NS_CAPTCHA}),
|
||||
?VFIELD(<<"hidden">>, <<"from">>,
|
||||
{xmlcdata,
|
||||
jlib:jid_to_string(To)}),
|
||||
jid:to_string(To)}),
|
||||
?VFIELD(<<"hidden">>,
|
||||
<<"challenge">>,
|
||||
{xmlcdata, Id}),
|
||||
@ -233,7 +233,7 @@ create_captcha_x(SID, To, Lang, Limiter, HeadEls,
|
||||
[{xmlcdata,
|
||||
Imageurl}]}]},
|
||||
?VFIELD(<<"hidden">>, <<"from">>,
|
||||
{xmlcdata, jlib:jid_to_string(To)}),
|
||||
{xmlcdata, jid:to_string(To)}),
|
||||
?VFIELD(<<"hidden">>, <<"challenge">>,
|
||||
{xmlcdata, Id}),
|
||||
?VFIELD(<<"hidden">>, <<"sid">>,
|
||||
|
@ -514,7 +514,7 @@ check_access2(?POLICY_ACCESS, _User, _Server) ->
|
||||
true;
|
||||
check_access2(Access, User, Server) ->
|
||||
%% Check this user has access permission
|
||||
case acl:match_rule(Server, Access, jlib:make_jid(User, Server, <<"">>)) of
|
||||
case acl:match_rule(Server, Access, jid:make(User, Server, <<"">>)) of
|
||||
allow -> true;
|
||||
deny -> false
|
||||
end.
|
||||
@ -597,7 +597,7 @@ is_admin(Name, {User, Server, _, true} = Auth) ->
|
||||
fun(A) when is_atom(A) -> A end,
|
||||
none),
|
||||
case acl:match_rule(Server, AdminAccess,
|
||||
jlib:make_jid(User, Server, <<"">>)) of
|
||||
jid:make(User, Server, <<"">>)) of
|
||||
allow ->
|
||||
case catch check_auth(get_command_definition(Name), Auth) of
|
||||
{ok, _, _} -> true;
|
||||
|
@ -306,7 +306,7 @@ normalize_hosts(Hosts) ->
|
||||
normalize_hosts([], PrepHosts) ->
|
||||
lists:reverse(PrepHosts);
|
||||
normalize_hosts([Host|Hosts], PrepHosts) ->
|
||||
case jlib:nodeprep(iolist_to_binary(Host)) of
|
||||
case jid:nodeprep(iolist_to_binary(Host)) of
|
||||
error ->
|
||||
?ERROR_MSG("Can't load config file: "
|
||||
"invalid host name [~p]", [Host]),
|
||||
|
@ -232,7 +232,7 @@ process_request(Data, IP, HOpts) ->
|
||||
"dressing' xmlns='",
|
||||
(?NS_HTTP_BIND)/binary, "'/>">>};
|
||||
XmppDomain ->
|
||||
NXmppDomain = jlib:nameprep(XmppDomain),
|
||||
NXmppDomain = jid:nameprep(XmppDomain),
|
||||
Sid = p1_sha:sha(term_to_binary({now(), make_ref()})),
|
||||
case start(NXmppDomain, Sid, <<"">>, IP, HOpts) of
|
||||
{error, _} ->
|
||||
|
@ -125,7 +125,7 @@ get_client_identity(Client, Ctx) -> {ok, {Ctx, {client, Client}}}.
|
||||
verify_redirection_uri(_, _, Ctx) -> {ok, Ctx}.
|
||||
|
||||
authenticate_user({User, Server}, {password, Password} = Ctx) ->
|
||||
case jlib:make_jid(User, Server, <<"">>) of
|
||||
case jid:make(User, Server, <<"">>) of
|
||||
#jid{} = JID ->
|
||||
Access =
|
||||
ejabberd_config:get_option(
|
||||
@ -173,8 +173,8 @@ associate_access_token(AccessToken, Context, AppContext) ->
|
||||
proplists:get_value(<<"resource_owner">>, Context, <<"">>),
|
||||
Scope = proplists:get_value(<<"scope">>, Context, []),
|
||||
Expire = proplists:get_value(<<"expiry_time">>, Context, 0),
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
R = #oauth_token{
|
||||
token = AccessToken,
|
||||
us = {LUser, LServer},
|
||||
@ -190,8 +190,8 @@ associate_refresh_token(RefreshToken, Context, AppContext) ->
|
||||
|
||||
|
||||
check_token(User, Server, Scope, Token) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
case catch mnesia:dirty_read(oauth_token, Token) of
|
||||
[#oauth_token{us = {LUser, LServer},
|
||||
scope = TokenScope,
|
||||
|
@ -242,7 +242,7 @@ export_users([], _Server, _Fd) ->
|
||||
%%%% Utilities
|
||||
export_user(User, Server, Fd) ->
|
||||
Password = ejabberd_auth:get_password_s(User, Server),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
PasswordFormat = ejabberd_config:get_option({auth_password_format, LServer}, fun(X) -> X end, plain),
|
||||
Pass = case Password of
|
||||
{_,_,_,_} ->
|
||||
@ -281,7 +281,7 @@ parse_scram_password(PassData) ->
|
||||
}.
|
||||
|
||||
get_vcard(User, Server) ->
|
||||
JID = jlib:make_jid(User, Server, <<>>),
|
||||
JID = jid:make(User, Server, <<>>),
|
||||
case mod_vcard:process_sm_iq(JID, JID, #iq{type = get}) of
|
||||
#iq{type = result, sub_el = [_|_] = VCardEls} ->
|
||||
VCardEls;
|
||||
@ -335,7 +335,7 @@ get_privacy(User, Server) ->
|
||||
|
||||
%% @spec (Dir::string(), Hosts::[string()]) -> ok
|
||||
get_roster(User, Server) ->
|
||||
JID = jlib:make_jid(User, Server, <<>>),
|
||||
JID = jid:make(User, Server, <<>>),
|
||||
case mod_roster:get_roster(User, Server) of
|
||||
[_|_] = Items ->
|
||||
Subs =
|
||||
@ -349,8 +349,8 @@ get_roster(User, Server) ->
|
||||
[#xmlel{name = <<"presence">>,
|
||||
attrs =
|
||||
[{<<"from">>,
|
||||
jlib:jid_to_string(R#roster.jid)},
|
||||
{<<"to">>, jlib:jid_to_string(JID)},
|
||||
jid:to_string(R#roster.jid)},
|
||||
{<<"to">>, jid:to_string(JID)},
|
||||
{<<"xmlns">>, <<"jabber:client">>},
|
||||
{<<"type">>, <<"subscribe">>}],
|
||||
children =
|
||||
@ -444,7 +444,7 @@ process_el({xmlstreamelement, #xmlel{name = <<"host">>,
|
||||
attrs = Attrs,
|
||||
children = Els}}, State) ->
|
||||
JIDS = xml:get_attr_s(<<"jid">>, Attrs),
|
||||
case jlib:string_to_jid(JIDS) of
|
||||
case jid:from_string(JIDS) of
|
||||
#jid{lserver = S} ->
|
||||
case lists:member(S, ?MYHOSTS) of
|
||||
true ->
|
||||
@ -499,7 +499,7 @@ process_user(#xmlel{name = <<"user">>, attrs = Attrs, children = Els},
|
||||
_ -> Password
|
||||
end,
|
||||
|
||||
case jlib:nodeprep(Name) of
|
||||
case jid:nodeprep(Name) of
|
||||
error ->
|
||||
stop("Invalid 'user': ~s", [Name]);
|
||||
LUser ->
|
||||
@ -579,7 +579,7 @@ process_roster(El, State = #state{user = U, server = S}) ->
|
||||
%%%==================================
|
||||
%%%% Export server
|
||||
process_privacy(El, State = #state{user = U, server = S}) ->
|
||||
JID = jlib:make_jid(U, S, <<"">>),
|
||||
JID = jid:make(U, S, <<"">>),
|
||||
case mod_privacy:process_iq_set(
|
||||
[], JID, JID, #iq{type = set, sub_el = El}) of
|
||||
{error, Error} = Err ->
|
||||
@ -605,7 +605,7 @@ process_privacy(El, State = #state{user = U, server = S}) ->
|
||||
|
||||
%% @spec (Dir::string()) -> ok
|
||||
process_private(El, State = #state{user = U, server = S}) ->
|
||||
JID = jlib:make_jid(U, S, <<"">>),
|
||||
JID = jid:make(U, S, <<"">>),
|
||||
case mod_private:process_sm_iq(
|
||||
JID, JID, #iq{type = set, sub_el = El}) of
|
||||
#iq{type = result} ->
|
||||
@ -617,7 +617,7 @@ process_private(El, State = #state{user = U, server = S}) ->
|
||||
%%%==================================
|
||||
%%%% Export host
|
||||
process_vcard(El, State = #state{user = U, server = S}) ->
|
||||
JID = jlib:make_jid(U, S, <<"">>),
|
||||
JID = jid:make(U, S, <<"">>),
|
||||
case mod_vcard:process_sm_iq(
|
||||
JID, JID, #iq{type = set, sub_el = El}) of
|
||||
#iq{type = result} ->
|
||||
@ -629,9 +629,9 @@ process_vcard(El, State = #state{user = U, server = S}) ->
|
||||
%% @spec (Dir::string(), Host::string()) -> ok
|
||||
process_offline_msg(El, State = #state{user = U, server = S}) ->
|
||||
FromS = xml:get_attr_s(<<"from">>, El#xmlel.attrs),
|
||||
case jlib:string_to_jid(FromS) of
|
||||
case jid:from_string(FromS) of
|
||||
#jid{} = From ->
|
||||
To = jlib:make_jid(U, S, <<>>),
|
||||
To = jid:make(U, S, <<>>),
|
||||
NewEl = jlib:replace_from_to(From, To, El),
|
||||
case catch mod_offline:store_packet(From, To, NewEl) of
|
||||
{'EXIT', _} = Err ->
|
||||
@ -646,9 +646,9 @@ process_offline_msg(El, State = #state{user = U, server = S}) ->
|
||||
%% @spec (Dir::string(), Fn::string(), Host::string()) -> ok
|
||||
process_presence(El, #state{user = U, server = S} = State) ->
|
||||
FromS = xml:get_attr_s(<<"from">>, El#xmlel.attrs),
|
||||
case jlib:string_to_jid(FromS) of
|
||||
case jid:from_string(FromS) of
|
||||
#jid{} = From ->
|
||||
To = jlib:make_jid(U, S, <<>>),
|
||||
To = jid:make(U, S, <<>>),
|
||||
NewEl = jlib:replace_from_to(From, To, El),
|
||||
ejabberd_router:route(From, To, NewEl),
|
||||
{ok, State};
|
||||
|
@ -75,7 +75,7 @@ start_odbc(Host, App) ->
|
||||
|
||||
%% Returns {true, App} if we have configured odbc for the given host
|
||||
needs_odbc(Host) ->
|
||||
LHost = jlib:nameprep(Host),
|
||||
LHost = jid:nameprep(Host),
|
||||
case ejabberd_config:get_option({odbc_type, LHost},
|
||||
fun(mysql) -> mysql;
|
||||
(pgsql) -> pgsql;
|
||||
|
@ -99,7 +99,7 @@ register_route(Domain) ->
|
||||
-spec register_route(binary(), local_hint()) -> term().
|
||||
|
||||
register_route(Domain, LocalHint) ->
|
||||
case jlib:nameprep(Domain) of
|
||||
case jid:nameprep(Domain) of
|
||||
error -> erlang:error({invalid_domain, Domain});
|
||||
LDomain ->
|
||||
Pid = self(),
|
||||
@ -161,7 +161,7 @@ register_routes(Domains) ->
|
||||
-spec unregister_route(binary()) -> term().
|
||||
|
||||
unregister_route(Domain) ->
|
||||
case jlib:nameprep(Domain) of
|
||||
case jid:nameprep(Domain) of
|
||||
error -> erlang:error({invalid_domain, Domain});
|
||||
LDomain ->
|
||||
Pid = self(),
|
||||
@ -349,12 +349,12 @@ do_route(OrigFrom, OrigTo, OrigPacket) ->
|
||||
of
|
||||
undefined -> now();
|
||||
random -> now();
|
||||
source -> jlib:jid_tolower(From);
|
||||
destination -> jlib:jid_tolower(To);
|
||||
source -> jid:tolower(From);
|
||||
destination -> jid:tolower(To);
|
||||
bare_source ->
|
||||
jlib:jid_remove_resource(jlib:jid_tolower(From));
|
||||
jid:remove_resource(jid:tolower(From));
|
||||
bare_destination ->
|
||||
jlib:jid_remove_resource(jlib:jid_tolower(To))
|
||||
jid:remove_resource(jid:tolower(To))
|
||||
end,
|
||||
case get_component_number(LDstDomain) of
|
||||
undefined ->
|
||||
|
@ -69,7 +69,7 @@ route_multicast(From, Domain, Destinations, Packet) ->
|
||||
end.
|
||||
|
||||
register_route(Domain) ->
|
||||
case jlib:nameprep(Domain) of
|
||||
case jid:nameprep(Domain) of
|
||||
error ->
|
||||
erlang:error({invalid_domain, Domain});
|
||||
LDomain ->
|
||||
@ -82,7 +82,7 @@ register_route(Domain) ->
|
||||
end.
|
||||
|
||||
unregister_route(Domain) ->
|
||||
case jlib:nameprep(Domain) of
|
||||
case jid:nameprep(Domain) of
|
||||
error ->
|
||||
erlang:error({invalid_domain, Domain});
|
||||
LDomain ->
|
||||
@ -209,9 +209,9 @@ code_change(_OldVsn, State, _Extra) ->
|
||||
do_route(From, Domain, Destinations, Packet) ->
|
||||
|
||||
?DEBUG("route_multicast~n\tfrom ~s~n\tdomain ~s~n\tdestinations ~p~n\tpacket ~p~n",
|
||||
[jlib:jid_to_string(From),
|
||||
[jid:to_string(From),
|
||||
Domain,
|
||||
[jlib:jid_to_string(To) || To <- Destinations],
|
||||
[jid:to_string(To) || To <- Destinations],
|
||||
Packet]),
|
||||
|
||||
%% Try to find an appropriate multicast service
|
||||
|
@ -311,8 +311,8 @@ do_route(From, To, Packet) ->
|
||||
#xmlel{name = Name, attrs = Attrs, children = Els} =
|
||||
Packet,
|
||||
NewAttrs =
|
||||
jlib:replace_from_to_attrs(jlib:jid_to_string(From),
|
||||
jlib:jid_to_string(To), Attrs),
|
||||
jlib:replace_from_to_attrs(jid:to_string(From),
|
||||
jid:to_string(To), Attrs),
|
||||
#jid{lserver = MyServer} = From,
|
||||
ejabberd_hooks:run(s2s_send_packet, MyServer,
|
||||
[From, To, Packet]),
|
||||
@ -386,7 +386,7 @@ choose_pid(From, Pids) ->
|
||||
Ps -> Ps
|
||||
end,
|
||||
Pid =
|
||||
lists:nth(erlang:phash(jlib:jid_remove_resource(From),
|
||||
lists:nth(erlang:phash(jid:remove_resource(From),
|
||||
length(Pids1)),
|
||||
Pids1),
|
||||
?DEBUG("Using ejabberd_s2s_out ~p~n", [Pid]),
|
||||
@ -431,7 +431,7 @@ new_connection(MyServer, Server, From, FromTo,
|
||||
|
||||
max_s2s_connections_number({From, To}) ->
|
||||
case acl:match_rule(From, max_s2s_connections,
|
||||
jlib:make_jid(<<"">>, To, <<"">>))
|
||||
jid:make(<<"">>, To, <<"">>))
|
||||
of
|
||||
Max when is_integer(Max) -> Max;
|
||||
_ -> ?DEFAULT_MAX_S2S_CONNECTIONS_NUMBER
|
||||
@ -439,7 +439,7 @@ max_s2s_connections_number({From, To}) ->
|
||||
|
||||
max_s2s_connections_number_per_node({From, To}) ->
|
||||
case acl:match_rule(From, max_s2s_connections_per_node,
|
||||
jlib:make_jid(<<"">>, To, <<"">>))
|
||||
jid:make(<<"">>, To, <<"">>))
|
||||
of
|
||||
Max when is_integer(Max) -> Max;
|
||||
_ -> ?DEFAULT_MAX_S2S_CONNECTIONS_NUMBER_PER_NODE
|
||||
@ -550,7 +550,7 @@ allow_host1(MyHost, S2SHost) ->
|
||||
s2s_access,
|
||||
fun(A) when is_atom(A) -> A end,
|
||||
all),
|
||||
JID = jlib:make_jid(<<"">>, S2SHost, <<"">>),
|
||||
JID = jid:make(<<"">>, S2SHost, <<"">>),
|
||||
case acl:match_rule(MyHost, Rule, JID) of
|
||||
deny -> false;
|
||||
allow ->
|
||||
@ -639,7 +639,7 @@ get_cert_domains(Cert) ->
|
||||
true -> error
|
||||
end,
|
||||
if D /= error ->
|
||||
case jlib:string_to_jid(D) of
|
||||
case jid:from_string(D) of
|
||||
#jid{luser = <<"">>, lserver = LD,
|
||||
lresource = <<"">>} ->
|
||||
[LD];
|
||||
@ -675,7 +675,7 @@ get_cert_domains(Cert) ->
|
||||
when
|
||||
is_binary(D) ->
|
||||
case
|
||||
jlib:string_to_jid((D))
|
||||
jid:from_string((D))
|
||||
of
|
||||
#jid{luser =
|
||||
<<"">>,
|
||||
@ -698,7 +698,7 @@ get_cert_domains(Cert) ->
|
||||
({dNSName, D})
|
||||
when is_list(D) ->
|
||||
case
|
||||
jlib:string_to_jid(list_to_binary(D))
|
||||
jid:from_string(list_to_binary(D))
|
||||
of
|
||||
#jid{luser = <<"">>,
|
||||
lserver = LD,
|
||||
|
@ -199,7 +199,7 @@ wait_for_stream({xmlstreamstart, _Name, Attrs},
|
||||
send_text(StateData,
|
||||
?STREAM_HEADER(<<" version='1.0'">>)),
|
||||
Auth = if StateData#state.tls_enabled ->
|
||||
case jlib:nameprep(xml:get_attr_s(<<"from">>, Attrs)) of
|
||||
case jid:nameprep(xml:get_attr_s(<<"from">>, Attrs)) of
|
||||
From when From /= <<"">>, From /= error ->
|
||||
{Result, Message} =
|
||||
ejabberd_s2s:check_peer_certificate(StateData#state.sockmod,
|
||||
@ -360,7 +360,7 @@ wait_for_feature_request({xmlstreamelement, El},
|
||||
?INFO_MSG("Accepted s2s EXTERNAL authentication for ~s (TLS=~p)",
|
||||
[AuthDomain, StateData#state.tls_enabled]),
|
||||
change_shaper(StateData, <<"">>,
|
||||
jlib:make_jid(<<"">>, AuthDomain, <<"">>)),
|
||||
jid:make(<<"">>, AuthDomain, <<"">>)),
|
||||
{next_state, wait_for_stream,
|
||||
StateData#state{streamid = new_id(),
|
||||
authenticated = true}};
|
||||
@ -403,8 +403,8 @@ stream_established({xmlstreamelement, El}, StateData) ->
|
||||
case is_key_packet(El) of
|
||||
{key, To, From, Id, Key} ->
|
||||
?DEBUG("GET KEY: ~p", [{To, From, Id, Key}]),
|
||||
LTo = jlib:nameprep(To),
|
||||
LFrom = jlib:nameprep(From),
|
||||
LTo = jid:nameprep(To),
|
||||
LFrom = jid:nameprep(From),
|
||||
case {ejabberd_s2s:allow_host(LTo, LFrom),
|
||||
lists:member(LTo,
|
||||
ejabberd_router:dirty_get_all_domains())}
|
||||
@ -418,7 +418,7 @@ stream_established({xmlstreamelement, El}, StateData) ->
|
||||
wait_for_verification,
|
||||
StateData#state.connections),
|
||||
change_shaper(StateData, LTo,
|
||||
jlib:make_jid(<<"">>, LFrom, <<"">>)),
|
||||
jid:make(<<"">>, LFrom, <<"">>)),
|
||||
{next_state, stream_established,
|
||||
StateData#state{connections = Conns, timer = Timer}};
|
||||
{_, false} ->
|
||||
@ -430,8 +430,8 @@ stream_established({xmlstreamelement, El}, StateData) ->
|
||||
end;
|
||||
{verify, To, From, Id, Key} ->
|
||||
?DEBUG("VERIFY KEY: ~p", [{To, From, Id, Key}]),
|
||||
LTo = jlib:nameprep(To),
|
||||
LFrom = jlib:nameprep(From),
|
||||
LTo = jid:nameprep(To),
|
||||
LFrom = jid:nameprep(From),
|
||||
Type = case ejabberd_s2s:has_key({LTo, LFrom}, Key) of
|
||||
true -> <<"valid">>;
|
||||
_ -> <<"invalid">>
|
||||
@ -448,9 +448,9 @@ stream_established({xmlstreamelement, El}, StateData) ->
|
||||
NewEl = jlib:remove_attr(<<"xmlns">>, El),
|
||||
#xmlel{name = Name, attrs = Attrs} = NewEl,
|
||||
From_s = xml:get_attr_s(<<"from">>, Attrs),
|
||||
From = jlib:string_to_jid(From_s),
|
||||
From = jid:from_string(From_s),
|
||||
To_s = xml:get_attr_s(<<"to">>, Attrs),
|
||||
To = jlib:string_to_jid(To_s),
|
||||
To = jid:from_string(To_s),
|
||||
if (To /= error) and (From /= error) ->
|
||||
LFrom = From#jid.lserver,
|
||||
LTo = To#jid.lserver,
|
||||
@ -500,8 +500,8 @@ stream_established({valid, From, To}, StateData) ->
|
||||
children = []}),
|
||||
?INFO_MSG("Accepted s2s dialback authentication for ~s (TLS=~p)",
|
||||
[From, StateData#state.tls_enabled]),
|
||||
LFrom = jlib:nameprep(From),
|
||||
LTo = jlib:nameprep(To),
|
||||
LFrom = jid:nameprep(From),
|
||||
LTo = jid:nameprep(To),
|
||||
NSD = StateData#state{connections =
|
||||
(?DICT):store({LFrom, LTo}, established,
|
||||
StateData#state.connections)},
|
||||
@ -513,8 +513,8 @@ stream_established({invalid, From, To}, StateData) ->
|
||||
[{<<"from">>, To}, {<<"to">>, From},
|
||||
{<<"type">>, <<"invalid">>}],
|
||||
children = []}),
|
||||
LFrom = jlib:nameprep(From),
|
||||
LTo = jlib:nameprep(To),
|
||||
LFrom = jid:nameprep(From),
|
||||
LTo = jid:nameprep(To),
|
||||
NSD = StateData#state{connections =
|
||||
(?DICT):erase({LFrom, LTo},
|
||||
StateData#state.connections)},
|
||||
|
@ -999,9 +999,9 @@ bounce_element(El, Error) ->
|
||||
<<"result">> -> ok;
|
||||
_ ->
|
||||
Err = jlib:make_error_reply(El, Error),
|
||||
From = jlib:string_to_jid(xml:get_tag_attr_s(<<"from">>,
|
||||
From = jid:from_string(xml:get_tag_attr_s(<<"from">>,
|
||||
El)),
|
||||
To = jlib:string_to_jid(xml:get_tag_attr_s(<<"to">>,
|
||||
To = jid:from_string(xml:get_tag_attr_s(<<"to">>,
|
||||
El)),
|
||||
ejabberd_router:route(To, From, Err)
|
||||
end.
|
||||
|
@ -225,10 +225,10 @@ stream_established({xmlstreamelement, El}, StateData) ->
|
||||
%% when accept packets from any address.
|
||||
%% In this case, the component can send packet of
|
||||
%% behalf of the server users.
|
||||
false -> jlib:string_to_jid(From);
|
||||
false -> jid:from_string(From);
|
||||
%% The default is the standard behaviour in XEP-0114
|
||||
_ ->
|
||||
FromJID1 = jlib:string_to_jid(From),
|
||||
FromJID1 = jid:from_string(From),
|
||||
case FromJID1 of
|
||||
#jid{lserver = Server} ->
|
||||
case lists:member(Server, StateData#state.hosts) of
|
||||
@ -241,7 +241,7 @@ stream_established({xmlstreamelement, El}, StateData) ->
|
||||
To = xml:get_attr_s(<<"to">>, Attrs),
|
||||
ToJID = case To of
|
||||
<<"">> -> error;
|
||||
_ -> jlib:string_to_jid(To)
|
||||
_ -> jid:from_string(To)
|
||||
end,
|
||||
if ((Name == <<"iq">>) or (Name == <<"message">>) or
|
||||
(Name == <<"presence">>))
|
||||
@ -323,8 +323,8 @@ handle_info({route, From, To, Packet}, StateName,
|
||||
#xmlel{name = Name, attrs = Attrs, children = Els} =
|
||||
Packet,
|
||||
Attrs2 =
|
||||
jlib:replace_from_to_attrs(jlib:jid_to_string(From),
|
||||
jlib:jid_to_string(To), Attrs),
|
||||
jlib:replace_from_to_attrs(jid:to_string(From),
|
||||
jid:to_string(To), Attrs),
|
||||
Text = xml:element_to_binary(#xmlel{name = Name,
|
||||
attrs = Attrs2, children = Els}),
|
||||
send_text(StateData, Text);
|
||||
|
@ -120,7 +120,7 @@ route(From, To, Packet) ->
|
||||
open_session(SID, User, Server, Resource, Priority, Info) ->
|
||||
set_session(SID, User, Server, Resource, Priority, Info),
|
||||
check_for_sessions_to_replace(User, Server, Resource),
|
||||
JID = jlib:make_jid(User, Server, Resource),
|
||||
JID = jid:make(User, Server, Resource),
|
||||
ejabberd_hooks:run(sm_register_connection_hook,
|
||||
JID#jid.lserver, [SID, JID, Info]).
|
||||
|
||||
@ -133,14 +133,14 @@ open_session(SID, User, Server, Resource, Info) ->
|
||||
|
||||
close_session(SID, User, Server, Resource) ->
|
||||
Mod = get_sm_backend(),
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LResource = jlib:resourceprep(Resource),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
LResource = jid:resourceprep(Resource),
|
||||
Info = case Mod:delete_session(LUser, LServer, LResource, SID) of
|
||||
{ok, #session{info = I}} -> I;
|
||||
{error, notfound} -> []
|
||||
end,
|
||||
JID = jlib:make_jid(User, Server, Resource),
|
||||
JID = jid:make(User, Server, Resource),
|
||||
ejabberd_hooks:run(sm_remove_connection_hook,
|
||||
JID#jid.lserver, [SID, JID, Info]).
|
||||
|
||||
@ -164,13 +164,13 @@ bounce_offline_message(From, To, Packet) ->
|
||||
-spec disconnect_removed_user(binary(), binary()) -> ok.
|
||||
|
||||
disconnect_removed_user(User, Server) ->
|
||||
ejabberd_sm:route(jlib:make_jid(<<"">>, <<"">>, <<"">>),
|
||||
jlib:make_jid(User, Server, <<"">>),
|
||||
ejabberd_sm:route(jid:make(<<"">>, <<"">>, <<"">>),
|
||||
jid:make(User, Server, <<"">>),
|
||||
{broadcast, {exit, <<"User removed">>}}).
|
||||
|
||||
get_user_resources(User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
Mod = get_sm_backend(),
|
||||
Ss = Mod:get_sessions(LUser, LServer),
|
||||
[element(3, S#session.usr) || S <- clean_session_list(Ss)].
|
||||
@ -186,9 +186,9 @@ get_user_present_resources(LUser, LServer) ->
|
||||
-spec get_user_ip(binary(), binary(), binary()) -> ip().
|
||||
|
||||
get_user_ip(User, Server, Resource) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LResource = jlib:resourceprep(Resource),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
LResource = jid:resourceprep(Resource),
|
||||
Mod = get_sm_backend(),
|
||||
case Mod:get_sessions(LUser, LServer, LResource) of
|
||||
[] ->
|
||||
@ -201,9 +201,9 @@ get_user_ip(User, Server, Resource) ->
|
||||
-spec get_user_info(binary(), binary(), binary()) -> info() | offline.
|
||||
|
||||
get_user_info(User, Server, Resource) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LResource = jlib:resourceprep(Resource),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
LResource = jid:resourceprep(Resource),
|
||||
Mod = get_sm_backend(),
|
||||
case Mod:get_sessions(LUser, LServer, LResource) of
|
||||
[] ->
|
||||
@ -224,7 +224,7 @@ set_presence(SID, User, Server, Resource, Priority,
|
||||
set_session(SID, User, Server, Resource, Priority,
|
||||
Info),
|
||||
ejabberd_hooks:run(set_presence_hook,
|
||||
jlib:nameprep(Server),
|
||||
jid:nameprep(Server),
|
||||
[User, Server, Resource, Presence]).
|
||||
|
||||
-spec unset_presence(sid(), binary(), binary(),
|
||||
@ -235,7 +235,7 @@ unset_presence(SID, User, Server, Resource, Status,
|
||||
set_session(SID, User, Server, Resource, undefined,
|
||||
Info),
|
||||
ejabberd_hooks:run(unset_presence_hook,
|
||||
jlib:nameprep(Server),
|
||||
jid:nameprep(Server),
|
||||
[User, Server, Resource, Status]).
|
||||
|
||||
-spec close_session_unset_presence(sid(), binary(), binary(),
|
||||
@ -245,15 +245,15 @@ close_session_unset_presence(SID, User, Server,
|
||||
Resource, Status) ->
|
||||
close_session(SID, User, Server, Resource),
|
||||
ejabberd_hooks:run(unset_presence_hook,
|
||||
jlib:nameprep(Server),
|
||||
jid:nameprep(Server),
|
||||
[User, Server, Resource, Status]).
|
||||
|
||||
-spec get_session_pid(binary(), binary(), binary()) -> none | pid().
|
||||
|
||||
get_session_pid(User, Server, Resource) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LResource = jlib:resourceprep(Resource),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
LResource = jid:resourceprep(Resource),
|
||||
Mod = get_sm_backend(),
|
||||
case Mod:get_sessions(LUser, LServer, LResource) of
|
||||
[#session{sid = {_, Pid}}] -> Pid;
|
||||
@ -275,7 +275,7 @@ dirty_get_my_sessions_list() ->
|
||||
-spec get_vh_session_list(binary()) -> [ljid()].
|
||||
|
||||
get_vh_session_list(Server) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
Mod = get_sm_backend(),
|
||||
[S#session.usr || S <- Mod:get_sessions(LServer)].
|
||||
|
||||
@ -288,7 +288,7 @@ get_all_pids() ->
|
||||
-spec get_vh_session_number(binary()) -> non_neg_integer().
|
||||
|
||||
get_vh_session_number(Server) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
Mod = get_sm_backend(),
|
||||
length(Mod:get_sessions(LServer)).
|
||||
|
||||
@ -374,9 +374,9 @@ code_change(_OldVsn, State, _Extra) -> {ok, State}.
|
||||
prio(), info()) -> ok.
|
||||
|
||||
set_session(SID, User, Server, Resource, Priority, Info) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LResource = jlib:resourceprep(Resource),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
LResource = jid:resourceprep(Resource),
|
||||
US = {LUser, LServer},
|
||||
USR = {LUser, LServer, LResource},
|
||||
Mod = get_sm_backend(),
|
||||
@ -390,12 +390,12 @@ do_route(From, To, {broadcast, _} = Packet) ->
|
||||
<<"">> ->
|
||||
lists:foreach(fun(R) ->
|
||||
do_route(From,
|
||||
jlib:jid_replace_resource(To, R),
|
||||
jid:replace_resource(To, R),
|
||||
Packet)
|
||||
end,
|
||||
get_user_resources(To#jid.user, To#jid.server));
|
||||
_ ->
|
||||
{U, S, R} = jlib:jid_tolower(To),
|
||||
{U, S, R} = jid:tolower(To),
|
||||
Mod = get_sm_backend(),
|
||||
case Mod:get_sessions(U, S, R) of
|
||||
[] ->
|
||||
@ -474,7 +474,7 @@ do_route(From, To, #xmlel{} = Packet) ->
|
||||
PResources = get_user_present_resources(LUser, LServer),
|
||||
lists:foreach(fun ({_, R}) ->
|
||||
do_route(From,
|
||||
jlib:jid_replace_resource(To,
|
||||
jid:replace_resource(To,
|
||||
R),
|
||||
Packet)
|
||||
end,
|
||||
@ -563,7 +563,7 @@ route_message(From, To, Packet, Type) ->
|
||||
when is_integer(Priority), Priority >= 0 ->
|
||||
lists:foreach(fun ({P, R}) when P == Priority;
|
||||
(P >= 0) and (Type == headline) ->
|
||||
LResource = jlib:resourceprep(R),
|
||||
LResource = jid:resourceprep(R),
|
||||
Mod = get_sm_backend(),
|
||||
case Mod:get_sessions(LUser, LServer,
|
||||
LResource) of
|
||||
@ -619,9 +619,9 @@ clean_session_list([S1, S2 | Rest], Res) ->
|
||||
|
||||
%% On new session, check if some existing connections need to be replace
|
||||
check_for_sessions_to_replace(User, Server, Resource) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LResource = jlib:resourceprep(Resource),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
LResource = jid:resourceprep(Resource),
|
||||
check_existing_resources(LUser, LServer, LResource),
|
||||
check_max_sessions(LUser, LServer).
|
||||
|
||||
@ -643,9 +643,9 @@ is_existing_resource(LUser, LServer, LResource) ->
|
||||
[] /= get_resource_sessions(LUser, LServer, LResource).
|
||||
|
||||
get_resource_sessions(User, Server, Resource) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LResource = jlib:resourceprep(Resource),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
LResource = jid:resourceprep(Resource),
|
||||
Mod = get_sm_backend(),
|
||||
[S#session.sid || S <- Mod:get_sessions(LUser, LServer, LResource)].
|
||||
|
||||
@ -663,7 +663,7 @@ check_max_sessions(LUser, LServer) ->
|
||||
%% Defaults to infinity
|
||||
get_max_user_sessions(LUser, Host) ->
|
||||
case acl:match_rule(Host, max_user_sessions,
|
||||
jlib:make_jid(LUser, Host, <<"">>))
|
||||
jid:make(LUser, Host, <<"">>))
|
||||
of
|
||||
Max when is_integer(Max) -> Max;
|
||||
infinity -> infinity;
|
||||
|
@ -68,7 +68,7 @@ process_command(From, To, Packet) ->
|
||||
case Name of
|
||||
<<"message">> ->
|
||||
LFrom =
|
||||
jlib:jid_tolower(jlib:jid_remove_resource(From)),
|
||||
jid:tolower(jid:remove_resource(From)),
|
||||
case lists:member(LFrom, get_admin_jids()) of
|
||||
true ->
|
||||
Body = xml:get_path_s(Packet,
|
||||
@ -185,9 +185,9 @@ process_large_heap(Pid, Info) ->
|
||||
io_lib:format("(~w) The process ~w is consuming too "
|
||||
"much memory:~n~p~n~s",
|
||||
[node(), Pid, Info, DetailedInfo])),
|
||||
From = jlib:make_jid(<<"">>, Host, <<"watchdog">>),
|
||||
From = jid:make(<<"">>, Host, <<"watchdog">>),
|
||||
lists:foreach(fun (JID) ->
|
||||
send_message(From, jlib:make_jid(JID), Body)
|
||||
send_message(From, jid:make(JID), Body)
|
||||
end, JIDs).
|
||||
|
||||
send_message(From, To, Body) ->
|
||||
@ -203,8 +203,8 @@ get_admin_jids() ->
|
||||
ejabberd_config:get_option(
|
||||
watchdog_admins,
|
||||
fun(JIDs) ->
|
||||
[jlib:jid_tolower(
|
||||
jlib:string_to_jid(
|
||||
[jid:tolower(
|
||||
jid:from_string(
|
||||
iolist_to_binary(S))) || S <- JIDs]
|
||||
end, []).
|
||||
|
||||
@ -336,7 +336,7 @@ process_remote_command(_) -> throw(unknown_command).
|
||||
|
||||
opt_type(watchdog_admins) ->
|
||||
fun (JIDs) ->
|
||||
[jlib:jid_tolower(jlib:string_to_jid(iolist_to_binary(S)))
|
||||
[jid:tolower(jid:from_string(iolist_to_binary(S)))
|
||||
|| S <- JIDs]
|
||||
end;
|
||||
opt_type(watchdog_large_heap) ->
|
||||
|
@ -95,7 +95,7 @@ is_acl_match(Host, Rules, Jid) ->
|
||||
get_jid(Auth, HostHTTP, Method) ->
|
||||
case get_auth_admin(Auth, HostHTTP, [], Method) of
|
||||
{ok, {User, Server}} ->
|
||||
jlib:make_jid(User, Server, <<"">>);
|
||||
jid:make(User, Server, <<"">>);
|
||||
{unauthorized, Error} ->
|
||||
?ERROR_MSG("Unauthorized ~p: ~p", [Auth, Error]),
|
||||
throw({unauthorized, Auth})
|
||||
@ -184,7 +184,7 @@ process([<<"server">>, SHost | RPath] = Path,
|
||||
#request{auth = Auth, lang = Lang, host = HostHTTP,
|
||||
method = Method} =
|
||||
Request) ->
|
||||
Host = jlib:nameprep(SHost),
|
||||
Host = jid:nameprep(SHost),
|
||||
case lists:member(Host, ?MYHOSTS) of
|
||||
true ->
|
||||
case get_auth_admin(Auth, HostHTTP, Path, Method) of
|
||||
@ -250,7 +250,7 @@ get_auth_admin(Auth, HostHTTP, RPath, Method) ->
|
||||
case Auth of
|
||||
{SJID, Pass} ->
|
||||
{HostOfRule, AccessRule} = get_acl_rule(RPath, Method),
|
||||
case jlib:string_to_jid(SJID) of
|
||||
case jid:from_string(SJID) of
|
||||
error -> {unauthorized, <<"badformed-jid">>};
|
||||
#jid{user = <<"">>, server = User} ->
|
||||
get_auth_account(HostOfRule, AccessRule, User, HostHTTP,
|
||||
@ -267,7 +267,7 @@ get_auth_account(HostOfRule, AccessRule, User, Server,
|
||||
case ejabberd_auth:check_password(User, Server, Pass) of
|
||||
true ->
|
||||
case is_acl_match(HostOfRule, AccessRule,
|
||||
jlib:make_jid(User, Server, <<"">>))
|
||||
jid:make(User, Server, <<"">>))
|
||||
of
|
||||
false -> {unauthorized, <<"unprivileged-account">>};
|
||||
true -> {ok, {User, Server}}
|
||||
@ -1128,7 +1128,7 @@ string_to_spec(<<"server_regexp">>, Val) ->
|
||||
{server_regexp, Val};
|
||||
string_to_spec(<<"node_regexp">>, Val) ->
|
||||
#jid{luser = U, lserver = S, resource = <<"">>} =
|
||||
jlib:string_to_jid(Val),
|
||||
jid:from_string(Val),
|
||||
{node_regexp, U, S};
|
||||
string_to_spec(<<"user_glob">>, Val) ->
|
||||
string_to_spec2(user_glob, Val);
|
||||
@ -1136,7 +1136,7 @@ string_to_spec(<<"server_glob">>, Val) ->
|
||||
{server_glob, Val};
|
||||
string_to_spec(<<"node_glob">>, Val) ->
|
||||
#jid{luser = U, lserver = S, resource = <<"">>} =
|
||||
jlib:string_to_jid(Val),
|
||||
jid:from_string(Val),
|
||||
{node_glob, U, S};
|
||||
string_to_spec(<<"all">>, _) -> all;
|
||||
string_to_spec(<<"raw">>, Val) ->
|
||||
@ -1146,7 +1146,7 @@ string_to_spec(<<"raw">>, Val) ->
|
||||
|
||||
string_to_spec2(ACLName, Val) ->
|
||||
#jid{luser = U, lserver = S, resource = <<"">>} =
|
||||
jlib:string_to_jid(Val),
|
||||
jid:from_string(Val),
|
||||
case U of
|
||||
<<"">> -> {ACLName, S};
|
||||
_ -> {ACLName, {U, S}}
|
||||
@ -1362,7 +1362,7 @@ list_users_parse_query(Query, Host) ->
|
||||
lists:keysearch(<<"newusername">>, 1, Query),
|
||||
{value, {_, Password}} =
|
||||
lists:keysearch(<<"newuserpassword">>, 1, Query),
|
||||
case jlib:string_to_jid(<<Username/binary, "@",
|
||||
case jid:from_string(<<Username/binary, "@",
|
||||
Host/binary>>)
|
||||
of
|
||||
error -> error;
|
||||
@ -1463,10 +1463,10 @@ get_lastactivity_menuitem_list(Server) ->
|
||||
end.
|
||||
|
||||
us_to_list({User, Server}) ->
|
||||
jlib:jid_to_string({User, Server, <<"">>}).
|
||||
jid:to_string({User, Server, <<"">>}).
|
||||
|
||||
su_to_list({Server, User}) ->
|
||||
jlib:jid_to_string({User, Server, <<"">>}).
|
||||
jid:to_string({User, Server, <<"">>}).
|
||||
|
||||
%%%==================================
|
||||
%%%% get_stats
|
||||
@ -1521,8 +1521,8 @@ list_online_users(Host, _Lang) ->
|
||||
SUsers).
|
||||
|
||||
user_info(User, Server, Query, Lang) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
US = {jlib:nodeprep(User), LServer},
|
||||
LServer = jid:nameprep(Server),
|
||||
US = {jid:nodeprep(User), LServer},
|
||||
Res = user_parse_query(User, Server, Query),
|
||||
Resources = ejabberd_sm:get_user_resources(User,
|
||||
Server),
|
||||
|
@ -62,7 +62,7 @@ modules() ->
|
||||
mod_vcard_xupdate].
|
||||
|
||||
export(Server, Output) ->
|
||||
LServer = jlib:nameprep(iolist_to_binary(Server)),
|
||||
LServer = jid:nameprep(iolist_to_binary(Server)),
|
||||
Modules = modules(),
|
||||
IO = prepare_output(Output),
|
||||
lists:foreach(
|
||||
@ -72,7 +72,7 @@ export(Server, Output) ->
|
||||
close_output(Output, IO).
|
||||
|
||||
export(Server, Output, Module) ->
|
||||
LServer = jlib:nameprep(iolist_to_binary(Server)),
|
||||
LServer = jid:nameprep(iolist_to_binary(Server)),
|
||||
IO = prepare_output(Output),
|
||||
lists:foreach(
|
||||
fun({Table, ConvertFun}) ->
|
||||
@ -87,7 +87,7 @@ import_file(Server, FileName) ->
|
||||
{file, FileName},
|
||||
{mode, read_only}]) of
|
||||
{ok, Fd} ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
Mods = [{Mod, gen_mod:db_type(LServer, Mod)}
|
||||
|| Mod <- modules(), gen_mod:is_loaded(LServer, Mod)],
|
||||
AuthMods = case lists:member(ejabberd_auth_internal,
|
||||
@ -106,7 +106,7 @@ import(Server, Output) ->
|
||||
import(Server, Output, [{fast, true}]).
|
||||
|
||||
import(Server, Output, Opts) ->
|
||||
LServer = jlib:nameprep(iolist_to_binary(Server)),
|
||||
LServer = jid:nameprep(iolist_to_binary(Server)),
|
||||
Modules = modules(),
|
||||
IO = prepare_output(Output, disk_log),
|
||||
lists:foreach(
|
||||
@ -116,7 +116,7 @@ import(Server, Output, Opts) ->
|
||||
close_output(Output, IO).
|
||||
|
||||
import(Server, Output, Opts, Module) ->
|
||||
LServer = jlib:nameprep(iolist_to_binary(Server)),
|
||||
LServer = jid:nameprep(iolist_to_binary(Server)),
|
||||
IO = prepare_output(Output, disk_log),
|
||||
lists:foreach(
|
||||
fun({SelectQuery, ConvertFun}) ->
|
||||
|
@ -95,7 +95,7 @@ remove_user(User, Server, Password) ->
|
||||
[<<"removeuser3">>, User, Server, Password]).
|
||||
|
||||
call_port(Server, Msg) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
ProcessName = get_process_name(LServer,
|
||||
random_instance(get_instances(LServer))),
|
||||
ProcessName ! {call, self(), Msg},
|
||||
|
@ -42,8 +42,8 @@
|
||||
import_file(File) ->
|
||||
User = filename:rootname(filename:basename(File)),
|
||||
Server = filename:basename(filename:dirname(File)),
|
||||
case jlib:nodeprep(User) /= error andalso
|
||||
jlib:nameprep(Server) /= error
|
||||
case jid:nodeprep(User) /= error andalso
|
||||
jid:nameprep(Server) /= error
|
||||
of
|
||||
true ->
|
||||
case file:read_file(File) of
|
||||
@ -112,7 +112,7 @@ process_xdb(User, Server,
|
||||
|
||||
xdb_data(_User, _Server, {xmlcdata, _CData}) -> ok;
|
||||
xdb_data(User, Server, #xmlel{attrs = Attrs} = El) ->
|
||||
From = jlib:make_jid(User, Server, <<"">>),
|
||||
From = jid:make(User, Server, <<"">>),
|
||||
case xml:get_attr_s(<<"xmlns">>, Attrs) of
|
||||
?NS_AUTH ->
|
||||
Password = xml:get_tag_cdata(El),
|
||||
@ -129,7 +129,7 @@ xdb_data(User, Server, #xmlel{attrs = Attrs} = El) ->
|
||||
ok;
|
||||
?NS_VCARD ->
|
||||
catch mod_vcard:process_sm_iq(From,
|
||||
jlib:make_jid(<<"">>, Server, <<"">>),
|
||||
jid:make(<<"">>, Server, <<"">>),
|
||||
#iq{type = set, xmlns = ?NS_VCARD,
|
||||
sub_el = El}),
|
||||
ok;
|
||||
@ -139,7 +139,7 @@ xdb_data(User, Server, #xmlel{attrs = Attrs} = El) ->
|
||||
case xml:get_attr_s(<<"j_private_flag">>, Attrs) of
|
||||
<<"1">> ->
|
||||
catch mod_private:process_sm_iq(From,
|
||||
jlib:make_jid(<<"">>, Server,
|
||||
jid:make(<<"">>, Server,
|
||||
<<"">>),
|
||||
#iq{type = set,
|
||||
xmlns = ?NS_PRIVATE,
|
||||
@ -158,13 +158,13 @@ xdb_data(User, Server, #xmlel{attrs = Attrs} = El) ->
|
||||
end.
|
||||
|
||||
process_offline(Server, To, #xmlel{children = Els}) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
lists:foreach(fun (#xmlel{attrs = Attrs} = El) ->
|
||||
FromS = xml:get_attr_s(<<"from">>, Attrs),
|
||||
From = case FromS of
|
||||
<<"">> ->
|
||||
jlib:make_jid(<<"">>, Server, <<"">>);
|
||||
_ -> jlib:string_to_jid(FromS)
|
||||
jid:make(<<"">>, Server, <<"">>);
|
||||
_ -> jid:from_string(FromS)
|
||||
end,
|
||||
case From of
|
||||
error -> ok;
|
||||
|
228
src/jid.erl
Normal file
228
src/jid.erl
Normal file
@ -0,0 +1,228 @@
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net>
|
||||
%%% @doc
|
||||
%%% JID processing library
|
||||
%%% @end
|
||||
%%% Created : 24 Nov 2015 by Evgeny Khramtsov <ekhramtsov@process-one.net>
|
||||
%%%
|
||||
%%%
|
||||
%%% ejabberd, Copyright (C) 2002-2015 ProcessOne
|
||||
%%%
|
||||
%%% This program is free software; you can redistribute it and/or
|
||||
%%% modify it under the terms of the GNU General Public License as
|
||||
%%% published by the Free Software Foundation; either version 2 of the
|
||||
%%% License, or (at your option) any later version.
|
||||
%%%
|
||||
%%% This program is distributed in the hope that it will be useful,
|
||||
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
%%% General Public License for more details.
|
||||
%%%
|
||||
%%% You should have received a copy of the GNU General Public License along
|
||||
%%% with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
%%%
|
||||
%%%-------------------------------------------------------------------
|
||||
-module(jid).
|
||||
|
||||
%% API
|
||||
-export([start/0,
|
||||
make/1,
|
||||
make/3,
|
||||
split/1,
|
||||
from_string/1,
|
||||
to_string/1,
|
||||
is_nodename/1,
|
||||
nodeprep/1,
|
||||
nameprep/1,
|
||||
resourceprep/1,
|
||||
tolower/1,
|
||||
remove_resource/1,
|
||||
replace_resource/2]).
|
||||
|
||||
-include("jlib.hrl").
|
||||
|
||||
-export_type([jid/0]).
|
||||
|
||||
%%%===================================================================
|
||||
%%% API
|
||||
%%%===================================================================
|
||||
-spec start() -> ok.
|
||||
|
||||
start() ->
|
||||
SplitPattern = binary:compile_pattern([<<"@">>, <<"/">>]),
|
||||
catch ets:new(jlib, [named_table, protected, set, {keypos, 1}]),
|
||||
ets:insert(jlib, {string_to_jid_pattern, SplitPattern}),
|
||||
ok.
|
||||
|
||||
-spec make(binary(), binary(), binary()) -> jid() | error.
|
||||
|
||||
make(User, Server, Resource) ->
|
||||
case nodeprep(User) of
|
||||
error -> error;
|
||||
LUser ->
|
||||
case nameprep(Server) of
|
||||
error -> error;
|
||||
LServer ->
|
||||
case resourceprep(Resource) of
|
||||
error -> error;
|
||||
LResource ->
|
||||
#jid{user = User, server = Server, resource = Resource,
|
||||
luser = LUser, lserver = LServer,
|
||||
lresource = LResource}
|
||||
end
|
||||
end
|
||||
end.
|
||||
|
||||
-spec make({binary(), binary(), binary()}) -> jid() | error.
|
||||
|
||||
make({User, Server, Resource}) ->
|
||||
make(User, Server, Resource).
|
||||
|
||||
%% This is the reverse of make_jid/1
|
||||
-spec split(jid()) -> {binary(), binary(), binary()} | error.
|
||||
|
||||
split(#jid{user = U, server = S, resource = R}) ->
|
||||
{U, S, R};
|
||||
split(_) ->
|
||||
error.
|
||||
|
||||
-spec from_string(binary()) -> jid() | error.
|
||||
|
||||
from_string(S) ->
|
||||
SplitPattern = ets:lookup_element(jlib, string_to_jid_pattern, 2),
|
||||
Size = size(S),
|
||||
End = Size-1,
|
||||
case binary:match(S, SplitPattern) of
|
||||
{0, _} ->
|
||||
error;
|
||||
{End, _} ->
|
||||
error;
|
||||
{Pos1, _} ->
|
||||
case binary:at(S, Pos1) of
|
||||
$/ ->
|
||||
make(<<>>,
|
||||
binary:part(S, 0, Pos1),
|
||||
binary:part(S, Pos1+1, Size-Pos1-1));
|
||||
_ ->
|
||||
Pos1N = Pos1+1,
|
||||
case binary:match(S, SplitPattern, [{scope, {Pos1+1, Size-Pos1-1}}]) of
|
||||
{End, _} ->
|
||||
error;
|
||||
{Pos1N, _} ->
|
||||
error;
|
||||
{Pos2, _} ->
|
||||
case binary:at(S, Pos2) of
|
||||
$/ ->
|
||||
make(binary:part(S, 0, Pos1),
|
||||
binary:part(S, Pos1+1, Pos2-Pos1-1),
|
||||
binary:part(S, Pos2+1, Size-Pos2-1));
|
||||
_ -> error
|
||||
end;
|
||||
_ ->
|
||||
make(binary:part(S, 0, Pos1),
|
||||
binary:part(S, Pos1+1, Size-Pos1-1),
|
||||
<<>>)
|
||||
end
|
||||
end;
|
||||
_ ->
|
||||
make(<<>>, S, <<>>)
|
||||
end.
|
||||
|
||||
-spec to_string(jid() | ljid()) -> binary().
|
||||
|
||||
to_string(#jid{user = User, server = Server,
|
||||
resource = Resource}) ->
|
||||
to_string({User, Server, Resource});
|
||||
to_string({N, S, R}) ->
|
||||
Node = iolist_to_binary(N),
|
||||
Server = iolist_to_binary(S),
|
||||
Resource = iolist_to_binary(R),
|
||||
S1 = case Node of
|
||||
<<"">> -> <<"">>;
|
||||
_ -> <<Node/binary, "@">>
|
||||
end,
|
||||
S2 = <<S1/binary, Server/binary>>,
|
||||
S3 = case Resource of
|
||||
<<"">> -> S2;
|
||||
_ -> <<S2/binary, "/", Resource/binary>>
|
||||
end,
|
||||
S3.
|
||||
|
||||
-spec is_nodename(binary()) -> boolean().
|
||||
|
||||
is_nodename(Node) ->
|
||||
N = nodeprep(Node),
|
||||
(N /= error) and (N /= <<>>).
|
||||
|
||||
-define(LOWER(Char),
|
||||
if Char >= $A, Char =< $Z -> Char + 32;
|
||||
true -> Char
|
||||
end).
|
||||
|
||||
-spec nodeprep(binary()) -> binary() | error.
|
||||
|
||||
nodeprep("") -> <<>>;
|
||||
nodeprep(S) when byte_size(S) < 1024 ->
|
||||
R = stringprep:nodeprep(S),
|
||||
if byte_size(R) < 1024 -> R;
|
||||
true -> error
|
||||
end;
|
||||
nodeprep(_) -> error.
|
||||
|
||||
-spec nameprep(binary()) -> binary() | error.
|
||||
|
||||
nameprep(S) when byte_size(S) < 1024 ->
|
||||
R = stringprep:nameprep(S),
|
||||
if byte_size(R) < 1024 -> R;
|
||||
true -> error
|
||||
end;
|
||||
nameprep(_) -> error.
|
||||
|
||||
-spec resourceprep(binary()) -> binary() | error.
|
||||
|
||||
resourceprep(S) when byte_size(S) < 1024 ->
|
||||
R = stringprep:resourceprep(S),
|
||||
if byte_size(R) < 1024 -> R;
|
||||
true -> error
|
||||
end;
|
||||
resourceprep(_) -> error.
|
||||
|
||||
-spec tolower(jid() | ljid()) -> error | ljid().
|
||||
|
||||
tolower(#jid{luser = U, lserver = S,
|
||||
lresource = R}) ->
|
||||
{U, S, R};
|
||||
tolower({U, S, R}) ->
|
||||
case nodeprep(U) of
|
||||
error -> error;
|
||||
LUser ->
|
||||
case nameprep(S) of
|
||||
error -> error;
|
||||
LServer ->
|
||||
case resourceprep(R) of
|
||||
error -> error;
|
||||
LResource -> {LUser, LServer, LResource}
|
||||
end
|
||||
end
|
||||
end.
|
||||
|
||||
-spec remove_resource(jid()) -> jid();
|
||||
(ljid()) -> ljid().
|
||||
|
||||
remove_resource(#jid{} = JID) ->
|
||||
JID#jid{resource = <<"">>, lresource = <<"">>};
|
||||
remove_resource({U, S, _R}) -> {U, S, <<"">>}.
|
||||
|
||||
-spec replace_resource(jid(), binary()) -> error | jid().
|
||||
|
||||
replace_resource(JID, Resource) ->
|
||||
case resourceprep(Resource) of
|
||||
error -> error;
|
||||
LResource ->
|
||||
JID#jid{resource = Resource, lresource = LResource}
|
||||
end.
|
||||
|
||||
%%%===================================================================
|
||||
%%% Internal functions
|
||||
%%%===================================================================
|
165
src/jlib.erl
165
src/jlib.erl
@ -39,10 +39,7 @@
|
||||
make_error_reply/2, make_error_element/2,
|
||||
make_correct_from_to_attrs/3, replace_from_to_attrs/3,
|
||||
replace_from_to/3, replace_from_attrs/2, replace_from/2,
|
||||
remove_attr/2, make_jid/3, make_jid/1, split_jid/1, string_to_jid/1,
|
||||
jid_to_string/1, is_nodename/1, tolower/1, nodeprep/1,
|
||||
nameprep/1, resourceprep/1, jid_tolower/1,
|
||||
jid_remove_resource/1, jid_replace_resource/2,
|
||||
remove_attr/2, tolower/1,
|
||||
get_iq_namespace/1, iq_query_info/1,
|
||||
iq_query_or_response_info/1, is_iq_request_type/1,
|
||||
iq_to_xml/1, parse_xdata_submit/1,
|
||||
@ -58,19 +55,16 @@
|
||||
atom_to_binary/1, binary_to_atom/1, tuple_to_binary/1,
|
||||
l2i/1, i2l/1, i2l/2, queue_drop_while/2]).
|
||||
|
||||
-export([start/0]).
|
||||
%% The following functions are deprecated and will be removed soon
|
||||
%% Use corresponding functions from jid.erl instead
|
||||
-export([make_jid/3, make_jid/1, split_jid/1, string_to_jid/1,
|
||||
jid_to_string/1, is_nodename/1, nodeprep/1,
|
||||
nameprep/1, resourceprep/1, jid_tolower/1,
|
||||
jid_remove_resource/1, jid_replace_resource/2]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("jlib.hrl").
|
||||
|
||||
-export_type([jid/0]).
|
||||
|
||||
start() ->
|
||||
SplitPattern = binary:compile_pattern([<<"@">>, <<"/">>]),
|
||||
catch ets:new(jlib, [named_table, protected, set, {keypos, 1}]),
|
||||
ets:insert(jlib, {string_to_jid_pattern, SplitPattern}),
|
||||
ok.
|
||||
|
||||
%send_iq(From, To, ID, SubTags) ->
|
||||
% ok.
|
||||
|
||||
@ -173,8 +167,8 @@ replace_from_to_attrs(From, To, Attrs) ->
|
||||
replace_from_to(From, To,
|
||||
#xmlel{name = Name, attrs = Attrs, children = Els}) ->
|
||||
NewAttrs =
|
||||
replace_from_to_attrs(jlib:jid_to_string(From),
|
||||
jlib:jid_to_string(To), Attrs),
|
||||
replace_from_to_attrs(jid:to_string(From),
|
||||
jid:to_string(To), Attrs),
|
||||
#xmlel{name = Name, attrs = NewAttrs, children = Els}.
|
||||
|
||||
-spec replace_from_attrs(binary(), [attr()]) -> [attr()].
|
||||
@ -187,7 +181,7 @@ replace_from_attrs(From, Attrs) ->
|
||||
|
||||
replace_from(From,
|
||||
#xmlel{name = Name, attrs = Attrs, children = Els}) ->
|
||||
NewAttrs = replace_from_attrs(jlib:jid_to_string(From),
|
||||
NewAttrs = replace_from_attrs(jid:to_string(From),
|
||||
Attrs),
|
||||
#xmlel{name = Name, attrs = NewAttrs, children = Els}.
|
||||
|
||||
@ -201,101 +195,32 @@ remove_attr(Attr,
|
||||
-spec make_jid(binary(), binary(), binary()) -> jid() | error.
|
||||
|
||||
make_jid(User, Server, Resource) ->
|
||||
case nodeprep(User) of
|
||||
error -> error;
|
||||
LUser ->
|
||||
case nameprep(Server) of
|
||||
error -> error;
|
||||
LServer ->
|
||||
case resourceprep(Resource) of
|
||||
error -> error;
|
||||
LResource ->
|
||||
#jid{user = User, server = Server, resource = Resource,
|
||||
luser = LUser, lserver = LServer,
|
||||
lresource = LResource}
|
||||
end
|
||||
end
|
||||
end.
|
||||
jid:make(User, Server, Resource).
|
||||
|
||||
-spec make_jid({binary(), binary(), binary()}) -> jid() | error.
|
||||
|
||||
make_jid({User, Server, Resource}) ->
|
||||
make_jid(User, Server, Resource).
|
||||
jid:make({User, Server, Resource}).
|
||||
|
||||
%% This is the reverse of make_jid/1
|
||||
-spec split_jid(jid()) -> {binary(), binary(), binary()} | error.
|
||||
split_jid(#jid{user = U, server = S, resource = R}) ->
|
||||
{U, S, R};
|
||||
split_jid(_) ->
|
||||
error.
|
||||
split_jid(J) ->
|
||||
jid:split(J).
|
||||
|
||||
-spec string_to_jid(binary()) -> jid() | error.
|
||||
|
||||
string_to_jid(S) ->
|
||||
SplitPattern = ets:lookup_element(jlib, string_to_jid_pattern, 2),
|
||||
Size = size(S),
|
||||
End = Size-1,
|
||||
case binary:match(S, SplitPattern) of
|
||||
{0, _} ->
|
||||
error;
|
||||
{End, _} ->
|
||||
error;
|
||||
{Pos1, _} ->
|
||||
case binary:at(S, Pos1) of
|
||||
$/ ->
|
||||
make_jid(<<>>,
|
||||
binary:part(S, 0, Pos1),
|
||||
binary:part(S, Pos1+1, Size-Pos1-1));
|
||||
_ ->
|
||||
Pos1N = Pos1+1,
|
||||
case binary:match(S, SplitPattern, [{scope, {Pos1+1, Size-Pos1-1}}]) of
|
||||
{End, _} ->
|
||||
error;
|
||||
{Pos1N, _} ->
|
||||
error;
|
||||
{Pos2, _} ->
|
||||
case binary:at(S, Pos2) of
|
||||
$/ ->
|
||||
make_jid(binary:part(S, 0, Pos1),
|
||||
binary:part(S, Pos1+1, Pos2-Pos1-1),
|
||||
binary:part(S, Pos2+1, Size-Pos2-1));
|
||||
_ -> error
|
||||
end;
|
||||
_ ->
|
||||
make_jid(binary:part(S, 0, Pos1),
|
||||
binary:part(S, Pos1+1, Size-Pos1-1),
|
||||
<<>>)
|
||||
end
|
||||
end;
|
||||
_ ->
|
||||
make_jid(<<>>, S, <<>>)
|
||||
end.
|
||||
jid:from_string(S).
|
||||
|
||||
-spec jid_to_string(jid() | ljid()) -> binary().
|
||||
|
||||
jid_to_string(#jid{user = User, server = Server,
|
||||
resource = Resource}) ->
|
||||
jid_to_string({User, Server, Resource});
|
||||
jid_to_string({N, S, R}) ->
|
||||
Node = iolist_to_binary(N),
|
||||
Server = iolist_to_binary(S),
|
||||
Resource = iolist_to_binary(R),
|
||||
S1 = case Node of
|
||||
<<"">> -> <<"">>;
|
||||
_ -> <<Node/binary, "@">>
|
||||
end,
|
||||
S2 = <<S1/binary, Server/binary>>,
|
||||
S3 = case Resource of
|
||||
<<"">> -> S2;
|
||||
_ -> <<S2/binary, "/", Resource/binary>>
|
||||
end,
|
||||
S3.
|
||||
jid_to_string(J) ->
|
||||
jid:to_string(J).
|
||||
|
||||
-spec is_nodename(binary()) -> boolean().
|
||||
|
||||
is_nodename(Node) ->
|
||||
N = nodeprep(Node),
|
||||
(N /= error) and (N /= <<>>).
|
||||
jid:is_nodename(Node).
|
||||
|
||||
%tolower_c(C) when C >= $A, C =< $Z ->
|
||||
% C + 32;
|
||||
@ -333,66 +258,30 @@ tolower_s([]) -> [].
|
||||
|
||||
-spec nodeprep(binary()) -> binary() | error.
|
||||
|
||||
nodeprep("") -> <<>>;
|
||||
nodeprep(S) when byte_size(S) < 1024 ->
|
||||
R = stringprep:nodeprep(S),
|
||||
if byte_size(R) < 1024 -> R;
|
||||
true -> error
|
||||
end;
|
||||
nodeprep(_) -> error.
|
||||
nodeprep(S) -> jid:nodeprep(S).
|
||||
|
||||
-spec nameprep(binary()) -> binary() | error.
|
||||
|
||||
nameprep(S) when byte_size(S) < 1024 ->
|
||||
R = stringprep:nameprep(S),
|
||||
if byte_size(R) < 1024 -> R;
|
||||
true -> error
|
||||
end;
|
||||
nameprep(_) -> error.
|
||||
nameprep(S) -> jid:nameprep(S).
|
||||
|
||||
-spec resourceprep(binary()) -> binary() | error.
|
||||
|
||||
resourceprep(S) when byte_size(S) < 1024 ->
|
||||
R = stringprep:resourceprep(S),
|
||||
if byte_size(R) < 1024 -> R;
|
||||
true -> error
|
||||
end;
|
||||
resourceprep(_) -> error.
|
||||
resourceprep(S) -> jid:resourceprep(S).
|
||||
|
||||
-spec jid_tolower(jid() | ljid()) -> error | ljid().
|
||||
|
||||
jid_tolower(#jid{luser = U, lserver = S,
|
||||
lresource = R}) ->
|
||||
{U, S, R};
|
||||
jid_tolower({U, S, R}) ->
|
||||
case nodeprep(U) of
|
||||
error -> error;
|
||||
LUser ->
|
||||
case nameprep(S) of
|
||||
error -> error;
|
||||
LServer ->
|
||||
case resourceprep(R) of
|
||||
error -> error;
|
||||
LResource -> {LUser, LServer, LResource}
|
||||
end
|
||||
end
|
||||
end.
|
||||
jid_tolower(J) ->
|
||||
jid:tolower(J).
|
||||
|
||||
-spec jid_remove_resource(jid()) -> jid();
|
||||
(ljid()) -> ljid().
|
||||
|
||||
jid_remove_resource(#jid{} = JID) ->
|
||||
JID#jid{resource = <<"">>, lresource = <<"">>};
|
||||
jid_remove_resource({U, S, _R}) -> {U, S, <<"">>}.
|
||||
jid_remove_resource(J) -> jid:remove_resource(J).
|
||||
|
||||
-spec jid_replace_resource(jid(), binary()) -> error | jid().
|
||||
|
||||
jid_replace_resource(JID, Resource) ->
|
||||
case resourceprep(Resource) of
|
||||
error -> error;
|
||||
LResource ->
|
||||
JID#jid{resource = Resource, lresource = LResource}
|
||||
end.
|
||||
jid:replace_resource(JID, Resource).
|
||||
|
||||
-spec get_iq_namespace(xmlel()) -> binary().
|
||||
|
||||
@ -668,7 +557,7 @@ add_delay_info(El, From, Time, Desc) ->
|
||||
-> xmlel() | error.
|
||||
|
||||
create_delay_tag(TimeStamp, FromJID, Desc) when is_tuple(FromJID) ->
|
||||
From = jlib:jid_to_string(FromJID),
|
||||
From = jid:to_string(FromJID),
|
||||
Stamp = now_to_utc_string(TimeStamp, 3),
|
||||
Children = case Desc of
|
||||
<<"">> -> [];
|
||||
@ -680,7 +569,7 @@ create_delay_tag(TimeStamp, FromJID, Desc) when is_tuple(FromJID) ->
|
||||
{<<"stamp">>, Stamp}],
|
||||
children = Children};
|
||||
create_delay_tag(DateTime, Host, Desc) when is_binary(Host) ->
|
||||
FromJID = jlib:make_jid(<<"">>, Host, <<"">>),
|
||||
FromJID = jid:make(<<"">>, Host, <<"">>),
|
||||
create_delay_tag(DateTime, FromJID, Desc).
|
||||
|
||||
-type tz() :: {binary(), {integer(), integer()}} | {integer(), integer()} | utc.
|
||||
|
@ -142,7 +142,7 @@ get_sm_commands(Acc, _From,
|
||||
end,
|
||||
Nodes = [#xmlel{name = <<"item">>,
|
||||
attrs =
|
||||
[{<<"jid">>, jlib:jid_to_string(To)},
|
||||
[{<<"jid">>, jid:to_string(To)},
|
||||
{<<"node">>, ?NS_COMMANDS},
|
||||
{<<"name">>,
|
||||
translate:translate(Lang, <<"Commands">>)}],
|
||||
|
@ -688,8 +688,8 @@ get_resources(User, Server) ->
|
||||
get_sessions(User, Server)).
|
||||
|
||||
get_sessions(User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
Sessions = mnesia:dirty_index_read(session, {LUser, LServer}, #session.us),
|
||||
true = is_list(Sessions),
|
||||
Sessions.
|
||||
@ -734,8 +734,8 @@ kick_session(User, Server, Resource, ReasonText) ->
|
||||
ok.
|
||||
|
||||
kick_this_session(User, Server, Resource, Reason) ->
|
||||
ejabberd_sm:route(jlib:make_jid(<<"">>, <<"">>, <<"">>),
|
||||
jlib:make_jid(User, Server, Resource),
|
||||
ejabberd_sm:route(jid:make(<<"">>, <<"">>, <<"">>),
|
||||
jid:make(User, Server, Resource),
|
||||
{broadcast, {exit, Reason}}).
|
||||
|
||||
status_num(Host, Status) ->
|
||||
@ -814,8 +814,8 @@ stringize(String) ->
|
||||
|
||||
set_presence(User, Host, Resource, Type, Show, Status, Priority) ->
|
||||
Pid = ejabberd_sm:get_session_pid(User, Host, Resource),
|
||||
USR = jlib:jid_to_string(jlib:make_jid(User, Host, Resource)),
|
||||
US = jlib:jid_to_string(jlib:make_jid(User, Host, <<>>)),
|
||||
USR = jid:to_string(jid:make(User, Host, Resource)),
|
||||
US = jid:to_string(jid:make(User, Host, <<>>)),
|
||||
Message = {route_xmlstreamelement,
|
||||
{xmlel, <<"presence">>,
|
||||
[{<<"from">>, USR}, {<<"to">>, US}, {<<"type">>, Type}],
|
||||
@ -901,7 +901,7 @@ get_module_resource(Server) ->
|
||||
|
||||
get_vcard_content(User, Server, Data) ->
|
||||
[{_, Module, Function, _Opts}] = ets:lookup(sm_iqtable, {?NS_VCARD, Server}),
|
||||
JID = jlib:make_jid(User, Server, get_module_resource(Server)),
|
||||
JID = jid:make(User, Server, get_module_resource(Server)),
|
||||
IQ = #iq{type = get, xmlns = ?NS_VCARD},
|
||||
IQr = Module:Function(JID, JID, IQ),
|
||||
[A1] = IQr#iq.sub_el,
|
||||
@ -938,7 +938,7 @@ set_vcard_content(User, Server, Data, SomeContent) ->
|
||||
Bin when is_binary(Bin) -> [SomeContent]
|
||||
end,
|
||||
[{_, Module, Function, _Opts}] = ets:lookup(sm_iqtable, {?NS_VCARD, Server}),
|
||||
JID = jlib:make_jid(User, Server, get_module_resource(Server)),
|
||||
JID = jid:make(User, Server, get_module_resource(Server)),
|
||||
IQ = #iq{type = get, xmlns = ?NS_VCARD},
|
||||
IQr = Module:Function(JID, JID, IQ),
|
||||
|
||||
@ -1052,7 +1052,7 @@ get_roster(User, Server) ->
|
||||
make_roster_xmlrpc(Roster) ->
|
||||
lists:foldl(
|
||||
fun(Item, Res) ->
|
||||
JIDS = jlib:jid_to_string(Item#roster.jid),
|
||||
JIDS = jid:to_string(Item#roster.jid),
|
||||
Nick = Item#roster.name,
|
||||
Subs = atom_to_list(Item#roster.subscription),
|
||||
Ask = atom_to_list(Item#roster.ask),
|
||||
@ -1118,7 +1118,7 @@ push_roster_item(LU, LS, U, S, Action) ->
|
||||
end, ejabberd_sm:get_user_resources(LU, LS)).
|
||||
|
||||
push_roster_item(LU, LS, R, U, S, Action) ->
|
||||
LJID = jlib:make_jid(LU, LS, R),
|
||||
LJID = jid:make(LU, LS, R),
|
||||
BroadcastEl = build_broadcast(U, S, Action),
|
||||
ejabberd_sm:route(LJID, LJID, BroadcastEl),
|
||||
Item = build_roster_item(U, S, Action),
|
||||
@ -1127,14 +1127,14 @@ push_roster_item(LU, LS, R, U, S, Action) ->
|
||||
|
||||
build_roster_item(U, S, {add, Nick, Subs, Group}) ->
|
||||
{xmlel, <<"item">>,
|
||||
[{<<"jid">>, jlib:jid_to_string(jlib:make_jid(U, S, <<>>))},
|
||||
[{<<"jid">>, jid:to_string(jid:make(U, S, <<>>))},
|
||||
{<<"name">>, Nick},
|
||||
{<<"subscription">>, Subs}],
|
||||
[{xmlel, <<"group">>, [], [{xmlcdata, Group}]}]
|
||||
};
|
||||
build_roster_item(U, S, remove) ->
|
||||
{xmlel, <<"item">>,
|
||||
[{<<"jid">>, jlib:jid_to_string(jlib:make_jid(U, S, <<>>))},
|
||||
[{<<"jid">>, jid:to_string(jid:make(U, S, <<>>))},
|
||||
{<<"subscription">>, <<"remove">>}],
|
||||
[]
|
||||
}.
|
||||
@ -1193,8 +1193,8 @@ get_last(User, Server) ->
|
||||
%% <aa xmlns='bb'>Cluth</aa>
|
||||
|
||||
private_get(Username, Host, Element, Ns) ->
|
||||
From = jlib:make_jid(Username, Host, <<>>),
|
||||
To = jlib:make_jid(Username, Host, <<>>),
|
||||
From = jid:make(Username, Host, <<>>),
|
||||
To = jid:make(Username, Host, <<>>),
|
||||
IQ = {iq, <<>>, get, ?NS_PRIVATE, <<>>,
|
||||
{xmlel, <<"query">>,
|
||||
[{<<"xmlns">>,?NS_PRIVATE}],
|
||||
@ -1216,8 +1216,8 @@ private_set(Username, Host, ElementString) ->
|
||||
end.
|
||||
|
||||
private_set2(Username, Host, Xml) ->
|
||||
From = jlib:make_jid(Username, Host, <<>>),
|
||||
To = jlib:make_jid(Username, Host, <<>>),
|
||||
From = jid:make(Username, Host, <<>>),
|
||||
To = jid:make(Username, Host, <<>>),
|
||||
IQ = {iq, <<>>, set, ?NS_PRIVATE, <<>>,
|
||||
{xmlel, <<"query">>,
|
||||
[{<<"xmlns">>, ?NS_PRIVATE}],
|
||||
@ -1261,7 +1261,7 @@ btl(B) -> binary_to_list(B).
|
||||
|
||||
srg_get_members(Group, Host) ->
|
||||
Members = mod_shared_roster:get_group_explicit_users(Host,Group),
|
||||
[jlib:jid_to_string(jlib:make_jid(MUser, MServer, <<>>))
|
||||
[jid:to_string(jid:make(MUser, MServer, <<>>))
|
||||
|| {MUser, MServer} <- Members].
|
||||
|
||||
srg_user_add(User, Host, Group, GroupHost) ->
|
||||
@ -1292,8 +1292,8 @@ send_message(Type, From, To, Subject, Body) ->
|
||||
%% If the user is local and is online in several resources,
|
||||
%% the packet is sent to all its resources.
|
||||
send_packet_all_resources(FromJIDString, ToJIDString, Packet) ->
|
||||
FromJID = jlib:string_to_jid(FromJIDString),
|
||||
ToJID = jlib:string_to_jid(ToJIDString),
|
||||
FromJID = jid:from_string(FromJIDString),
|
||||
ToJID = jid:from_string(ToJIDString),
|
||||
ToUser = ToJID#jid.user,
|
||||
ToServer = ToJID#jid.server,
|
||||
case ToJID#jid.resource of
|
||||
@ -1317,7 +1317,7 @@ send_packet_all_resources(FromJID, ToUser, ToServer, Packet) ->
|
||||
end.
|
||||
|
||||
send_packet_all_resources(FromJID, ToU, ToS, ToR, Packet) ->
|
||||
ToJID = jlib:make_jid(ToU, ToS, ToR),
|
||||
ToJID = jid:make(ToU, ToS, ToR),
|
||||
ejabberd_router:route(FromJID, ToJID, Packet).
|
||||
|
||||
build_packet(Type, Subject, Body) ->
|
||||
@ -1335,8 +1335,8 @@ send_stanza_c2s(Username, Host, Resource, Stanza) ->
|
||||
p1_fsm:send_event(C2sPid, {xmlstreamelement, XmlEl}).
|
||||
|
||||
privacy_set(Username, Host, QueryS) ->
|
||||
From = jlib:make_jid(Username, Host, <<"">>),
|
||||
To = jlib:make_jid(<<"">>, Host, <<"">>),
|
||||
From = jid:make(Username, Host, <<"">>),
|
||||
To = jid:make(<<"">>, Host, <<"">>),
|
||||
QueryEl = xml_stream:parse_element(QueryS),
|
||||
StanzaEl = {xmlel, <<"iq">>, [{<<"type">>, <<"set">>}], [QueryEl]},
|
||||
IQ = jlib:iq_query_info(StanzaEl),
|
||||
@ -1477,7 +1477,7 @@ decide_rip_jid({UName, UServer, _UResource}, Match_list) ->
|
||||
decide_rip_jid({UName, UServer}, Match_list) ->
|
||||
lists:any(
|
||||
fun(Match_string) ->
|
||||
MJID = jlib:string_to_jid(list_to_binary(Match_string)),
|
||||
MJID = jid:from_string(list_to_binary(Match_string)),
|
||||
MName = MJID#jid.luser,
|
||||
MServer = MJID#jid.lserver,
|
||||
Is_server = is_glob_match(UServer, MServer),
|
||||
|
@ -691,10 +691,10 @@ announce_all(From, To, Packet) ->
|
||||
Err = jlib:make_error_reply(Packet, ?ERR_FORBIDDEN),
|
||||
ejabberd_router:route(To, From, Err);
|
||||
allow ->
|
||||
Local = jlib:make_jid(<<>>, To#jid.server, <<>>),
|
||||
Local = jid:make(<<>>, To#jid.server, <<>>),
|
||||
lists:foreach(
|
||||
fun({User, Server}) ->
|
||||
Dest = jlib:make_jid(User, Server, <<>>),
|
||||
Dest = jid:make(User, Server, <<>>),
|
||||
ejabberd_router:route(Local, Dest, Packet)
|
||||
end, ejabberd_auth:get_vh_registered_users(Host))
|
||||
end.
|
||||
@ -706,10 +706,10 @@ announce_all_hosts_all(From, To, Packet) ->
|
||||
Err = jlib:make_error_reply(Packet, ?ERR_FORBIDDEN),
|
||||
ejabberd_router:route(To, From, Err);
|
||||
allow ->
|
||||
Local = jlib:make_jid(<<>>, To#jid.server, <<>>),
|
||||
Local = jid:make(<<>>, To#jid.server, <<>>),
|
||||
lists:foreach(
|
||||
fun({User, Server}) ->
|
||||
Dest = jlib:make_jid(User, Server, <<>>),
|
||||
Dest = jid:make(User, Server, <<>>),
|
||||
ejabberd_router:route(Local, Dest, Packet)
|
||||
end, ejabberd_auth:dirty_get_registered_users())
|
||||
end.
|
||||
@ -740,10 +740,10 @@ announce_all_hosts_online(From, To, Packet) ->
|
||||
end.
|
||||
|
||||
announce_online1(Sessions, Server, Packet) ->
|
||||
Local = jlib:make_jid(<<>>, Server, <<>>),
|
||||
Local = jid:make(<<>>, Server, <<>>),
|
||||
lists:foreach(
|
||||
fun({U, S, R}) ->
|
||||
Dest = jlib:make_jid(U, S, R),
|
||||
Dest = jid:make(U, S, R),
|
||||
ejabberd_router:route(Local, Dest, Packet)
|
||||
end, Sessions).
|
||||
|
||||
@ -770,7 +770,7 @@ announce_all_hosts_motd(From, To, Packet) ->
|
||||
end.
|
||||
|
||||
announce_motd(Host, Packet) ->
|
||||
LServer = jlib:nameprep(Host),
|
||||
LServer = jid:nameprep(Host),
|
||||
announce_motd_update(LServer, Packet),
|
||||
Sessions = ejabberd_sm:get_vh_session_list(LServer),
|
||||
announce_online1(Sessions, LServer, Packet),
|
||||
@ -922,7 +922,7 @@ send_motd(#jid{luser = LUser, lserver = LServer} = JID, mnesia) ->
|
||||
[#motd_users{}] ->
|
||||
ok;
|
||||
_ ->
|
||||
Local = jlib:make_jid(<<>>, LServer, <<>>),
|
||||
Local = jid:make(<<>>, LServer, <<>>),
|
||||
ejabberd_router:route(Local, JID, Packet),
|
||||
F = fun() ->
|
||||
mnesia:write(#motd_users{us = US})
|
||||
@ -940,7 +940,7 @@ send_motd(#jid{luser = LUser, lserver = LServer} = JID, riak) ->
|
||||
{ok, #motd_users{}} ->
|
||||
ok;
|
||||
_ ->
|
||||
Local = jlib:make_jid(<<>>, LServer, <<>>),
|
||||
Local = jid:make(<<>>, LServer, <<>>),
|
||||
ejabberd_router:route(Local, JID, Packet),
|
||||
{atomic, ejabberd_riak:put(
|
||||
#motd_users{us = US}, motd_users_schema(),
|
||||
@ -963,7 +963,7 @@ send_motd(#jid{luser = LUser, lserver = LServer} = JID, odbc) when LUser /= <<>>
|
||||
[<<"select username from motd "
|
||||
"where username='">>, Username, <<"';">>]) of
|
||||
{selected, [<<"username">>], []} ->
|
||||
Local = jlib:make_jid(<<"">>, LServer, <<"">>),
|
||||
Local = jid:make(<<"">>, LServer, <<"">>),
|
||||
ejabberd_router:route(Local, JID, Packet),
|
||||
F = fun() ->
|
||||
odbc_queries:update_t(
|
||||
@ -1038,10 +1038,10 @@ send_announcement_to_all(Host, SubjectS, BodyS) ->
|
||||
children = SubjectEls ++ BodyEls
|
||||
},
|
||||
Sessions = ejabberd_sm:dirty_get_sessions_list(),
|
||||
Local = jlib:make_jid(<<>>, Host, <<>>),
|
||||
Local = jid:make(<<>>, Host, <<>>),
|
||||
lists:foreach(
|
||||
fun({U, S, R}) ->
|
||||
Dest = jlib:make_jid(U, S, R),
|
||||
Dest = jid:make(U, S, R),
|
||||
ejabberd_router:route(Local, Dest, Packet)
|
||||
end, Sessions).
|
||||
|
||||
|
@ -118,7 +118,7 @@ parse_blocklist_items([#xmlel{name = <<"item">>,
|
||||
JIDs) ->
|
||||
case xml:get_attr(<<"jid">>, Attrs) of
|
||||
{value, JID1} ->
|
||||
JID = jlib:jid_tolower(jlib:string_to_jid(JID1)),
|
||||
JID = jid:tolower(jid:from_string(JID1)),
|
||||
parse_blocklist_items(Els, [JID | JIDs]);
|
||||
false -> parse_blocklist_items(Els, JIDs)
|
||||
end;
|
||||
@ -375,13 +375,13 @@ make_userlist(Name, List) ->
|
||||
#userlist{name = Name, list = List, needdb = NeedDb}.
|
||||
|
||||
broadcast_list_update(LUser, LServer, Name, UserList) ->
|
||||
ejabberd_sm:route(jlib:make_jid(LUser, LServer,
|
||||
ejabberd_sm:route(jid:make(LUser, LServer,
|
||||
<<"">>),
|
||||
jlib:make_jid(LUser, LServer, <<"">>),
|
||||
jid:make(LUser, LServer, <<"">>),
|
||||
{broadcast, {privacy_list, UserList, Name}}).
|
||||
|
||||
broadcast_blocklist_event(LUser, LServer, Event) ->
|
||||
JID = jlib:make_jid(LUser, LServer, <<"">>),
|
||||
JID = jid:make(LUser, LServer, <<"">>),
|
||||
ejabberd_sm:route(JID, JID,
|
||||
{broadcast, {blocking, Event}}).
|
||||
|
||||
@ -397,7 +397,7 @@ process_blocklist_get(LUser, LServer) ->
|
||||
#xmlel{name = <<"item">>,
|
||||
attrs =
|
||||
[{<<"jid">>,
|
||||
jlib:jid_to_string(JID)}],
|
||||
jid:to_string(JID)}],
|
||||
children = []}
|
||||
end,
|
||||
JIDs),
|
||||
|
@ -235,7 +235,7 @@ c2s_presence_in(C2SState,
|
||||
Delete = (Type == <<"unavailable">>) or
|
||||
(Type == <<"error">>),
|
||||
if Insert or Delete ->
|
||||
LFrom = jlib:jid_tolower(From),
|
||||
LFrom = jid:tolower(From),
|
||||
Rs = case ejabberd_c2s:get_aux_field(caps_resources,
|
||||
C2SState)
|
||||
of
|
||||
@ -269,7 +269,7 @@ c2s_presence_in(C2SState,
|
||||
c2s_filter_packet(InAcc, Host, C2SState, {pep_message, Feature}, To, _Packet) ->
|
||||
case ejabberd_c2s:get_aux_field(caps_resources, C2SState) of
|
||||
{ok, Rs} ->
|
||||
LTo = jlib:jid_tolower(To),
|
||||
LTo = jid:tolower(To),
|
||||
case gb_trees:lookup(LTo, Rs) of
|
||||
{value, Caps} ->
|
||||
Drop = not lists:member(Feature, get_features(Host, Caps)),
|
||||
@ -417,7 +417,7 @@ feature_request(Host, From, Caps,
|
||||
feature_response(IQReply, Host, From, Caps,
|
||||
SubNodes)
|
||||
end,
|
||||
ejabberd_local:route_iq(jlib:make_jid(<<"">>, Host,
|
||||
ejabberd_local:route_iq(jid:make(<<"">>, Host,
|
||||
<<"">>),
|
||||
From, IQ, F);
|
||||
true -> feature_request(Host, From, Caps, Tail)
|
||||
@ -449,7 +449,7 @@ feature_response(_IQResult, Host, From, Caps,
|
||||
feature_request(Host, From, Caps, SubNodes).
|
||||
|
||||
caps_read_fun(Host, Node) ->
|
||||
LServer = jlib:nameprep(Host),
|
||||
LServer = jid:nameprep(Host),
|
||||
DBType = gen_mod:db_type(LServer, ?MODULE),
|
||||
caps_read_fun(LServer, Node, DBType).
|
||||
|
||||
@ -488,7 +488,7 @@ caps_read_fun(LServer, {Node, SubNode}, odbc) ->
|
||||
end.
|
||||
|
||||
caps_write_fun(Host, Node, Features) ->
|
||||
LServer = jlib:nameprep(Host),
|
||||
LServer = jid:nameprep(Host),
|
||||
DBType = gen_mod:db_type(LServer, ?MODULE),
|
||||
caps_write_fun(LServer, Node, Features, DBType).
|
||||
|
||||
@ -511,7 +511,7 @@ caps_write_fun(LServer, NodePair, Features, odbc) ->
|
||||
end.
|
||||
|
||||
make_my_disco_hash(Host) ->
|
||||
JID = jlib:make_jid(<<"">>, Host, <<"">>),
|
||||
JID = jid:make(<<"">>, Host, <<"">>),
|
||||
case {ejabberd_hooks:run_fold(disco_local_features,
|
||||
Host, empty, [JID, JID, <<"">>, <<"">>]),
|
||||
ejabberd_hooks:run_fold(disco_local_identity, Host, [],
|
||||
|
@ -104,7 +104,7 @@ iq_handler1(From, To, IQ) ->
|
||||
|
||||
iq_handler(From, _To, #iq{type=set, sub_el = #xmlel{name = Operation, children = []}} = IQ, CC)->
|
||||
?DEBUG("carbons IQ received: ~p", [IQ]),
|
||||
{U, S, R} = jlib:jid_tolower(From),
|
||||
{U, S, R} = jid:tolower(From),
|
||||
Result = case Operation of
|
||||
<<"enable">>->
|
||||
?INFO_MSG("carbons enabled for user ~s@~s/~s", [U,S,R]),
|
||||
@ -161,7 +161,7 @@ remove_connection(User, Server, Resource, _Status)->
|
||||
%%% Internal
|
||||
%% Direction = received | sent <received xmlns='urn:xmpp:carbons:1'/>
|
||||
send_copies(JID, To, Packet, Direction)->
|
||||
{U, S, R} = jlib:jid_tolower(JID),
|
||||
{U, S, R} = jid:tolower(JID),
|
||||
PrioRes = ejabberd_sm:get_user_present_resources(U, S),
|
||||
{_, AvailRs} = lists:unzip(PrioRes),
|
||||
{MaxPrio, MaxRes} = case catch lists:max(PrioRes) of
|
||||
@ -180,7 +180,7 @@ send_copies(JID, To, Packet, Direction)->
|
||||
TargetJIDs = case {IsBareTo, R} of
|
||||
{true, MaxRes} ->
|
||||
OrigTo = fun(Res) -> lists:member({MaxPrio, Res}, PrioRes) end,
|
||||
[ {jlib:make_jid({U, S, CCRes}), CC_Version}
|
||||
[ {jid:make({U, S, CCRes}), CC_Version}
|
||||
|| {CCRes, CC_Version} <- list(U, S),
|
||||
lists:member(CCRes, AvailRs), not OrigTo(CCRes) ];
|
||||
{true, _} ->
|
||||
@ -191,16 +191,16 @@ send_copies(JID, To, Packet, Direction)->
|
||||
%% MaxRes) in order to avoid duplicates.
|
||||
[];
|
||||
{false, _} ->
|
||||
[ {jlib:make_jid({U, S, CCRes}), CC_Version}
|
||||
[ {jid:make({U, S, CCRes}), CC_Version}
|
||||
|| {CCRes, CC_Version} <- list(U, S),
|
||||
lists:member(CCRes, AvailRs), CCRes /= R ]
|
||||
%TargetJIDs = lists:delete(JID, [ jlib:make_jid({U, S, CCRes}) || CCRes <- list(U, S) ]),
|
||||
%TargetJIDs = lists:delete(JID, [ jid:make({U, S, CCRes}) || CCRes <- list(U, S) ]),
|
||||
end,
|
||||
|
||||
lists:map(fun({Dest,Version}) ->
|
||||
{_, _, Resource} = jlib:jid_tolower(Dest),
|
||||
{_, _, Resource} = jid:tolower(Dest),
|
||||
?DEBUG("Sending: ~p =/= ~p", [R, Resource]),
|
||||
Sender = jlib:make_jid({U, S, <<>>}),
|
||||
Sender = jid:make({U, S, <<>>}),
|
||||
%{xmlelement, N, A, C} = Packet,
|
||||
New = build_forward_packet(JID, Packet, Sender, Dest, Direction, Version),
|
||||
ejabberd_router:route(Sender, Dest, New)
|
||||
@ -211,8 +211,8 @@ build_forward_packet(JID, Packet, Sender, Dest, Direction, ?NS_CARBONS_2) ->
|
||||
#xmlel{name = <<"message">>,
|
||||
attrs = [{<<"xmlns">>, <<"jabber:client">>},
|
||||
{<<"type">>, message_type(Packet)},
|
||||
{<<"from">>, jlib:jid_to_string(Sender)},
|
||||
{<<"to">>, jlib:jid_to_string(Dest)}],
|
||||
{<<"from">>, jid:to_string(Sender)},
|
||||
{<<"to">>, jid:to_string(Dest)}],
|
||||
children = [
|
||||
#xmlel{name = list_to_binary(atom_to_list(Direction)),
|
||||
attrs = [{<<"xmlns">>, ?NS_CARBONS_2}],
|
||||
@ -227,8 +227,8 @@ build_forward_packet(JID, Packet, Sender, Dest, Direction, ?NS_CARBONS_1) ->
|
||||
#xmlel{name = <<"message">>,
|
||||
attrs = [{<<"xmlns">>, <<"jabber:client">>},
|
||||
{<<"type">>, message_type(Packet)},
|
||||
{<<"from">>, jlib:jid_to_string(Sender)},
|
||||
{<<"to">>, jlib:jid_to_string(Dest)}],
|
||||
{<<"from">>, jid:to_string(Sender)},
|
||||
{<<"to">>, jid:to_string(Dest)}],
|
||||
children = [
|
||||
#xmlel{name = list_to_binary(atom_to_list(Direction)),
|
||||
attrs = [{<<"xmlns">>, ?NS_CARBONS_1}]},
|
||||
@ -259,7 +259,7 @@ complete_packet(From, #xmlel{name = <<"message">>, attrs = OrigAttrs} = Packet,
|
||||
Attrs = lists:keystore(<<"xmlns">>, 1, OrigAttrs, {<<"xmlns">>, <<"jabber:client">>}),
|
||||
case proplists:get_value(<<"from">>, Attrs) of
|
||||
undefined ->
|
||||
Packet#xmlel{attrs = [{<<"from">>, jlib:jid_to_string(From)}|Attrs]};
|
||||
Packet#xmlel{attrs = [{<<"from">>, jid:to_string(From)}|Attrs]};
|
||||
_ ->
|
||||
Packet#xmlel{attrs = Attrs}
|
||||
end;
|
||||
|
@ -114,7 +114,7 @@ stop(Host) ->
|
||||
-define(NODEJID(To, Name, Node),
|
||||
#xmlel{name = <<"item">>,
|
||||
attrs =
|
||||
[{<<"jid">>, jlib:jid_to_string(To)},
|
||||
[{<<"jid">>, jid:to_string(To)},
|
||||
{<<"name">>, ?T(Lang, Name)}, {<<"node">>, Node}],
|
||||
children = []}).
|
||||
|
||||
@ -292,7 +292,7 @@ adhoc_sm_items(Acc, From, #jid{lserver = LServer} = To,
|
||||
end,
|
||||
Nodes = [#xmlel{name = <<"item">>,
|
||||
attrs =
|
||||
[{<<"jid">>, jlib:jid_to_string(To)},
|
||||
[{<<"jid">>, jid:to_string(To)},
|
||||
{<<"name">>, ?T(Lang, <<"Configuration">>)},
|
||||
{<<"node">>, <<"config">>}],
|
||||
children = []}],
|
||||
@ -415,7 +415,7 @@ get_permission_level(JID) ->
|
||||
allow ->
|
||||
PermLev = get_permission_level(From),
|
||||
case get_local_items({PermLev, LServer}, LNode,
|
||||
jlib:jid_to_string(To), Lang)
|
||||
jid:to_string(To), Lang)
|
||||
of
|
||||
{result, Res} -> {result, Res};
|
||||
{error, Error} -> {error, Error}
|
||||
@ -437,7 +437,7 @@ get_local_items(Acc, From, #jid{lserver = LServer} = To,
|
||||
allow ->
|
||||
PermLev = get_permission_level(From),
|
||||
case get_local_items({PermLev, LServer}, [],
|
||||
jlib:jid_to_string(To), Lang)
|
||||
jid:to_string(To), Lang)
|
||||
of
|
||||
{result, Res} -> {result, Items ++ Res};
|
||||
{error, _Error} -> {result, Items}
|
||||
@ -1817,7 +1817,7 @@ set_form(From, Host, ?NS_ADMINL(<<"add-user">>), _Lang,
|
||||
AccountString = get_value(<<"accountjid">>, XData),
|
||||
Password = get_value(<<"password">>, XData),
|
||||
Password = get_value(<<"password-verify">>, XData),
|
||||
AccountJID = jlib:string_to_jid(AccountString),
|
||||
AccountJID = jid:from_string(AccountString),
|
||||
User = AccountJID#jid.luser,
|
||||
Server = AccountJID#jid.lserver,
|
||||
true = lists:member(Server, ?MYHOSTS),
|
||||
@ -1831,7 +1831,7 @@ set_form(From, Host, ?NS_ADMINL(<<"delete-user">>),
|
||||
XData),
|
||||
[_ | _] = AccountStringList,
|
||||
ASL2 = lists:map(fun (AccountString) ->
|
||||
JID = jlib:string_to_jid(AccountString),
|
||||
JID = jid:from_string(AccountString),
|
||||
User = JID#jid.luser,
|
||||
Server = JID#jid.lserver,
|
||||
true = Server == Host orelse
|
||||
@ -1846,7 +1846,7 @@ set_form(From, Host, ?NS_ADMINL(<<"delete-user">>),
|
||||
set_form(From, Host, ?NS_ADMINL(<<"end-user-session">>),
|
||||
Lang, XData) ->
|
||||
AccountString = get_value(<<"accountjid">>, XData),
|
||||
JID = jlib:string_to_jid(AccountString),
|
||||
JID = jid:from_string(AccountString),
|
||||
LUser = JID#jid.luser,
|
||||
LServer = JID#jid.lserver,
|
||||
true = LServer == Host orelse
|
||||
@ -1872,7 +1872,7 @@ set_form(From, Host, ?NS_ADMINL(<<"end-user-session">>),
|
||||
set_form(From, Host,
|
||||
?NS_ADMINL(<<"get-user-password">>), Lang, XData) ->
|
||||
AccountString = get_value(<<"accountjid">>, XData),
|
||||
JID = jlib:string_to_jid(AccountString),
|
||||
JID = jid:from_string(AccountString),
|
||||
User = JID#jid.luser,
|
||||
Server = JID#jid.lserver,
|
||||
true = Server == Host orelse
|
||||
@ -1892,7 +1892,7 @@ set_form(From, Host,
|
||||
?NS_ADMINL(<<"change-user-password">>), _Lang, XData) ->
|
||||
AccountString = get_value(<<"accountjid">>, XData),
|
||||
Password = get_value(<<"password">>, XData),
|
||||
JID = jlib:string_to_jid(AccountString),
|
||||
JID = jid:from_string(AccountString),
|
||||
User = JID#jid.luser,
|
||||
Server = JID#jid.lserver,
|
||||
true = Server == Host orelse
|
||||
@ -1903,7 +1903,7 @@ set_form(From, Host,
|
||||
set_form(From, Host,
|
||||
?NS_ADMINL(<<"get-user-lastlogin">>), Lang, XData) ->
|
||||
AccountString = get_value(<<"accountjid">>, XData),
|
||||
JID = jlib:string_to_jid(AccountString),
|
||||
JID = jid:from_string(AccountString),
|
||||
User = JID#jid.luser,
|
||||
Server = JID#jid.lserver,
|
||||
true = Server == Host orelse
|
||||
@ -1938,7 +1938,7 @@ set_form(From, Host,
|
||||
set_form(From, Host, ?NS_ADMINL(<<"user-stats">>), Lang,
|
||||
XData) ->
|
||||
AccountString = get_value(<<"accountjid">>, XData),
|
||||
JID = jlib:string_to_jid(AccountString),
|
||||
JID = jid:from_string(AccountString),
|
||||
User = JID#jid.luser,
|
||||
Server = JID#jid.lserver,
|
||||
true = Server == Host orelse
|
||||
@ -2031,7 +2031,7 @@ stop_node(From, Host, ENode, Action, XData) ->
|
||||
?NS_XDATA},
|
||||
{<<"type">>, <<"submit">>}],
|
||||
children = SubEls}]},
|
||||
To = jlib:make_jid(<<"">>, Host, <<"">>),
|
||||
To = jid:make(<<"">>, Host, <<"">>),
|
||||
mod_announce:announce_commands(empty, From, To, Request)
|
||||
end,
|
||||
Time = timer:seconds(Delay),
|
||||
|
@ -167,7 +167,7 @@ code_change(_OldVsn, State, _Extra) -> {ok, State}.
|
||||
%% Finally, the received response is printed in the ejabberd log file.
|
||||
do_client_version(disabled, _From, _To) -> ok;
|
||||
do_client_version(enabled, From, To) ->
|
||||
ToS = jlib:jid_to_string(To),
|
||||
ToS = jid:to_string(To),
|
||||
Random_resource =
|
||||
iolist_to_binary(integer_to_list(random:uniform(100000))),
|
||||
From2 = From#jid{resource = Random_resource,
|
||||
|
@ -114,7 +114,7 @@ check_permissions(#request{auth = HTTPAuth, headers = Headers}, Command)
|
||||
Auth =
|
||||
case HTTPAuth of
|
||||
{SJID, Pass} ->
|
||||
case jlib:string_to_jid(SJID) of
|
||||
case jid:from_string(SJID) of
|
||||
#jid{user = User, server = Server} ->
|
||||
case ejabberd_auth:check_password(User, Server, Pass) of
|
||||
true -> {ok, {User, Server, Pass, Admin}};
|
||||
|
@ -560,12 +560,12 @@ process_iq(From,
|
||||
end;
|
||||
{error, Error} ->
|
||||
?DEBUG("Cannot parse request from ~s",
|
||||
[jlib:jid_to_string(From)]),
|
||||
[jid:to_string(From)]),
|
||||
IQ#iq{type = error, sub_el = [SubEl, Error]}
|
||||
end;
|
||||
deny ->
|
||||
?DEBUG("Denying HTTP upload slot request from ~s",
|
||||
[jlib:jid_to_string(From)]),
|
||||
[jid:to_string(From)]),
|
||||
IQ#iq{type = error, sub_el = [SubEl, ?ERR_FORBIDDEN]}
|
||||
end;
|
||||
process_iq(_From, #iq{sub_el = SubEl} = IQ, _State) ->
|
||||
@ -611,7 +611,7 @@ create_slot(#state{service_url = undefined, max_size = MaxSize},
|
||||
Text = <<"File larger than ", (jlib:integer_to_binary(MaxSize))/binary,
|
||||
" Bytes.">>,
|
||||
?INFO_MSG("Rejecting file ~s from ~s (too large: ~B bytes)",
|
||||
[File, jlib:jid_to_string(JID), Size]),
|
||||
[File, jid:to_string(JID), Size]),
|
||||
{error, ?ERRT_NOT_ACCEPTABLE(Lang, Text)};
|
||||
create_slot(#state{service_url = undefined,
|
||||
jid_in_url = JIDinURL,
|
||||
@ -627,7 +627,7 @@ create_slot(#state{service_url = undefined,
|
||||
RandStr = make_rand_string(SecretLength),
|
||||
FileStr = make_file_string(File),
|
||||
?INFO_MSG("Got HTTP upload slot for ~s (file: ~s)",
|
||||
[jlib:jid_to_string(JID), File]),
|
||||
[jid:to_string(JID), File]),
|
||||
{ok, [UserStr, RandStr, FileStr]};
|
||||
deny ->
|
||||
{error, ?ERR_SERVICE_UNAVAILABLE};
|
||||
@ -641,7 +641,7 @@ create_slot(#state{service_url = ServiceURL},
|
||||
HttpOptions = [{timeout, ?SERVICE_REQUEST_TIMEOUT}],
|
||||
SizeStr = jlib:integer_to_binary(Size),
|
||||
GetRequest = binary_to_list(ServiceURL) ++
|
||||
"?jid=" ++ ?URL_ENC(jlib:jid_to_string({U, S, <<"">>})) ++
|
||||
"?jid=" ++ ?URL_ENC(jid:to_string({U, S, <<"">>})) ++
|
||||
"&name=" ++ ?URL_ENC(File) ++
|
||||
"&size=" ++ ?URL_ENC(SizeStr) ++
|
||||
"&content_type=" ++ ?URL_ENC(ContentType),
|
||||
@ -651,32 +651,32 @@ create_slot(#state{service_url = ServiceURL},
|
||||
[<<"http", _/binary>> = PutURL,
|
||||
<<"http", _/binary>> = GetURL] ->
|
||||
?INFO_MSG("Got HTTP upload slot for ~s (file: ~s)",
|
||||
[jlib:jid_to_string(JID), File]),
|
||||
[jid:to_string(JID), File]),
|
||||
{ok, PutURL, GetURL};
|
||||
Lines ->
|
||||
?ERROR_MSG("Can't parse data received for ~s from <~s>: ~p",
|
||||
[jlib:jid_to_string(JID), ServiceURL, Lines]),
|
||||
[jid:to_string(JID), ServiceURL, Lines]),
|
||||
{error, ?ERR_SERVICE_UNAVAILABLE}
|
||||
end;
|
||||
{ok, {402, _Body}} ->
|
||||
?INFO_MSG("Got status code 402 for ~s from <~s>",
|
||||
[jlib:jid_to_string(JID), ServiceURL]),
|
||||
[jid:to_string(JID), ServiceURL]),
|
||||
{error, ?ERR_RESOURCE_CONSTRAINT};
|
||||
{ok, {403, _Body}} ->
|
||||
?INFO_MSG("Got status code 403 for ~s from <~s>",
|
||||
[jlib:jid_to_string(JID), ServiceURL]),
|
||||
[jid:to_string(JID), ServiceURL]),
|
||||
{error, ?ERR_NOT_ALLOWED};
|
||||
{ok, {413, _Body}} ->
|
||||
?INFO_MSG("Got status code 413 for ~s from <~s>",
|
||||
[jlib:jid_to_string(JID), ServiceURL]),
|
||||
[jid:to_string(JID), ServiceURL]),
|
||||
{error, ?ERR_NOT_ACCEPTABLE};
|
||||
{ok, {Code, _Body}} ->
|
||||
?ERROR_MSG("Got unexpected status code for ~s from <~s>: ~B",
|
||||
[jlib:jid_to_string(JID), ServiceURL, Code]),
|
||||
[jid:to_string(JID), ServiceURL, Code]),
|
||||
{error, ?ERR_SERVICE_UNAVAILABLE};
|
||||
{error, Reason} ->
|
||||
?ERROR_MSG("Error requesting upload slot for ~s from <~s>: ~p",
|
||||
[jlib:jid_to_string(JID), ServiceURL, Reason]),
|
||||
[jid:to_string(JID), ServiceURL, Reason]),
|
||||
{error, ?ERR_SERVICE_UNAVAILABLE}
|
||||
end.
|
||||
|
||||
@ -959,7 +959,7 @@ thumb_el(Path, URI) ->
|
||||
-spec remove_user(binary(), binary()) -> ok.
|
||||
|
||||
remove_user(User, Server) ->
|
||||
ServerHost = jlib:nameprep(Server),
|
||||
ServerHost = jid:nameprep(Server),
|
||||
DocRoot = gen_mod:get_module_opt(ServerHost, ?MODULE, docroot,
|
||||
fun iolist_to_binary/1,
|
||||
<<"@HOME@/upload">>),
|
||||
@ -968,7 +968,7 @@ remove_user(User, Server) ->
|
||||
(node) -> node
|
||||
end,
|
||||
sha1),
|
||||
UserStr = make_user_string(jlib:make_jid(User, Server, <<"">>), JIDinURL),
|
||||
UserStr = make_user_string(jid:make(User, Server, <<"">>), JIDinURL),
|
||||
UserDir = str:join([expand_home(DocRoot), UserStr], <<$/>>),
|
||||
case del_tree(UserDir) of
|
||||
ok ->
|
||||
|
@ -181,24 +181,24 @@ handle_cast({handle_slot_request, #jid{user = U, server = S} = JID, Path, Size},
|
||||
NewSize = case {HardQuota, SoftQuota} of
|
||||
{0, 0} ->
|
||||
?DEBUG("No quota specified for ~s",
|
||||
[jlib:jid_to_string(JID)]),
|
||||
[jid:to_string(JID)]),
|
||||
undefined;
|
||||
{0, _} ->
|
||||
?WARNING_MSG("No hard quota specified for ~s",
|
||||
[jlib:jid_to_string(JID)]),
|
||||
[jid:to_string(JID)]),
|
||||
enforce_quota(Path, Size, OldSize, SoftQuota, SoftQuota);
|
||||
{_, 0} ->
|
||||
?WARNING_MSG("No soft quota specified for ~s",
|
||||
[jlib:jid_to_string(JID)]),
|
||||
[jid:to_string(JID)]),
|
||||
enforce_quota(Path, Size, OldSize, HardQuota, HardQuota);
|
||||
_ when SoftQuota > HardQuota ->
|
||||
?WARNING_MSG("Bad quota for ~s (soft: ~p, hard: ~p)",
|
||||
[jlib:jid_to_string(JID),
|
||||
[jid:to_string(JID),
|
||||
SoftQuota, HardQuota]),
|
||||
enforce_quota(Path, Size, OldSize, SoftQuota, SoftQuota);
|
||||
_ ->
|
||||
?DEBUG("Enforcing quota for ~s",
|
||||
[jlib:jid_to_string(JID)]),
|
||||
[jid:to_string(JID)]),
|
||||
enforce_quota(Path, Size, OldSize, SoftQuota, HardQuota)
|
||||
end,
|
||||
NewDiskUsage = if is_integer(NewSize) ->
|
||||
|
@ -578,7 +578,7 @@ process_irc_register(ServerHost, Host, From, _To,
|
||||
end.
|
||||
|
||||
get_data(ServerHost, Host, From) ->
|
||||
LServer = jlib:nameprep(ServerHost),
|
||||
LServer = jid:nameprep(ServerHost),
|
||||
get_data(LServer, Host, From,
|
||||
gen_mod:db_type(LServer, ?MODULE)).
|
||||
|
||||
@ -604,7 +604,7 @@ get_data(LServer, Host, From, riak) ->
|
||||
end;
|
||||
get_data(LServer, Host, From, odbc) ->
|
||||
SJID =
|
||||
ejabberd_odbc:escape(jlib:jid_to_string(jlib:jid_tolower(jlib:jid_remove_resource(From)))),
|
||||
ejabberd_odbc:escape(jid:to_string(jid:tolower(jid:remove_resource(From)))),
|
||||
SHost = ejabberd_odbc:escape(Host),
|
||||
case catch ejabberd_odbc:sql_query(LServer,
|
||||
[<<"select data from irc_custom where jid='">>,
|
||||
@ -722,12 +722,12 @@ get_form(_ServerHost, _Host, _, _, _Lang) ->
|
||||
{error, ?ERR_SERVICE_UNAVAILABLE}.
|
||||
|
||||
set_data(ServerHost, Host, From, Data) ->
|
||||
LServer = jlib:nameprep(ServerHost),
|
||||
LServer = jid:nameprep(ServerHost),
|
||||
set_data(LServer, Host, From, data_to_binary(From, Data),
|
||||
gen_mod:db_type(LServer, ?MODULE)).
|
||||
|
||||
set_data(_LServer, Host, From, Data, mnesia) ->
|
||||
{LUser, LServer, _} = jlib:jid_tolower(From),
|
||||
{LUser, LServer, _} = jid:tolower(From),
|
||||
US = {LUser, LServer},
|
||||
F = fun () ->
|
||||
mnesia:write(#irc_custom{us_host = {US, Host},
|
||||
@ -735,14 +735,14 @@ set_data(_LServer, Host, From, Data, mnesia) ->
|
||||
end,
|
||||
mnesia:transaction(F);
|
||||
set_data(LServer, Host, From, Data, riak) ->
|
||||
{LUser, LServer, _} = jlib:jid_tolower(From),
|
||||
{LUser, LServer, _} = jid:tolower(From),
|
||||
US = {LUser, LServer},
|
||||
{atomic, ejabberd_riak:put(#irc_custom{us_host = {US, Host},
|
||||
data = Data},
|
||||
irc_custom_schema())};
|
||||
set_data(LServer, Host, From, Data, odbc) ->
|
||||
SJID =
|
||||
ejabberd_odbc:escape(jlib:jid_to_string(jlib:jid_tolower(jlib:jid_remove_resource(From)))),
|
||||
ejabberd_odbc:escape(jid:to_string(jid:tolower(jid:remove_resource(From)))),
|
||||
SHost = ejabberd_odbc:escape(Host),
|
||||
SData = ejabberd_odbc:encode_term(Data),
|
||||
F = fun () ->
|
||||
@ -921,7 +921,7 @@ adhoc_join(From, To,
|
||||
<<"invite">>,
|
||||
attrs =
|
||||
[{<<"from">>,
|
||||
jlib:jid_to_string(From)}],
|
||||
jid:to_string(From)}],
|
||||
children =
|
||||
[#xmlel{name
|
||||
=
|
||||
@ -952,7 +952,7 @@ adhoc_join(From, To,
|
||||
Lang,
|
||||
<<"Join the IRC channel in this Jabber ID: ~s">>),
|
||||
[RoomJID]))}]}]},
|
||||
ejabberd_router:route(jlib:string_to_jid(RoomJID), From,
|
||||
ejabberd_router:route(jid:from_string(RoomJID), From,
|
||||
Invite),
|
||||
adhoc:produce_response(Request,
|
||||
#adhoc_response{status =
|
||||
@ -1248,7 +1248,7 @@ data_to_binary(JID, Data) ->
|
||||
?ERROR_MSG("failed to convert "
|
||||
"parameter ~p for user ~s",
|
||||
[Param,
|
||||
jlib:jid_to_string(JID)]);
|
||||
jid:to_string(JID)]);
|
||||
true ->
|
||||
?ERROR_MSG("failed to convert "
|
||||
"parameter ~p",
|
||||
@ -1295,7 +1295,7 @@ update_table() ->
|
||||
fun(#irc_custom{us_host = {_, H}}) -> H end,
|
||||
fun(#irc_custom{us_host = {{U, S}, H},
|
||||
data = Data} = R) ->
|
||||
JID = jlib:make_jid(U, S, <<"">>),
|
||||
JID = jid:make(U, S, <<"">>),
|
||||
R#irc_custom{us_host = {{iolist_to_binary(U),
|
||||
iolist_to_binary(S)},
|
||||
iolist_to_binary(H)},
|
||||
@ -1313,8 +1313,8 @@ export(_Server) ->
|
||||
case str:suffix(Host, IRCHost) of
|
||||
true ->
|
||||
SJID = ejabberd_odbc:escape(
|
||||
jlib:jid_to_string(
|
||||
jlib:make_jid(U, S, <<"">>))),
|
||||
jid:to_string(
|
||||
jid:make(U, S, <<"">>))),
|
||||
SIRCHost = ejabberd_odbc:escape(IRCHost),
|
||||
SData = ejabberd_odbc:encode_term(Data),
|
||||
[[<<"delete from irc_custom where jid='">>, SJID,
|
||||
@ -1331,7 +1331,7 @@ export(_Server) ->
|
||||
import(_LServer) ->
|
||||
[{<<"select jid, host, data from irc_custom;">>,
|
||||
fun([SJID, IRCHost, SData]) ->
|
||||
#jid{luser = U, lserver = S} = jlib:string_to_jid(SJID),
|
||||
#jid{luser = U, lserver = S} = jid:from_string(SJID),
|
||||
Data = ejabberd_odbc:decode_term(SData),
|
||||
#irc_custom{us_host = {{U, S}, IRCHost},
|
||||
data = Data}
|
||||
|
@ -306,7 +306,7 @@ handle_info({route_chan, Channel, Resource,
|
||||
of
|
||||
<<"">> ->
|
||||
ejabberd_router:route(
|
||||
jlib:make_jid(
|
||||
jid:make(
|
||||
iolist_to_binary([Channel,
|
||||
<<"%">>,
|
||||
StateData#state.server]),
|
||||
@ -430,7 +430,7 @@ handle_info({route_chan, Channel, Resource,
|
||||
#xmlel{name = <<"iq">>} = El},
|
||||
StateName, StateData) ->
|
||||
From = StateData#state.user,
|
||||
To = jlib:make_jid(iolist_to_binary([Channel, <<"%">>,
|
||||
To = jid:make(iolist_to_binary([Channel, <<"%">>,
|
||||
StateData#state.server]),
|
||||
StateData#state.host, StateData#state.nick),
|
||||
_ = case jlib:iq_query_info(El) of
|
||||
@ -716,7 +716,7 @@ terminate(_Reason, _StateName, FullStateData) ->
|
||||
|
||||
send_stanza(Chan, StateData, Stanza) ->
|
||||
ejabberd_router:route(
|
||||
jlib:make_jid(
|
||||
jid:make(
|
||||
iolist_to_binary([Chan,
|
||||
<<"%">>,
|
||||
StateData#state.server]),
|
||||
@ -770,9 +770,9 @@ bounce_messages(Reason) ->
|
||||
<<"error">> -> ok;
|
||||
_ ->
|
||||
Err = jlib:make_error_reply(El, <<"502">>, Reason),
|
||||
From = jlib:string_to_jid(xml:get_attr_s(<<"from">>,
|
||||
From = jid:from_string(xml:get_attr_s(<<"from">>,
|
||||
Attrs)),
|
||||
To = jlib:string_to_jid(xml:get_attr_s(<<"to">>,
|
||||
To = jid:from_string(xml:get_attr_s(<<"to">>,
|
||||
Attrs)),
|
||||
ejabberd_router:route(To, From, Err)
|
||||
end,
|
||||
@ -830,7 +830,7 @@ process_channel_list_user(StateData, Chan, User) ->
|
||||
{U2, <<"admin">>, <<"moderator">>};
|
||||
_ -> {User1, <<"member">>, <<"participant">>}
|
||||
end,
|
||||
ejabberd_router:route(jlib:make_jid(iolist_to_binary([Chan,
|
||||
ejabberd_router:route(jid:make(iolist_to_binary([Chan,
|
||||
<<"%">>,
|
||||
StateData#state.server]),
|
||||
StateData#state.host, User2),
|
||||
@ -860,7 +860,7 @@ process_channel_topic(StateData, Chan, String) ->
|
||||
Msg = ejabberd_regexp:replace(String, <<".*332[^:]*:">>,
|
||||
<<"">>),
|
||||
Msg1 = filter_message(Msg),
|
||||
ejabberd_router:route(jlib:make_jid(iolist_to_binary([Chan,
|
||||
ejabberd_router:route(jid:make(iolist_to_binary([Chan,
|
||||
<<"%">>,
|
||||
StateData#state.server]),
|
||||
StateData#state.host, <<"">>),
|
||||
@ -889,7 +889,7 @@ process_channel_topic_who(StateData, Chan, String) ->
|
||||
_ -> String
|
||||
end,
|
||||
Msg2 = filter_message(Msg1),
|
||||
ejabberd_router:route(jlib:make_jid(iolist_to_binary([Chan,
|
||||
ejabberd_router:route(jid:make(iolist_to_binary([Chan,
|
||||
<<"%">>,
|
||||
StateData#state.server]),
|
||||
StateData#state.host, <<"">>),
|
||||
@ -921,7 +921,7 @@ process_nick_in_use(StateData, String) ->
|
||||
% Shouldn't happen with a well behaved server
|
||||
StateData;
|
||||
Chan ->
|
||||
ejabberd_router:route(jlib:make_jid(iolist_to_binary([Chan,
|
||||
ejabberd_router:route(jid:make(iolist_to_binary([Chan,
|
||||
<<"%">>,
|
||||
StateData#state.server]),
|
||||
StateData#state.host,
|
||||
@ -938,7 +938,7 @@ process_num_error(StateData, String) ->
|
||||
<<"continue">>),
|
||||
lists:foreach(fun (Chan) ->
|
||||
ejabberd_router:route(
|
||||
jlib:make_jid(
|
||||
jid:make(
|
||||
iolist_to_binary(
|
||||
[Chan,
|
||||
<<"%">>,
|
||||
@ -956,7 +956,7 @@ process_num_error(StateData, String) ->
|
||||
StateData.
|
||||
|
||||
process_endofwhois(StateData, _String, Nick) ->
|
||||
ejabberd_router:route(jlib:make_jid(iolist_to_binary([Nick,
|
||||
ejabberd_router:route(jid:make(iolist_to_binary([Nick,
|
||||
<<"!">>,
|
||||
StateData#state.server]),
|
||||
StateData#state.host, <<"">>),
|
||||
@ -973,7 +973,7 @@ process_whois311(StateData, String, Nick, Ident,
|
||||
Irchost) ->
|
||||
Fullname = ejabberd_regexp:replace(String,
|
||||
<<".*311[^:]*:">>, <<"">>),
|
||||
ejabberd_router:route(jlib:make_jid(iolist_to_binary([Nick,
|
||||
ejabberd_router:route(jid:make(iolist_to_binary([Nick,
|
||||
<<"!">>,
|
||||
StateData#state.server]),
|
||||
StateData#state.host, <<"">>),
|
||||
@ -997,7 +997,7 @@ process_whois311(StateData, String, Nick, Ident,
|
||||
process_whois312(StateData, String, Nick, Ircserver) ->
|
||||
Ircserverdesc = ejabberd_regexp:replace(String,
|
||||
<<".*312[^:]*:">>, <<"">>),
|
||||
ejabberd_router:route(jlib:make_jid(iolist_to_binary([Nick,
|
||||
ejabberd_router:route(jid:make(iolist_to_binary([Nick,
|
||||
<<"!">>,
|
||||
StateData#state.server]),
|
||||
StateData#state.host, <<"">>),
|
||||
@ -1019,7 +1019,7 @@ process_whois312(StateData, String, Nick, Ircserver) ->
|
||||
process_whois319(StateData, String, Nick) ->
|
||||
Chanlist = ejabberd_regexp:replace(String,
|
||||
<<".*319[^:]*:">>, <<"">>),
|
||||
ejabberd_router:route(jlib:make_jid(iolist_to_binary(
|
||||
ejabberd_router:route(jid:make(iolist_to_binary(
|
||||
[Nick,
|
||||
<<"!">>,
|
||||
StateData#state.server]),
|
||||
@ -1047,7 +1047,7 @@ process_chanprivmsg(StateData, Chan, From, String) ->
|
||||
_ -> Msg
|
||||
end,
|
||||
Msg2 = filter_message(Msg1),
|
||||
ejabberd_router:route(jlib:make_jid(iolist_to_binary(
|
||||
ejabberd_router:route(jid:make(iolist_to_binary(
|
||||
[Chan,
|
||||
<<"%">>,
|
||||
StateData#state.server]),
|
||||
@ -1069,7 +1069,7 @@ process_channotice(StateData, Chan, From, String) ->
|
||||
_ -> <<"/me NOTICE: ", Msg/binary>>
|
||||
end,
|
||||
Msg2 = filter_message(Msg1),
|
||||
ejabberd_router:route(jlib:make_jid(iolist_to_binary(
|
||||
ejabberd_router:route(jid:make(iolist_to_binary(
|
||||
[Chan,
|
||||
<<"%">>,
|
||||
StateData#state.server]),
|
||||
@ -1091,7 +1091,7 @@ process_privmsg(StateData, _Nick, From, String) ->
|
||||
_ -> Msg
|
||||
end,
|
||||
Msg2 = filter_message(Msg1),
|
||||
ejabberd_router:route(jlib:make_jid(iolist_to_binary(
|
||||
ejabberd_router:route(jid:make(iolist_to_binary(
|
||||
[FromUser,
|
||||
<<"!">>,
|
||||
StateData#state.server]),
|
||||
@ -1113,7 +1113,7 @@ process_notice(StateData, _Nick, From, String) ->
|
||||
_ -> <<"/me NOTICE: ", Msg/binary>>
|
||||
end,
|
||||
Msg2 = filter_message(Msg1),
|
||||
ejabberd_router:route(jlib:make_jid(iolist_to_binary(
|
||||
ejabberd_router:route(jid:make(iolist_to_binary(
|
||||
[FromUser,
|
||||
<<"!">>,
|
||||
StateData#state.server]),
|
||||
@ -1141,14 +1141,14 @@ process_userinfo(StateData, _Nick, From) ->
|
||||
send_text(StateData,
|
||||
io_lib:format("NOTICE ~s :\001USERINFO xmpp:~s\001\r\n",
|
||||
[FromUser,
|
||||
jlib:jid_to_string(StateData#state.user)])).
|
||||
jid:to_string(StateData#state.user)])).
|
||||
|
||||
process_topic(StateData, Chan, From, String) ->
|
||||
[FromUser | _] = str:tokens(From, <<"!">>),
|
||||
Msg = ejabberd_regexp:replace(String,
|
||||
<<".*TOPIC[^:]*:">>, <<"">>),
|
||||
Msg1 = filter_message(Msg),
|
||||
ejabberd_router:route(jlib:make_jid(iolist_to_binary(
|
||||
ejabberd_router:route(jid:make(iolist_to_binary(
|
||||
[Chan,
|
||||
<<"%">>,
|
||||
StateData#state.server]),
|
||||
@ -1170,7 +1170,7 @@ process_part(StateData, Chan, From, String) ->
|
||||
Msg = ejabberd_regexp:replace(String,
|
||||
<<".*PART[^:]*:">>, <<"">>),
|
||||
Msg1 = filter_message(Msg),
|
||||
ejabberd_router:route(jlib:make_jid(iolist_to_binary(
|
||||
ejabberd_router:route(jid:make(iolist_to_binary(
|
||||
[Chan,
|
||||
<<"%">>,
|
||||
StateData#state.server]),
|
||||
@ -1212,7 +1212,7 @@ process_quit(StateData, From, String) ->
|
||||
dict:map(fun (Chan, Ps) ->
|
||||
case (?SETS):is_member(FromUser, Ps) of
|
||||
true ->
|
||||
ejabberd_router:route(jlib:make_jid(iolist_to_binary(
|
||||
ejabberd_router:route(jid:make(iolist_to_binary(
|
||||
[Chan,
|
||||
<<"%">>,
|
||||
StateData#state.server]),
|
||||
@ -1261,7 +1261,7 @@ process_quit(StateData, From, String) ->
|
||||
process_join(StateData, Channel, From, _String) ->
|
||||
[FromUser | FromIdent] = str:tokens(From, <<"!">>),
|
||||
[Chan | _] = binary:split(Channel, <<":#">>),
|
||||
ejabberd_router:route(jlib:make_jid(iolist_to_binary(
|
||||
ejabberd_router:route(jid:make(iolist_to_binary(
|
||||
[Chan,
|
||||
<<"%">>,
|
||||
StateData#state.server]),
|
||||
@ -1294,7 +1294,7 @@ process_join(StateData, Channel, From, _String) ->
|
||||
|
||||
process_mode_o(StateData, Chan, _From, Nick,
|
||||
Affiliation, Role) ->
|
||||
ejabberd_router:route(jlib:make_jid(iolist_to_binary(
|
||||
ejabberd_router:route(jid:make(iolist_to_binary(
|
||||
[Chan,
|
||||
<<"%">>,
|
||||
StateData#state.server]),
|
||||
@ -1318,7 +1318,7 @@ process_kick(StateData, Chan, From, Nick, String) ->
|
||||
Msg = lists:last(str:tokens(String, <<":">>)),
|
||||
Msg2 = <<Nick/binary, " kicked by ", From/binary, " (",
|
||||
(filter_message(Msg))/binary, ")">>,
|
||||
ejabberd_router:route(jlib:make_jid(iolist_to_binary(
|
||||
ejabberd_router:route(jid:make(iolist_to_binary(
|
||||
[Chan,
|
||||
<<"%">>,
|
||||
StateData#state.server]),
|
||||
@ -1329,7 +1329,7 @@ process_kick(StateData, Chan, From, Nick, String) ->
|
||||
children =
|
||||
[#xmlel{name = <<"body">>, attrs = [],
|
||||
children = [{xmlcdata, Msg2}]}]}),
|
||||
ejabberd_router:route(jlib:make_jid(iolist_to_binary(
|
||||
ejabberd_router:route(jid:make(iolist_to_binary(
|
||||
[Chan,
|
||||
<<"%">>,
|
||||
StateData#state.server]),
|
||||
@ -1361,7 +1361,7 @@ process_nick(StateData, From, NewNick) ->
|
||||
NewChans = dict:map(fun (Chan, Ps) ->
|
||||
case (?SETS):is_member(FromUser, Ps) of
|
||||
true ->
|
||||
ejabberd_router:route(jlib:make_jid(
|
||||
ejabberd_router:route(jid:make(
|
||||
iolist_to_binary(
|
||||
[Chan,
|
||||
<<"%">>,
|
||||
@ -1408,7 +1408,7 @@ process_nick(StateData, From, NewNick) ->
|
||||
children
|
||||
=
|
||||
[]}]}]}),
|
||||
ejabberd_router:route(jlib:make_jid(
|
||||
ejabberd_router:route(jid:make(
|
||||
iolist_to_binary(
|
||||
[Chan,
|
||||
<<"%">>,
|
||||
@ -1456,7 +1456,7 @@ process_nick(StateData, From, NewNick) ->
|
||||
|
||||
process_error(StateData, String) ->
|
||||
lists:foreach(fun (Chan) ->
|
||||
ejabberd_router:route(jlib:make_jid(
|
||||
ejabberd_router:route(jid:make(
|
||||
iolist_to_binary(
|
||||
[Chan,
|
||||
<<"%">>,
|
||||
|
@ -236,8 +236,8 @@ on_presence_update(User, Server, _Resource, Status) ->
|
||||
store_last_info(User, Server, TimeStamp, Status).
|
||||
|
||||
store_last_info(User, Server, TimeStamp, Status) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
DBType = gen_mod:db_type(LServer, ?MODULE),
|
||||
store_last_info(LUser, LServer, TimeStamp, Status,
|
||||
DBType).
|
||||
@ -276,8 +276,8 @@ get_last_info(LUser, LServer) ->
|
||||
end.
|
||||
|
||||
remove_user(User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
DBType = gen_mod:db_type(LServer, ?MODULE),
|
||||
remove_user(LUser, LServer, DBType).
|
||||
|
||||
|
@ -136,8 +136,8 @@ stop(Host) ->
|
||||
ok.
|
||||
|
||||
remove_user(User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
remove_user(LUser, LServer,
|
||||
gen_mod:db_type(LServer, ?MODULE)).
|
||||
|
||||
@ -199,7 +199,7 @@ user_send_packet(Pkt, C2SState, JID, Peer) ->
|
||||
muc_filter_message(Pkt, #state{config = Config} = MUCState,
|
||||
RoomJID, From, FromNick) ->
|
||||
if Config#config.mam ->
|
||||
By = jlib:jid_to_string(RoomJID),
|
||||
By = jid:to_string(RoomJID),
|
||||
NewPkt = strip_my_archived_tag(Pkt, By),
|
||||
case store_muc(MUCState, NewPkt, RoomJID, From, FromNick) of
|
||||
{ok, ID} ->
|
||||
@ -323,10 +323,10 @@ process_iq(LServer, From, To, IQ, SubEl, Fs, MsgType) ->
|
||||
{_, _, _} = jlib:datetime_string_to_timestamp(Data),
|
||||
With, RSM};
|
||||
({<<"with">>, [Data|_]}, {Start, End, _, RSM}) ->
|
||||
{Start, End, jlib:jid_tolower(jlib:string_to_jid(Data)), RSM};
|
||||
{Start, End, jid:tolower(jid:from_string(Data)), RSM};
|
||||
({<<"withroom">>, [Data|_]}, {Start, End, _, RSM}) ->
|
||||
{Start, End,
|
||||
{room, jlib:jid_tolower(jlib:string_to_jid(Data))},
|
||||
{room, jid:tolower(jid:from_string(Data))},
|
||||
RSM};
|
||||
({<<"withtext">>, [Data|_]}, {Start, End, _, RSM}) ->
|
||||
{Start, End, {text, Data}, RSM};
|
||||
@ -362,7 +362,7 @@ strip_my_archived_tag(Pkt, LServer) ->
|
||||
NewEls = lists:filter(
|
||||
fun(#xmlel{name = Tag, attrs = Attrs})
|
||||
when Tag == <<"archived">>; Tag == <<"stanza-id">> ->
|
||||
case catch jlib:nameprep(
|
||||
case catch jid:nameprep(
|
||||
xml:get_attr_s(
|
||||
<<"by">>, Attrs)) of
|
||||
LServer ->
|
||||
@ -380,7 +380,7 @@ should_archive_peer(C2SState,
|
||||
always = Always,
|
||||
never = Never},
|
||||
Peer) ->
|
||||
LPeer = jlib:jid_tolower(Peer),
|
||||
LPeer = jid:tolower(Peer),
|
||||
case lists:member(LPeer, Always) of
|
||||
true ->
|
||||
true;
|
||||
@ -423,7 +423,7 @@ store_muc(MUCState, Pkt, RoomJID, Peer, Nick) ->
|
||||
case should_archive_muc(MUCState, Peer) of
|
||||
true ->
|
||||
LServer = MUCState#state.server_host,
|
||||
{U, S, _} = jlib:jid_tolower(RoomJID),
|
||||
{U, S, _} = jid:tolower(RoomJID),
|
||||
store(Pkt, LServer, {U, S}, groupchat, Peer, Nick, recv,
|
||||
gen_mod:db_type(LServer, ?MODULE));
|
||||
false ->
|
||||
@ -431,7 +431,7 @@ store_muc(MUCState, Pkt, RoomJID, Peer, Nick) ->
|
||||
end.
|
||||
|
||||
store(Pkt, _, {LUser, LServer}, Type, Peer, Nick, _Dir, mnesia) ->
|
||||
LPeer = {PUser, PServer, _} = jlib:jid_tolower(Peer),
|
||||
LPeer = {PUser, PServer, _} = jid:tolower(Peer),
|
||||
TS = now(),
|
||||
ID = jlib:integer_to_binary(now_to_usec(TS)),
|
||||
case mnesia:dirty_write(
|
||||
@ -453,13 +453,13 @@ store(Pkt, LServer, {LUser, LHost}, Type, Peer, Nick, _Dir, odbc) ->
|
||||
ID = TS = jlib:integer_to_binary(TSinteger),
|
||||
SUser = case Type of
|
||||
chat -> LUser;
|
||||
groupchat -> jlib:jid_to_string({LUser, LHost, <<>>})
|
||||
groupchat -> jid:to_string({LUser, LHost, <<>>})
|
||||
end,
|
||||
BarePeer = jlib:jid_to_string(
|
||||
jlib:jid_tolower(
|
||||
jlib:jid_remove_resource(Peer))),
|
||||
LPeer = jlib:jid_to_string(
|
||||
jlib:jid_tolower(Peer)),
|
||||
BarePeer = jid:to_string(
|
||||
jid:tolower(
|
||||
jid:remove_resource(Peer))),
|
||||
LPeer = jid:to_string(
|
||||
jid:tolower(Peer)),
|
||||
XML = xml:element_to_binary(Pkt),
|
||||
Body = xml:get_subtag_cdata(Pkt, <<"body">>),
|
||||
case ejabberd_odbc:sql_query(
|
||||
@ -576,7 +576,7 @@ select_and_start(LServer, From, To, Start, End, With, RSM, MsgType, DBType) ->
|
||||
chat ->
|
||||
case With of
|
||||
{room, {_, _, <<"">>} = WithJID} ->
|
||||
select(LServer, jlib:make_jid(WithJID), Start, End,
|
||||
select(LServer, jid:make(WithJID), Start, End,
|
||||
WithJID, RSM, MsgType, DBType);
|
||||
_ ->
|
||||
select(LServer, From, Start, End,
|
||||
@ -639,7 +639,7 @@ select(LServer, #jid{luser = LUser} = JidRequestor,
|
||||
Start, End, With, RSM, MsgType, {odbc, Host}) ->
|
||||
User = case MsgType of
|
||||
chat -> LUser;
|
||||
{groupchat, _Role, _MUCState} -> jlib:jid_to_string(JidRequestor)
|
||||
{groupchat, _Role, _MUCState} -> jid:to_string(JidRequestor)
|
||||
end,
|
||||
{Query, CountQuery} = make_sql_query(User, LServer,
|
||||
Start, End, With, RSM),
|
||||
@ -670,7 +670,7 @@ select(LServer, #jid{luser = LUser} = JidRequestor,
|
||||
fun([TS, XML, PeerBin, Kind, Nick]) ->
|
||||
#xmlel{} = El = xml_stream:parse_element(XML),
|
||||
Now = usec_to_now(jlib:binary_to_integer(TS)),
|
||||
PeerJid = jlib:jid_tolower(jlib:string_to_jid(PeerBin)),
|
||||
PeerJid = jid:tolower(jid:from_string(PeerBin)),
|
||||
T = if Kind /= <<"">> ->
|
||||
jlib:binary_to_atom(Kind);
|
||||
true -> chat
|
||||
@ -704,9 +704,9 @@ maybe_update_from_to(Pkt, JidRequestor, Peer, chat, _Nick) ->
|
||||
case xml:get_attr_s(<<"type">>, Pkt#xmlel.attrs) of
|
||||
<<"groupchat">> when Peer /= undefined ->
|
||||
Pkt2 = xml:replace_tag_attr(<<"to">>,
|
||||
jlib:jid_to_string(JidRequestor),
|
||||
jid:to_string(JidRequestor),
|
||||
Pkt),
|
||||
xml:replace_tag_attr(<<"from">>, jlib:jid_to_string(Peer),
|
||||
xml:replace_tag_attr(<<"from">>, jid:to_string(Peer),
|
||||
Pkt2);
|
||||
_ -> Pkt
|
||||
end;
|
||||
@ -719,12 +719,12 @@ maybe_update_from_to(#xmlel{children = Els} = Pkt, JidRequestor,
|
||||
children =
|
||||
[#xmlel{name = <<"item">>,
|
||||
attrs = [{<<"jid">>,
|
||||
jlib:jid_to_string(Peer)}]}]}];
|
||||
jid:to_string(Peer)}]}]}];
|
||||
_ ->
|
||||
[]
|
||||
end,
|
||||
Pkt1 = Pkt#xmlel{children = Items ++ Els},
|
||||
Pkt2 = jlib:replace_from(jlib:jid_replace_resource(JidRequestor, Nick), Pkt1),
|
||||
Pkt2 = jlib:replace_from(jid:replace_resource(JidRequestor, Nick), Pkt1),
|
||||
jlib:remove_attr(<<"to">>, Pkt2).
|
||||
|
||||
is_bare_copy(#jid{luser = U, lserver = S, lresource = R}, To) ->
|
||||
@ -913,11 +913,11 @@ make_sql_query(User, _LServer, Start, End, With, RSM) ->
|
||||
ejabberd_odbc:escape(Txt), <<"')">>];
|
||||
{_, _, <<>>} ->
|
||||
[<<" and bare_peer='">>,
|
||||
ejabberd_odbc:escape(jlib:jid_to_string(With)),
|
||||
ejabberd_odbc:escape(jid:to_string(With)),
|
||||
<<"'">>];
|
||||
{_, _, _} ->
|
||||
[<<" and peer='">>,
|
||||
ejabberd_odbc:escape(jlib:jid_to_string(With)),
|
||||
ejabberd_odbc:escape(jid:to_string(With)),
|
||||
<<"'">>];
|
||||
none ->
|
||||
[]
|
||||
@ -991,9 +991,9 @@ datetime_to_now(DateTime, USecs) ->
|
||||
get_jids(Els) ->
|
||||
lists:flatmap(
|
||||
fun(#xmlel{name = <<"jid">>} = El) ->
|
||||
J = jlib:string_to_jid(xml:get_tag_cdata(El)),
|
||||
[jlib:jid_tolower(jlib:jid_remove_resource(J)),
|
||||
jlib:jid_tolower(J)];
|
||||
J = jid:from_string(xml:get_tag_cdata(El)),
|
||||
[jid:tolower(jid:remove_resource(J)),
|
||||
jid:tolower(J)];
|
||||
(_) ->
|
||||
[]
|
||||
end, Els).
|
||||
|
@ -84,9 +84,9 @@ s2s_receive_packet(_From, #jid{lserver=LServer}, _Packet) ->
|
||||
push(LServer, s2s_receive_packet).
|
||||
|
||||
remove_user(_User, Server) ->
|
||||
push(jlib:nameprep(Server), remove_user).
|
||||
push(jid:nameprep(Server), remove_user).
|
||||
register_user(_User, Server) ->
|
||||
push(jlib:nameprep(Server), register_user).
|
||||
push(jid:nameprep(Server), register_user).
|
||||
|
||||
%%====================================================================
|
||||
%% metrics push handler
|
||||
|
@ -134,7 +134,7 @@ create_room(Host, Name, From, Nick, Opts) ->
|
||||
gen_server:call(Proc, {create, Name, From, Nick, Opts}).
|
||||
|
||||
store_room(ServerHost, Host, Name, Opts) ->
|
||||
LServer = jlib:nameprep(ServerHost),
|
||||
LServer = jid:nameprep(ServerHost),
|
||||
store_room(LServer, Host, Name, Opts,
|
||||
gen_mod:db_type(LServer, ?MODULE)).
|
||||
|
||||
@ -162,7 +162,7 @@ store_room(LServer, Host, Name, Opts, odbc) ->
|
||||
ejabberd_odbc:sql_transaction(LServer, F).
|
||||
|
||||
restore_room(ServerHost, Host, Name) ->
|
||||
LServer = jlib:nameprep(ServerHost),
|
||||
LServer = jid:nameprep(ServerHost),
|
||||
restore_room(LServer, Host, Name,
|
||||
gen_mod:db_type(LServer, ?MODULE)).
|
||||
|
||||
@ -190,7 +190,7 @@ restore_room(LServer, Host, Name, odbc) ->
|
||||
end.
|
||||
|
||||
forget_room(ServerHost, Host, Name) ->
|
||||
LServer = jlib:nameprep(ServerHost),
|
||||
LServer = jid:nameprep(ServerHost),
|
||||
forget_room(LServer, Host, Name,
|
||||
gen_mod:db_type(LServer, ?MODULE)).
|
||||
|
||||
@ -216,11 +216,11 @@ forget_room(LServer, Host, Name, odbc) ->
|
||||
remove_room_mam(LServer, Host, Name) ->
|
||||
case gen_mod:is_loaded(LServer, mod_mam) of
|
||||
true ->
|
||||
U = jlib:nodeprep(Name),
|
||||
S = jlib:nameprep(Host),
|
||||
U = jid:nodeprep(Name),
|
||||
S = jid:nameprep(Host),
|
||||
DBType = gen_mod:db_type(LServer, mod_mam),
|
||||
if DBType == odbc ->
|
||||
mod_mam:remove_user(jlib:jid_to_string({U, S, <<>>}),
|
||||
mod_mam:remove_user(jid:to_string({U, S, <<>>}),
|
||||
LServer, DBType);
|
||||
true ->
|
||||
mod_mam:remove_user(U, S, DBType)
|
||||
@ -241,12 +241,12 @@ process_iq_disco_items(Host, From, To,
|
||||
|
||||
can_use_nick(_ServerHost, _Host, _JID, <<"">>) -> false;
|
||||
can_use_nick(ServerHost, Host, JID, Nick) ->
|
||||
LServer = jlib:nameprep(ServerHost),
|
||||
LServer = jid:nameprep(ServerHost),
|
||||
can_use_nick(LServer, Host, JID, Nick,
|
||||
gen_mod:db_type(LServer, ?MODULE)).
|
||||
|
||||
can_use_nick(_LServer, Host, JID, Nick, mnesia) ->
|
||||
{LUser, LServer, _} = jlib:jid_tolower(JID),
|
||||
{LUser, LServer, _} = jid:tolower(JID),
|
||||
LUS = {LUser, LServer},
|
||||
case catch mnesia:dirty_select(muc_registered,
|
||||
[{#muc_registered{us_host = '$1',
|
||||
@ -259,7 +259,7 @@ can_use_nick(_LServer, Host, JID, Nick, mnesia) ->
|
||||
[#muc_registered{us_host = {U, _Host}}] -> U == LUS
|
||||
end;
|
||||
can_use_nick(LServer, Host, JID, Nick, riak) ->
|
||||
{LUser, LServer, _} = jlib:jid_tolower(JID),
|
||||
{LUser, LServer, _} = jid:tolower(JID),
|
||||
LUS = {LUser, LServer},
|
||||
case ejabberd_riak:get_by_index(muc_registered,
|
||||
muc_registered_schema(),
|
||||
@ -273,7 +273,7 @@ can_use_nick(LServer, Host, JID, Nick, riak) ->
|
||||
end;
|
||||
can_use_nick(LServer, Host, JID, Nick, odbc) ->
|
||||
SJID =
|
||||
jlib:jid_to_string(jlib:jid_tolower(jlib:jid_remove_resource(JID))),
|
||||
jid:to_string(jid:tolower(jid:remove_resource(JID))),
|
||||
SNick = ejabberd_odbc:escape(Nick),
|
||||
SHost = ejabberd_odbc:escape(Host),
|
||||
case catch ejabberd_odbc:sql_query(LServer,
|
||||
@ -463,7 +463,7 @@ do_route(Host, ServerHost, Access, HistorySize, RoomShaper,
|
||||
do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
|
||||
From, To, Packet, DefRoomOpts) ->
|
||||
{_AccessRoute, AccessCreate, AccessAdmin, _AccessPersistent} = Access,
|
||||
{Room, _, Nick} = jlib:jid_tolower(To),
|
||||
{Room, _, Nick} = jid:tolower(To),
|
||||
#xmlel{name = Name, attrs = Attrs} = Packet,
|
||||
case Room of
|
||||
<<"">> ->
|
||||
@ -641,7 +641,7 @@ check_user_can_create_room(ServerHost, AccessCreate,
|
||||
end.
|
||||
|
||||
get_rooms(ServerHost, Host) ->
|
||||
LServer = jlib:nameprep(ServerHost),
|
||||
LServer = jid:nameprep(ServerHost),
|
||||
get_rooms(LServer, Host,
|
||||
gen_mod:db_type(LServer, ?MODULE)).
|
||||
|
||||
@ -767,7 +767,7 @@ iq_disco_items(Host, From, Lang, none) ->
|
||||
#xmlel{name = <<"item">>,
|
||||
attrs =
|
||||
[{<<"jid">>,
|
||||
jlib:jid_to_string({Name, Host,
|
||||
jid:to_string({Name, Host,
|
||||
<<"">>})},
|
||||
{<<"name">>, Desc}],
|
||||
children = []}};
|
||||
@ -791,7 +791,7 @@ iq_disco_items(Host, From, Lang, Rsm) ->
|
||||
#xmlel{name = <<"item">>,
|
||||
attrs =
|
||||
[{<<"jid">>,
|
||||
jlib:jid_to_string({Name, Host,
|
||||
jid:to_string({Name, Host,
|
||||
<<"">>})},
|
||||
{<<"name">>, Desc}],
|
||||
children = []}};
|
||||
@ -868,12 +868,12 @@ iq_get_unique(From) ->
|
||||
randoms:get_string()]))}.
|
||||
|
||||
get_nick(ServerHost, Host, From) ->
|
||||
LServer = jlib:nameprep(ServerHost),
|
||||
LServer = jid:nameprep(ServerHost),
|
||||
get_nick(LServer, Host, From,
|
||||
gen_mod:db_type(LServer, ?MODULE)).
|
||||
|
||||
get_nick(_LServer, Host, From, mnesia) ->
|
||||
{LUser, LServer, _} = jlib:jid_tolower(From),
|
||||
{LUser, LServer, _} = jid:tolower(From),
|
||||
LUS = {LUser, LServer},
|
||||
case catch mnesia:dirty_read(muc_registered,
|
||||
{LUS, Host})
|
||||
@ -883,7 +883,7 @@ get_nick(_LServer, Host, From, mnesia) ->
|
||||
[#muc_registered{nick = Nick}] -> Nick
|
||||
end;
|
||||
get_nick(LServer, Host, From, riak) ->
|
||||
{LUser, LServer, _} = jlib:jid_tolower(From),
|
||||
{LUser, LServer, _} = jid:tolower(From),
|
||||
US = {LUser, LServer},
|
||||
case ejabberd_riak:get(muc_registered,
|
||||
muc_registered_schema(),
|
||||
@ -893,7 +893,7 @@ get_nick(LServer, Host, From, riak) ->
|
||||
end;
|
||||
get_nick(LServer, Host, From, odbc) ->
|
||||
SJID =
|
||||
ejabberd_odbc:escape(jlib:jid_to_string(jlib:jid_tolower(jlib:jid_remove_resource(From)))),
|
||||
ejabberd_odbc:escape(jid:to_string(jid:tolower(jid:remove_resource(From)))),
|
||||
SHost = ejabberd_odbc:escape(Host),
|
||||
case catch ejabberd_odbc:sql_query(LServer,
|
||||
[<<"select nick from muc_registered where "
|
||||
@ -941,12 +941,12 @@ iq_get_register_info(ServerHost, Host, From, Lang) ->
|
||||
Nick)]}].
|
||||
|
||||
set_nick(ServerHost, Host, From, Nick) ->
|
||||
LServer = jlib:nameprep(ServerHost),
|
||||
LServer = jid:nameprep(ServerHost),
|
||||
set_nick(LServer, Host, From, Nick,
|
||||
gen_mod:db_type(LServer, ?MODULE)).
|
||||
|
||||
set_nick(_LServer, Host, From, Nick, mnesia) ->
|
||||
{LUser, LServer, _} = jlib:jid_tolower(From),
|
||||
{LUser, LServer, _} = jid:tolower(From),
|
||||
LUS = {LUser, LServer},
|
||||
F = fun () ->
|
||||
case Nick of
|
||||
@ -976,7 +976,7 @@ set_nick(_LServer, Host, From, Nick, mnesia) ->
|
||||
end,
|
||||
mnesia:transaction(F);
|
||||
set_nick(LServer, Host, From, Nick, riak) ->
|
||||
{LUser, LServer, _} = jlib:jid_tolower(From),
|
||||
{LUser, LServer, _} = jid:tolower(From),
|
||||
LUS = {LUser, LServer},
|
||||
{atomic,
|
||||
case Nick of
|
||||
@ -1006,7 +1006,7 @@ set_nick(LServer, Host, From, Nick, riak) ->
|
||||
end};
|
||||
set_nick(LServer, Host, From, Nick, odbc) ->
|
||||
JID =
|
||||
jlib:jid_to_string(jlib:jid_tolower(jlib:jid_remove_resource(From))),
|
||||
jid:to_string(jid:tolower(jid:remove_resource(From))),
|
||||
SJID = ejabberd_odbc:escape(JID),
|
||||
SNick = ejabberd_odbc:escape(Nick),
|
||||
SHost = ejabberd_odbc:escape(Host),
|
||||
@ -1255,8 +1255,8 @@ export(_Server) ->
|
||||
case str:suffix(Host, RoomHost) of
|
||||
true ->
|
||||
SJID = ejabberd_odbc:escape(
|
||||
jlib:jid_to_string(
|
||||
jlib:make_jid(U, S, <<"">>))),
|
||||
jid:to_string(
|
||||
jid:make(U, S, <<"">>))),
|
||||
SNick = ejabberd_odbc:escape(Nick),
|
||||
SRoomHost = ejabberd_odbc:escape(RoomHost),
|
||||
[[<<"delete from muc_registered where jid='">>,
|
||||
@ -1279,7 +1279,7 @@ import(_LServer) ->
|
||||
{<<"select jid, host, nick from muc_registered;">>,
|
||||
fun([J, RoomHost, Nick]) ->
|
||||
#jid{user = U, server = S} =
|
||||
jlib:string_to_jid(J),
|
||||
jid:from_string(J),
|
||||
#muc_registered{us_host = {{U, S}, RoomHost},
|
||||
nick = Nick}
|
||||
end}].
|
||||
|
@ -676,7 +676,7 @@ get_room_occupants(Pid) ->
|
||||
S = get_room_state(Pid),
|
||||
lists:map(
|
||||
fun({_LJID, Info}) ->
|
||||
{jlib:jid_to_string(Info#user.jid),
|
||||
{jid:to_string(Info#user.jid),
|
||||
Info#user.nick,
|
||||
atom_to_list(Info#user.role)}
|
||||
end,
|
||||
@ -691,11 +691,11 @@ get_room_occupants_number(Room, Host) ->
|
||||
%% http://xmpp.org/extensions/xep-0249.html
|
||||
|
||||
send_direct_invitation(RoomName, RoomService, Password, Reason, UsersString) ->
|
||||
RoomJid = jlib:make_jid(RoomName, RoomService, <<"">>),
|
||||
RoomString = jlib:jid_to_string(RoomJid),
|
||||
RoomJid = jid:make(RoomName, RoomService, <<"">>),
|
||||
RoomString = jid:to_string(RoomJid),
|
||||
XmlEl = build_invitation(Password, Reason, RoomString),
|
||||
UsersStrings = get_users_to_invite(RoomJid, binary_to_list(UsersString)),
|
||||
[send_direct_invitation(RoomJid, jlib:string_to_jid(list_to_binary(UserStrings)), XmlEl)
|
||||
[send_direct_invitation(RoomJid, jid:from_string(list_to_binary(UserStrings)), XmlEl)
|
||||
|| UserStrings <- UsersStrings],
|
||||
timer:sleep(1000),
|
||||
ok.
|
||||
@ -704,11 +704,11 @@ get_users_to_invite(RoomJid, UsersString) ->
|
||||
UsersStrings = string:tokens(UsersString, ":"),
|
||||
OccupantsTuples = get_room_occupants(RoomJid#jid.luser,
|
||||
RoomJid#jid.lserver),
|
||||
OccupantsJids = [jlib:string_to_jid(JidString)
|
||||
OccupantsJids = [jid:from_string(JidString)
|
||||
|| {JidString, _Nick, _} <- OccupantsTuples],
|
||||
lists:filter(
|
||||
fun(UserString) ->
|
||||
UserJid = jlib:string_to_jid(list_to_binary(UserString)),
|
||||
UserJid = jid:from_string(list_to_binary(UserString)),
|
||||
%% [{"badlop@localhost/work","badlop","moderator"}]
|
||||
lists:all(fun(OccupantJid) ->
|
||||
UserJid#jid.luser /= OccupantJid#jid.luser
|
||||
@ -872,7 +872,7 @@ set_room_affiliation(Name, Service, JID, AffiliationString) ->
|
||||
[R] ->
|
||||
%% Get the PID for the online room so we can get the state of the room
|
||||
Pid = R#muc_online_room.pid,
|
||||
{ok, StateData} = gen_fsm:sync_send_all_state_event(Pid, {process_item_change, {jlib:string_to_jid(JID), affiliation, Affiliation, <<"">>}, <<"">>}),
|
||||
{ok, StateData} = gen_fsm:sync_send_all_state_event(Pid, {process_item_change, {jid:from_string(JID), affiliation, Affiliation, <<"">>}, <<"">>}),
|
||||
mod_muc:store_room(StateData#state.server_host, StateData#state.host, StateData#state.room, make_opts(StateData)),
|
||||
ok;
|
||||
[] ->
|
||||
|
@ -279,7 +279,7 @@ build_filename_string(TimeStamp, OutDir, RoomJID,
|
||||
{Fd, Fn, Fnrel}.
|
||||
|
||||
get_room_name(RoomJID) ->
|
||||
JID = jlib:string_to_jid(RoomJID), JID#jid.user.
|
||||
JID = jid:from_string(RoomJID), JID#jid.user.
|
||||
|
||||
%% calculate day before
|
||||
get_timestamp_daydiff(TimeStamp, Daydiff) ->
|
||||
@ -999,7 +999,7 @@ get_room_info(RoomJID, Opts) ->
|
||||
{value, {_, SA}} -> SA;
|
||||
false -> <<"">>
|
||||
end,
|
||||
#room{jid = jlib:jid_to_string(RoomJID), title = Title,
|
||||
#room{jid = jid:to_string(RoomJID), title = Title,
|
||||
subject = Subject, subject_author = SubjectAuthor,
|
||||
config = Opts}.
|
||||
|
||||
@ -1160,7 +1160,7 @@ role_users_to_string(RoleS, Users) ->
|
||||
<<RoleS/binary, ": ", UsersString/binary>>.
|
||||
|
||||
get_room_occupants(RoomJIDString) ->
|
||||
RoomJID = jlib:string_to_jid(RoomJIDString),
|
||||
RoomJID = jid:from_string(RoomJIDString),
|
||||
RoomName = RoomJID#jid.luser,
|
||||
MucService = RoomJID#jid.lserver,
|
||||
StateData = get_room_state(RoomName, MucService),
|
||||
|
@ -107,7 +107,7 @@ init([Host, ServerHost, Access, Room, HistorySize,
|
||||
#state{host = Host, server_host = ServerHost,
|
||||
access = Access, room = Room,
|
||||
history = lqueue_new(HistorySize),
|
||||
jid = jlib:make_jid(Room, Host, <<"">>),
|
||||
jid = jid:make(Room, Host, <<"">>),
|
||||
just_created = true,
|
||||
room_shaper = Shaper}),
|
||||
State1 = set_opts(DefRoomOpts, State),
|
||||
@ -119,7 +119,7 @@ init([Host, ServerHost, Access, Room, HistorySize,
|
||||
true -> ok
|
||||
end,
|
||||
?INFO_MSG("Created MUC room ~s@~s by ~s",
|
||||
[Room, Host, jlib:jid_to_string(Creator)]),
|
||||
[Room, Host, jid:to_string(Creator)]),
|
||||
add_to_log(room_existence, created, State1),
|
||||
add_to_log(room_existence, started, State1),
|
||||
{ok, normal_state, State1};
|
||||
@ -131,7 +131,7 @@ init([Host, ServerHost, Access, Room, HistorySize, RoomShaper, Opts]) ->
|
||||
access = Access,
|
||||
room = Room,
|
||||
history = lqueue_new(HistorySize),
|
||||
jid = jlib:make_jid(Room, Host, <<"">>),
|
||||
jid = jid:make(Room, Host, <<"">>),
|
||||
room_shaper = Shaper}),
|
||||
add_to_log(room_existence, started, State),
|
||||
{ok, normal_state, State}.
|
||||
@ -287,7 +287,7 @@ normal_state({route, From, <<"">>,
|
||||
MinInterval =
|
||||
(StateData#state.config)#config.voice_request_min_interval,
|
||||
BareFrom =
|
||||
jlib:jid_remove_resource(jlib:jid_tolower(From)),
|
||||
jid:remove_resource(jid:tolower(From)),
|
||||
NowPriority = -now_to_usec(now()),
|
||||
CleanPriority = NowPriority +
|
||||
MinInterval *
|
||||
@ -533,7 +533,7 @@ normal_state({route, From, ToNick,
|
||||
Err = jlib:make_error_reply(Packet,
|
||||
?ERRT_BAD_REQUEST(Lang,
|
||||
ErrText)),
|
||||
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid,
|
||||
ejabberd_router:route(jid:replace_resource(StateData#state.jid,
|
||||
ToNick),
|
||||
From, Err);
|
||||
_ ->
|
||||
@ -544,7 +544,7 @@ normal_state({route, From, ToNick,
|
||||
Err = jlib:make_error_reply(Packet,
|
||||
?ERRT_ITEM_NOT_FOUND(Lang,
|
||||
ErrText)),
|
||||
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid,
|
||||
ejabberd_router:route(jid:replace_resource(StateData#state.jid,
|
||||
ToNick),
|
||||
From, Err);
|
||||
ToJIDs ->
|
||||
@ -558,10 +558,10 @@ normal_state({route, From, ToNick,
|
||||
(PmFromVisitors == moderators) and
|
||||
DstIsModerator ->
|
||||
{ok, #user{nick = FromNick}} =
|
||||
(?DICT):find(jlib:jid_tolower(From),
|
||||
(?DICT):find(jid:tolower(From),
|
||||
StateData#state.users),
|
||||
FromNickJID =
|
||||
jlib:jid_replace_resource(StateData#state.jid,
|
||||
jid:replace_resource(StateData#state.jid,
|
||||
FromNick),
|
||||
X = #xmlel{name = <<"x">>,
|
||||
attrs = [{<<"xmlns">>, ?NS_MUC_USER}]},
|
||||
@ -574,7 +574,7 @@ normal_state({route, From, ToNick,
|
||||
Err = jlib:make_error_reply(Packet,
|
||||
?ERRT_FORBIDDEN(Lang,
|
||||
ErrText)),
|
||||
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid,
|
||||
ejabberd_router:route(jid:replace_resource(StateData#state.jid,
|
||||
ToNick),
|
||||
From, Err)
|
||||
end
|
||||
@ -587,7 +587,7 @@ normal_state({route, From, ToNick,
|
||||
Err = jlib:make_error_reply(Packet,
|
||||
?ERRT_NOT_ACCEPTABLE(Lang,
|
||||
ErrText)),
|
||||
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid,
|
||||
ejabberd_router:route(jid:replace_resource(StateData#state.jid,
|
||||
ToNick),
|
||||
From, Err);
|
||||
{false, _} ->
|
||||
@ -595,7 +595,7 @@ normal_state({route, From, ToNick,
|
||||
<<"It is not allowed to send private messages">>,
|
||||
Err = jlib:make_error_reply(Packet,
|
||||
?ERRT_FORBIDDEN(Lang, ErrText)),
|
||||
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid,
|
||||
ejabberd_router:route(jid:replace_resource(StateData#state.jid,
|
||||
ToNick),
|
||||
From, Err)
|
||||
end,
|
||||
@ -619,17 +619,17 @@ normal_state({route, From, ToNick,
|
||||
Err = jlib:make_error_reply(Packet,
|
||||
?ERRT_ITEM_NOT_FOUND(Lang,
|
||||
ErrText)),
|
||||
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid,
|
||||
ejabberd_router:route(jid:replace_resource(StateData#state.jid,
|
||||
ToNick),
|
||||
From, Err)
|
||||
end;
|
||||
ToJID ->
|
||||
{ok, #user{nick = FromNick}} =
|
||||
(?DICT):find(jlib:jid_tolower(FromFull),
|
||||
(?DICT):find(jid:tolower(FromFull),
|
||||
StateData#state.users),
|
||||
{ToJID2, Packet2} = handle_iq_vcard(FromFull, ToJID,
|
||||
StanzaId, NewId, Packet),
|
||||
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid,
|
||||
ejabberd_router:route(jid:replace_resource(StateData#state.jid,
|
||||
FromNick),
|
||||
ToJID2, Packet2)
|
||||
end;
|
||||
@ -643,7 +643,7 @@ normal_state({route, From, ToNick,
|
||||
Err = jlib:make_error_reply(Packet,
|
||||
?ERRT_NOT_ACCEPTABLE(Lang,
|
||||
ErrText)),
|
||||
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid,
|
||||
ejabberd_router:route(jid:replace_resource(StateData#state.jid,
|
||||
ToNick),
|
||||
From, Err)
|
||||
end;
|
||||
@ -655,7 +655,7 @@ normal_state({route, From, ToNick,
|
||||
"not allowed in this room">>,
|
||||
Err = jlib:make_error_reply(Packet,
|
||||
?ERRT_NOT_ALLOWED(Lang, ErrText)),
|
||||
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid,
|
||||
ejabberd_router:route(jid:replace_resource(StateData#state.jid,
|
||||
ToNick),
|
||||
From, Err)
|
||||
end
|
||||
@ -698,12 +698,12 @@ handle_event({destroy, Reason}, _StateName,
|
||||
end},
|
||||
StateData),
|
||||
?INFO_MSG("Destroyed MUC room ~s with reason: ~p",
|
||||
[jlib:jid_to_string(StateData#state.jid), Reason]),
|
||||
[jid:to_string(StateData#state.jid), Reason]),
|
||||
add_to_log(room_existence, destroyed, StateData),
|
||||
{stop, shutdown, StateData};
|
||||
handle_event(destroy, StateName, StateData) ->
|
||||
?INFO_MSG("Destroyed MUC room ~s",
|
||||
[jlib:jid_to_string(StateData#state.jid)]),
|
||||
[jid:to_string(StateData#state.jid)]),
|
||||
handle_event({destroy, none}, StateName, StateData);
|
||||
handle_event({set_affiliations, Affiliations},
|
||||
StateName, StateData) ->
|
||||
@ -807,7 +807,7 @@ handle_info({captcha_failed, From}, normal_state,
|
||||
Err = jlib:make_error_reply(Packet,
|
||||
?ERR_NOT_AUTHORIZED),
|
||||
ejabberd_router:route % TODO: s/Nick/""/
|
||||
(jlib:jid_replace_resource(StateData#state.jid,
|
||||
(jid:replace_resource(StateData#state.jid,
|
||||
Nick),
|
||||
From, Err),
|
||||
StateData#state{robots = Robots};
|
||||
@ -848,7 +848,7 @@ terminate(Reason, _StateName, StateData) ->
|
||||
Nick = Info#user.nick,
|
||||
case Reason of
|
||||
shutdown ->
|
||||
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid,
|
||||
ejabberd_router:route(jid:replace_resource(StateData#state.jid,
|
||||
Nick),
|
||||
Info#user.jid, Packet);
|
||||
_ -> ok
|
||||
@ -924,7 +924,7 @@ process_groupchat_message(From,
|
||||
{next_state, normal_state, StateData};
|
||||
NewPacket1 ->
|
||||
NewPacket = xml:remove_subtags(NewPacket1, <<"nick">>, {<<"xmlns">>, ?NS_NICK}),
|
||||
send_multiple(jlib:jid_replace_resource(StateData#state.jid,
|
||||
send_multiple(jid:replace_resource(StateData#state.jid,
|
||||
FromNick),
|
||||
StateData#state.server_host,
|
||||
StateData#state.users,
|
||||
@ -992,7 +992,7 @@ is_user_allowed_message_nonparticipant(JID,
|
||||
%% @doc Get information of this participant, or default values.
|
||||
%% If the JID is not a participant, return values for a service message.
|
||||
get_participant_data(From, StateData) ->
|
||||
case (?DICT):find(jlib:jid_tolower(From),
|
||||
case (?DICT):find(jid:tolower(From),
|
||||
StateData#state.users)
|
||||
of
|
||||
{ok, #user{nick = FromNick, role = Role}} ->
|
||||
@ -1069,7 +1069,7 @@ process_presence(From, Nick,
|
||||
Err = jlib:make_error_reply(Packet,
|
||||
?ERRT_NOT_ALLOWED(Lang,
|
||||
ErrText)),
|
||||
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid,
|
||||
ejabberd_router:route(jid:replace_resource(StateData#state.jid,
|
||||
Nick),
|
||||
From, Err),
|
||||
StateData;
|
||||
@ -1082,7 +1082,7 @@ process_presence(From, Nick,
|
||||
Err = jlib:make_error_reply(Packet,
|
||||
?ERRT_CONFLICT(Lang,
|
||||
ErrText)),
|
||||
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid,
|
||||
ejabberd_router:route(jid:replace_resource(StateData#state.jid,
|
||||
Nick), % TODO: s/Nick/""/
|
||||
From, Err),
|
||||
StateData;
|
||||
@ -1093,7 +1093,7 @@ process_presence(From, Nick,
|
||||
Err = jlib:make_error_reply(Packet,
|
||||
?ERRT_CONFLICT(Lang,
|
||||
ErrText)),
|
||||
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid,
|
||||
ejabberd_router:route(jid:replace_resource(StateData#state.jid,
|
||||
Nick),
|
||||
From, Err),
|
||||
StateData;
|
||||
@ -1129,14 +1129,14 @@ close_room_if_temporary_and_empty(StateData1) ->
|
||||
true ->
|
||||
?INFO_MSG("Destroyed MUC room ~s because it's temporary "
|
||||
"and empty",
|
||||
[jlib:jid_to_string(StateData1#state.jid)]),
|
||||
[jid:to_string(StateData1#state.jid)]),
|
||||
add_to_log(room_existence, destroyed, StateData1),
|
||||
{stop, normal, StateData1};
|
||||
_ -> {next_state, normal_state, StateData1}
|
||||
end.
|
||||
|
||||
is_user_online(JID, StateData) ->
|
||||
LJID = jlib:jid_tolower(JID),
|
||||
LJID = jid:tolower(JID),
|
||||
(?DICT):is_key(LJID, StateData#state.users).
|
||||
|
||||
%% Check if the user is occupant of the room, or at least is an admin or owner.
|
||||
@ -1161,7 +1161,7 @@ is_user_online_iq(StanzaId, JID, StateData)
|
||||
when JID#jid.lresource == <<"">> ->
|
||||
try stanzaid_unpack(StanzaId) of
|
||||
{OriginalId, Resource} ->
|
||||
JIDWithResource = jlib:jid_replace_resource(JID,
|
||||
JIDWithResource = jid:replace_resource(JID,
|
||||
Resource),
|
||||
{is_user_online(JIDWithResource, StateData), OriginalId,
|
||||
JIDWithResource}
|
||||
@ -1171,7 +1171,7 @@ is_user_online_iq(StanzaId, JID, StateData)
|
||||
|
||||
handle_iq_vcard(FromFull, ToJID, StanzaId, NewId,
|
||||
Packet) ->
|
||||
ToBareJID = jlib:jid_remove_resource(ToJID),
|
||||
ToBareJID = jid:remove_resource(ToJID),
|
||||
IQ = jlib:iq_query_info(Packet),
|
||||
handle_iq_vcard2(FromFull, ToJID, ToBareJID, StanzaId,
|
||||
NewId, IQ, Packet).
|
||||
@ -1253,7 +1253,7 @@ decide_fate_message(<<"error">>, Packet, From,
|
||||
Reason =
|
||||
io_lib:format("This participant is considered a ghost "
|
||||
"and is expulsed: ~s",
|
||||
[jlib:jid_to_string(From)]),
|
||||
[jid:to_string(From)]),
|
||||
{expulse_sender, Reason};
|
||||
false -> continue_delivery
|
||||
end,
|
||||
@ -1324,7 +1324,7 @@ set_affiliation(JID, Affiliation, StateData) ->
|
||||
set_affiliation(JID, Affiliation, StateData, <<"">>).
|
||||
|
||||
set_affiliation(JID, Affiliation, StateData, Reason) ->
|
||||
LJID = jlib:jid_remove_resource(jlib:jid_tolower(JID)),
|
||||
LJID = jid:remove_resource(jid:tolower(JID)),
|
||||
Affiliations = case Affiliation of
|
||||
none ->
|
||||
(?DICT):erase(LJID, StateData#state.affiliations);
|
||||
@ -1343,11 +1343,11 @@ get_affiliation(JID, StateData) ->
|
||||
of
|
||||
allow -> owner;
|
||||
_ ->
|
||||
LJID = jlib:jid_tolower(JID),
|
||||
LJID = jid:tolower(JID),
|
||||
case (?DICT):find(LJID, StateData#state.affiliations) of
|
||||
{ok, Affiliation} -> Affiliation;
|
||||
_ ->
|
||||
LJID1 = jlib:jid_remove_resource(LJID),
|
||||
LJID1 = jid:remove_resource(LJID),
|
||||
case (?DICT):find(LJID1, StateData#state.affiliations)
|
||||
of
|
||||
{ok, Affiliation} -> Affiliation;
|
||||
@ -1358,7 +1358,7 @@ get_affiliation(JID, StateData) ->
|
||||
of
|
||||
{ok, Affiliation} -> Affiliation;
|
||||
_ ->
|
||||
LJID3 = jlib:jid_remove_resource(LJID2),
|
||||
LJID3 = jid:remove_resource(LJID2),
|
||||
case (?DICT):find(LJID3,
|
||||
StateData#state.affiliations)
|
||||
of
|
||||
@ -1386,7 +1386,7 @@ get_service_affiliation(JID, StateData) ->
|
||||
end.
|
||||
|
||||
set_role(JID, Role, StateData) ->
|
||||
LJID = jlib:jid_tolower(JID),
|
||||
LJID = jid:tolower(JID),
|
||||
LJIDs = case LJID of
|
||||
{U, S, <<"">>} ->
|
||||
(?DICT):fold(fun (J, _, Js) ->
|
||||
@ -1433,7 +1433,7 @@ set_role(JID, Role, StateData) ->
|
||||
StateData#state{users = Users, nicks = Nicks}.
|
||||
|
||||
get_role(JID, StateData) ->
|
||||
LJID = jlib:jid_tolower(JID),
|
||||
LJID = jid:tolower(JID),
|
||||
case (?DICT):find(LJID, StateData#state.users) of
|
||||
{ok, #user{role = Role}} -> Role;
|
||||
_ -> none
|
||||
@ -1483,7 +1483,7 @@ get_max_users_admin_threshold(StateData) ->
|
||||
5).
|
||||
|
||||
get_user_activity(JID, StateData) ->
|
||||
case treap:lookup(jlib:jid_tolower(JID),
|
||||
case treap:lookup(jid:tolower(JID),
|
||||
StateData#state.activity)
|
||||
of
|
||||
{ok, _P, A} -> A;
|
||||
@ -1515,7 +1515,7 @@ store_user_activity(JID, UserActivity, StateData) ->
|
||||
fun(I) when is_number(I), I>=0 -> I end,
|
||||
0)
|
||||
* 1000),
|
||||
Key = jlib:jid_tolower(JID),
|
||||
Key = jid:tolower(JID),
|
||||
Now = now_to_usec(now()),
|
||||
Activity1 = clean_treap(StateData#state.activity,
|
||||
{1, -Now}),
|
||||
@ -1598,7 +1598,7 @@ prepare_room_queue(StateData) ->
|
||||
end.
|
||||
|
||||
add_online_user(JID, Nick, Role, StateData) ->
|
||||
LJID = jlib:jid_tolower(JID),
|
||||
LJID = jid:tolower(JID),
|
||||
Users = (?DICT):store(LJID,
|
||||
#user{jid = JID, nick = Nick, role = Role},
|
||||
StateData#state.users),
|
||||
@ -1618,7 +1618,7 @@ remove_online_user(JID, StateData) ->
|
||||
remove_online_user(JID, StateData, <<"">>).
|
||||
|
||||
remove_online_user(JID, StateData, Reason) ->
|
||||
LJID = jlib:jid_tolower(JID),
|
||||
LJID = jid:tolower(JID),
|
||||
{ok, #user{nick = Nick}} = (?DICT):find(LJID,
|
||||
StateData#state.users),
|
||||
add_to_log(leave, {Nick, Reason}, StateData),
|
||||
@ -1667,7 +1667,7 @@ strip_status(#xmlel{name = <<"presence">>,
|
||||
children = FEls}.
|
||||
|
||||
add_user_presence(JID, Presence, StateData) ->
|
||||
LJID = jlib:jid_tolower(JID),
|
||||
LJID = jid:tolower(JID),
|
||||
FPresence = filter_presence(Presence),
|
||||
Users = (?DICT):update(LJID,
|
||||
fun (#user{} = User) ->
|
||||
@ -1677,7 +1677,7 @@ add_user_presence(JID, Presence, StateData) ->
|
||||
StateData#state{users = Users}.
|
||||
|
||||
add_user_presence_un(JID, Presence, StateData) ->
|
||||
LJID = jlib:jid_tolower(JID),
|
||||
LJID = jid:tolower(JID),
|
||||
FPresence = filter_presence(Presence),
|
||||
Users = (?DICT):update(LJID,
|
||||
fun (#user{} = User) ->
|
||||
@ -1691,8 +1691,8 @@ add_user_presence_un(JID, Presence, StateData) ->
|
||||
%% Return jid record.
|
||||
find_jids_by_nick(Nick, StateData) ->
|
||||
case (?DICT):find(Nick, StateData#state.nicks) of
|
||||
{ok, [User]} -> [jlib:make_jid(User)];
|
||||
{ok, Users} -> [jlib:make_jid(LJID) || LJID <- Users];
|
||||
{ok, [User]} -> [jid:make(User)];
|
||||
{ok, Users} -> [jid:make(LJID) || LJID <- Users];
|
||||
error -> false
|
||||
end.
|
||||
|
||||
@ -1700,7 +1700,7 @@ find_jids_by_nick(Nick, StateData) ->
|
||||
%% highest-priority presence. Return jid record.
|
||||
find_jid_by_nick(Nick, StateData) ->
|
||||
case (?DICT):find(Nick, StateData#state.nicks) of
|
||||
{ok, [User]} -> jlib:make_jid(User);
|
||||
{ok, [User]} -> jid:make(User);
|
||||
{ok, [FirstUser | Users]} ->
|
||||
#user{last_presence = FirstPresence} =
|
||||
(?DICT):fetch(FirstUser, StateData#state.users),
|
||||
@ -1718,7 +1718,7 @@ find_jid_by_nick(Nick, StateData) ->
|
||||
end
|
||||
end,
|
||||
{FirstUser, FirstPresence}, Users),
|
||||
jlib:make_jid(LJID);
|
||||
jid:make(LJID);
|
||||
error -> false
|
||||
end.
|
||||
|
||||
@ -1748,7 +1748,7 @@ find_nick_by_jid(Jid, StateData) ->
|
||||
Nick.
|
||||
|
||||
is_nick_change(JID, Nick, StateData) ->
|
||||
LJID = jlib:jid_tolower(JID),
|
||||
LJID = jid:tolower(JID),
|
||||
case Nick of
|
||||
<<"">> -> false;
|
||||
_ ->
|
||||
@ -1760,8 +1760,8 @@ is_nick_change(JID, Nick, StateData) ->
|
||||
nick_collision(User, Nick, StateData) ->
|
||||
UserOfNick = find_jid_by_nick(Nick, StateData),
|
||||
(UserOfNick /= false andalso
|
||||
jlib:jid_remove_resource(jlib:jid_tolower(UserOfNick))
|
||||
/= jlib:jid_remove_resource(jlib:jid_tolower(User))).
|
||||
jid:remove_resource(jid:tolower(UserOfNick))
|
||||
/= jid:remove_resource(jid:tolower(User))).
|
||||
|
||||
add_new_user(From, Nick,
|
||||
#xmlel{attrs = Attrs, children = Els} = Packet,
|
||||
@ -1796,7 +1796,7 @@ add_new_user(From, Nick,
|
||||
Err = jlib:make_error_reply(Packet,
|
||||
?ERR_SERVICE_UNAVAILABLE),
|
||||
ejabberd_router:route % TODO: s/Nick/""/
|
||||
(jlib:jid_replace_resource(StateData#state.jid, Nick),
|
||||
(jid:replace_resource(StateData#state.jid, Nick),
|
||||
From, Err),
|
||||
StateData;
|
||||
{_, _, _, none} ->
|
||||
@ -1813,14 +1813,14 @@ add_new_user(From, Nick,
|
||||
ErrText)
|
||||
end),
|
||||
ejabberd_router:route % TODO: s/Nick/""/
|
||||
(jlib:jid_replace_resource(StateData#state.jid, Nick),
|
||||
(jid:replace_resource(StateData#state.jid, Nick),
|
||||
From, Err),
|
||||
StateData;
|
||||
{_, true, _, _} ->
|
||||
ErrText = <<"That nickname is already in use by another occupant">>,
|
||||
Err = jlib:make_error_reply(Packet,
|
||||
?ERRT_CONFLICT(Lang, ErrText)),
|
||||
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid,
|
||||
ejabberd_router:route(jid:replace_resource(StateData#state.jid,
|
||||
Nick),
|
||||
From, Err),
|
||||
StateData;
|
||||
@ -1828,7 +1828,7 @@ add_new_user(From, Nick,
|
||||
ErrText = <<"That nickname is registered by another person">>,
|
||||
Err = jlib:make_error_reply(Packet,
|
||||
?ERRT_CONFLICT(Lang, ErrText)),
|
||||
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid,
|
||||
ejabberd_router:route(jid:replace_resource(StateData#state.jid,
|
||||
Nick),
|
||||
From, Err),
|
||||
StateData;
|
||||
@ -1859,14 +1859,14 @@ add_new_user(From, Nick,
|
||||
?ERRT_NOT_AUTHORIZED(Lang,
|
||||
ErrText)),
|
||||
ejabberd_router:route % TODO: s/Nick/""/
|
||||
(jlib:jid_replace_resource(StateData#state.jid,
|
||||
(jid:replace_resource(StateData#state.jid,
|
||||
Nick),
|
||||
From, Err),
|
||||
StateData;
|
||||
captcha_required ->
|
||||
SID = xml:get_attr_s(<<"id">>, Attrs),
|
||||
RoomJID = StateData#state.jid,
|
||||
To = jlib:jid_replace_resource(RoomJID, Nick),
|
||||
To = jid:replace_resource(RoomJID, Nick),
|
||||
Limiter = {From#jid.luser, From#jid.lserver},
|
||||
case ejabberd_captcha:create_captcha(SID, RoomJID, To,
|
||||
Lang, Limiter, From)
|
||||
@ -1885,7 +1885,7 @@ add_new_user(From, Nick,
|
||||
?ERRT_RESOURCE_CONSTRAINT(Lang,
|
||||
ErrText)),
|
||||
ejabberd_router:route % TODO: s/Nick/""/
|
||||
(jlib:jid_replace_resource(StateData#state.jid,
|
||||
(jid:replace_resource(StateData#state.jid,
|
||||
Nick),
|
||||
From, Err),
|
||||
StateData;
|
||||
@ -1895,7 +1895,7 @@ add_new_user(From, Nick,
|
||||
?ERRT_INTERNAL_SERVER_ERROR(Lang,
|
||||
ErrText)),
|
||||
ejabberd_router:route % TODO: s/Nick/""/
|
||||
(jlib:jid_replace_resource(StateData#state.jid,
|
||||
(jid:replace_resource(StateData#state.jid,
|
||||
Nick),
|
||||
From, Err),
|
||||
StateData
|
||||
@ -1906,7 +1906,7 @@ add_new_user(From, Nick,
|
||||
?ERRT_NOT_AUTHORIZED(Lang,
|
||||
ErrText)),
|
||||
ejabberd_router:route % TODO: s/Nick/""/
|
||||
(jlib:jid_replace_resource(StateData#state.jid,
|
||||
(jid:replace_resource(StateData#state.jid,
|
||||
Nick),
|
||||
From, Err),
|
||||
StateData
|
||||
@ -2086,7 +2086,7 @@ send_update_presence(JID, Reason, StateData) ->
|
||||
end.
|
||||
|
||||
send_update_presence1(JID, Reason, StateData) ->
|
||||
LJID = jlib:jid_tolower(JID),
|
||||
LJID = jid:tolower(JID),
|
||||
LJIDs = case LJID of
|
||||
{U, S, <<"">>} ->
|
||||
(?DICT):fold(fun (J, _, Js) ->
|
||||
@ -2120,13 +2120,13 @@ send_new_presence(NJID, Reason, StateData, OldStateData) ->
|
||||
|
||||
send_new_presence1(NJID, Reason, StateData) ->
|
||||
#user{nick = Nick} =
|
||||
(?DICT):fetch(jlib:jid_tolower(NJID),
|
||||
(?DICT):fetch(jid:tolower(NJID),
|
||||
StateData#state.users),
|
||||
LJID = find_jid_by_nick(Nick, StateData),
|
||||
{ok,
|
||||
#user{jid = RealJID, role = Role,
|
||||
last_presence = Presence}} =
|
||||
(?DICT):find(jlib:jid_tolower(LJID),
|
||||
(?DICT):find(jid:tolower(LJID),
|
||||
StateData#state.users),
|
||||
Affiliation = get_affiliation(LJID, StateData),
|
||||
SAffiliation = affiliation_to_list(Affiliation),
|
||||
@ -2138,7 +2138,7 @@ send_new_presence1(NJID, Reason, StateData) ->
|
||||
of
|
||||
true ->
|
||||
[{<<"jid">>,
|
||||
jlib:jid_to_string(RealJID)},
|
||||
jid:to_string(RealJID)},
|
||||
{<<"affiliation">>, SAffiliation},
|
||||
{<<"role">>, SRole}];
|
||||
_ ->
|
||||
@ -2198,7 +2198,7 @@ send_new_presence1(NJID, Reason, StateData) ->
|
||||
=
|
||||
ItemEls}
|
||||
| Status3]}]),
|
||||
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid,
|
||||
ejabberd_router:route(jid:replace_resource(StateData#state.jid,
|
||||
Nick),
|
||||
Info#user.jid, Packet)
|
||||
end,
|
||||
@ -2211,14 +2211,14 @@ send_existing_presences(ToJID, StateData) ->
|
||||
end.
|
||||
|
||||
send_existing_presences1(ToJID, StateData) ->
|
||||
LToJID = jlib:jid_tolower(ToJID),
|
||||
LToJID = jid:tolower(ToJID),
|
||||
{ok, #user{jid = RealToJID, role = Role}} =
|
||||
(?DICT):find(LToJID, StateData#state.users),
|
||||
lists:foreach(fun ({FromNick, _Users}) ->
|
||||
LJID = find_jid_by_nick(FromNick, StateData),
|
||||
#user{jid = FromJID, role = FromRole,
|
||||
last_presence = Presence} =
|
||||
(?DICT):fetch(jlib:jid_tolower(LJID),
|
||||
(?DICT):fetch(jid:tolower(LJID),
|
||||
StateData#state.users),
|
||||
case RealToJID of
|
||||
FromJID -> ok;
|
||||
@ -2231,7 +2231,7 @@ send_existing_presences1(ToJID, StateData) ->
|
||||
of
|
||||
true ->
|
||||
[{<<"jid">>,
|
||||
jlib:jid_to_string(FromJID)},
|
||||
jid:to_string(FromJID)},
|
||||
{<<"affiliation">>,
|
||||
affiliation_to_list(FromAffiliation)},
|
||||
{<<"role">>,
|
||||
@ -2258,7 +2258,7 @@ send_existing_presences1(ToJID, StateData) ->
|
||||
children
|
||||
=
|
||||
[]}]}]),
|
||||
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid,
|
||||
ejabberd_router:route(jid:replace_resource(StateData#state.jid,
|
||||
FromNick),
|
||||
RealToJID, Packet)
|
||||
end
|
||||
@ -2269,7 +2269,7 @@ now_to_usec({MSec, Sec, USec}) ->
|
||||
(MSec * 1000000 + Sec) * 1000000 + USec.
|
||||
|
||||
change_nick(JID, Nick, StateData) ->
|
||||
LJID = jlib:jid_tolower(JID),
|
||||
LJID = jid:tolower(JID),
|
||||
{ok, #user{nick = OldNick}} = (?DICT):find(LJID,
|
||||
StateData#state.users),
|
||||
Users = (?DICT):update(LJID,
|
||||
@ -2311,7 +2311,7 @@ send_nick_changing(JID, OldNick, StateData,
|
||||
{ok,
|
||||
#user{jid = RealJID, nick = Nick, role = Role,
|
||||
last_presence = Presence}} =
|
||||
(?DICT):find(jlib:jid_tolower(JID),
|
||||
(?DICT):find(jid:tolower(JID),
|
||||
StateData#state.users),
|
||||
Affiliation = get_affiliation(JID, StateData),
|
||||
SAffiliation = affiliation_to_list(Affiliation),
|
||||
@ -2323,7 +2323,7 @@ send_nick_changing(JID, OldNick, StateData,
|
||||
of
|
||||
true ->
|
||||
[{<<"jid">>,
|
||||
jlib:jid_to_string(RealJID)},
|
||||
jid:to_string(RealJID)},
|
||||
{<<"affiliation">>, SAffiliation},
|
||||
{<<"role">>, SRole},
|
||||
{<<"nick">>, Nick}];
|
||||
@ -2338,7 +2338,7 @@ send_nick_changing(JID, OldNick, StateData,
|
||||
of
|
||||
true ->
|
||||
[{<<"jid">>,
|
||||
jlib:jid_to_string(RealJID)},
|
||||
jid:to_string(RealJID)},
|
||||
{<<"affiliation">>, SAffiliation},
|
||||
{<<"role">>, SRole}];
|
||||
_ ->
|
||||
@ -2392,13 +2392,13 @@ send_nick_changing(JID, OldNick, StateData,
|
||||
=
|
||||
[]}|Status110]}]),
|
||||
if SendOldUnavailable ->
|
||||
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid,
|
||||
ejabberd_router:route(jid:replace_resource(StateData#state.jid,
|
||||
OldNick),
|
||||
Info#user.jid, Packet1);
|
||||
true -> ok
|
||||
end,
|
||||
if SendNewAvailable ->
|
||||
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid,
|
||||
ejabberd_router:route(jid:replace_resource(StateData#state.jid,
|
||||
Nick),
|
||||
Info#user.jid, Packet2);
|
||||
true -> ok
|
||||
@ -2442,7 +2442,7 @@ add_message_to_history(FromNick, FromJID, Packet, StateData) ->
|
||||
Address = #xmlel{name = <<"address">>,
|
||||
attrs = [{<<"type">>, <<"ofrom">>},
|
||||
{<<"jid">>,
|
||||
jlib:jid_to_string(FromJID)}],
|
||||
jid:to_string(FromJID)}],
|
||||
children = []},
|
||||
Addresses = #xmlel{name = <<"addresses">>,
|
||||
attrs = [{<<"xmlns">>, ?NS_ADDRESS}],
|
||||
@ -2451,7 +2451,7 @@ add_message_to_history(FromNick, FromJID, Packet, StateData) ->
|
||||
end,
|
||||
TSPacket = jlib:add_delay_info(AddrPacket, StateData#state.jid, TimeStamp),
|
||||
SPacket =
|
||||
jlib:replace_from_to(jlib:jid_replace_resource(StateData#state.jid,
|
||||
jlib:replace_from_to(jid:replace_resource(StateData#state.jid,
|
||||
FromNick),
|
||||
StateData#state.jid, TSPacket),
|
||||
Size = element_size(SPacket),
|
||||
@ -2465,7 +2465,7 @@ send_history(JID, Shift, StateData) ->
|
||||
lists:foldl(fun ({Nick, Packet, HaveSubject, _TimeStamp,
|
||||
_Size},
|
||||
B) ->
|
||||
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid,
|
||||
ejabberd_router:route(jid:replace_resource(StateData#state.jid,
|
||||
Nick),
|
||||
JID, Packet),
|
||||
B or HaveSubject
|
||||
@ -2556,7 +2556,7 @@ items_with_affiliation(SAffiliation, StateData) ->
|
||||
attrs =
|
||||
[{<<"affiliation">>,
|
||||
affiliation_to_list(Affiliation)},
|
||||
{<<"jid">>, jlib:jid_to_string(JID)}],
|
||||
{<<"jid">>, jid:to_string(JID)}],
|
||||
children =
|
||||
[#xmlel{name = <<"reason">>, attrs = [],
|
||||
children = [{xmlcdata, Reason}]}]};
|
||||
@ -2565,7 +2565,7 @@ items_with_affiliation(SAffiliation, StateData) ->
|
||||
attrs =
|
||||
[{<<"affiliation">>,
|
||||
affiliation_to_list(Affiliation)},
|
||||
{<<"jid">>, jlib:jid_to_string(JID)}],
|
||||
{<<"jid">>, jid:to_string(JID)}],
|
||||
children = []}
|
||||
end,
|
||||
search_affiliation(SAffiliation, StateData)).
|
||||
@ -2578,7 +2578,7 @@ user_to_item(#user{role = Role, nick = Nick, jid = JID},
|
||||
[{<<"role">>, role_to_list(Role)},
|
||||
{<<"affiliation">>, affiliation_to_list(Affiliation)},
|
||||
{<<"nick">>, Nick},
|
||||
{<<"jid">>, jlib:jid_to_string(JID)}],
|
||||
{<<"jid">>, jid:to_string(JID)}],
|
||||
children = []}.
|
||||
|
||||
search_role(Role, StateData) ->
|
||||
@ -2604,8 +2604,8 @@ process_admin_items_set(UJID, Items, Lang, StateData) ->
|
||||
{result, Res} ->
|
||||
?INFO_MSG("Processing MUC admin query from ~s in "
|
||||
"room ~s:~n ~p",
|
||||
[jlib:jid_to_string(UJID),
|
||||
jlib:jid_to_string(StateData#state.jid), Res]),
|
||||
[jid:to_string(UJID),
|
||||
jid:to_string(StateData#state.jid), Res]),
|
||||
NSD = lists:foldl(process_item_change(UJID),
|
||||
StateData, lists:flatten(Res)),
|
||||
case (NSD#state.config)#config.persistent of
|
||||
@ -2705,7 +2705,7 @@ find_changed_items(UJID, UAffiliation, URole,
|
||||
Lang, StateData, Res) ->
|
||||
TJID = case xml:get_attr(<<"jid">>, Attrs) of
|
||||
{value, S} ->
|
||||
case jlib:string_to_jid(S) of
|
||||
case jid:from_string(S) of
|
||||
error ->
|
||||
ErrText = iolist_to_binary(
|
||||
io_lib:format(translate:translate(
|
||||
@ -2766,9 +2766,9 @@ find_changed_items(UJID, UAffiliation, URole,
|
||||
StateData)
|
||||
of
|
||||
[{OJID, _}] ->
|
||||
jlib:jid_remove_resource(OJID)
|
||||
jid:remove_resource(OJID)
|
||||
/=
|
||||
jlib:jid_tolower(jlib:jid_remove_resource(UJID));
|
||||
jid:tolower(jid:remove_resource(UJID));
|
||||
_ -> true
|
||||
end;
|
||||
_ -> false
|
||||
@ -2782,7 +2782,7 @@ find_changed_items(UJID, UAffiliation, URole,
|
||||
Reason = xml:get_path_s(Item,
|
||||
[{elem, <<"reason">>},
|
||||
cdata]),
|
||||
MoreRes = [{jlib:jid_remove_resource(Jidx),
|
||||
MoreRes = [{jid:remove_resource(Jidx),
|
||||
affiliation, SAffiliation, Reason}
|
||||
|| Jidx <- JIDs],
|
||||
find_changed_items(UJID, UAffiliation, URole,
|
||||
@ -2814,9 +2814,9 @@ find_changed_items(UJID, UAffiliation, URole,
|
||||
StateData)
|
||||
of
|
||||
[{OJID, _}] ->
|
||||
jlib:jid_remove_resource(OJID)
|
||||
jid:remove_resource(OJID)
|
||||
/=
|
||||
jlib:jid_tolower(jlib:jid_remove_resource(UJID));
|
||||
jid:tolower(jid:remove_resource(UJID));
|
||||
_ -> true
|
||||
end;
|
||||
_ -> false
|
||||
@ -2975,7 +2975,7 @@ send_kickban_presence(UJID, JID, Reason, Code, StateData) ->
|
||||
|
||||
send_kickban_presence(UJID, JID, Reason, Code, NewAffiliation,
|
||||
StateData) ->
|
||||
LJID = jlib:jid_tolower(JID),
|
||||
LJID = jid:tolower(JID),
|
||||
LJIDs = case LJID of
|
||||
{U, S, <<"">>} ->
|
||||
(?DICT):fold(fun (J, _, Js) ->
|
||||
@ -3004,14 +3004,14 @@ send_kickban_presence(UJID, JID, Reason, Code, NewAffiliation,
|
||||
send_kickban_presence1(MJID, UJID, Reason, Code, Affiliation,
|
||||
StateData) ->
|
||||
{ok, #user{jid = RealJID, nick = Nick}} =
|
||||
(?DICT):find(jlib:jid_tolower(UJID),
|
||||
(?DICT):find(jid:tolower(UJID),
|
||||
StateData#state.users),
|
||||
SAffiliation = affiliation_to_list(Affiliation),
|
||||
BannedJIDString = jlib:jid_to_string(RealJID),
|
||||
BannedJIDString = jid:to_string(RealJID),
|
||||
case MJID /= <<"">> of
|
||||
true ->
|
||||
{ok, #user{nick = ActorNick}} =
|
||||
(?DICT):find(jlib:jid_tolower(MJID),
|
||||
(?DICT):find(jid:tolower(MJID),
|
||||
StateData#state.users);
|
||||
false ->
|
||||
ActorNick = <<"">>
|
||||
@ -3064,7 +3064,7 @@ send_kickban_presence1(MJID, UJID, Reason, Code, Affiliation,
|
||||
Code}],
|
||||
children =
|
||||
[]}]}]},
|
||||
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid,
|
||||
ejabberd_router:route(jid:replace_resource(StateData#state.jid,
|
||||
Nick),
|
||||
Info#user.jid, Packet)
|
||||
end,
|
||||
@ -3099,8 +3099,8 @@ process_iq_owner(From, set, Lang, SubEl, StateData) ->
|
||||
end;
|
||||
[#xmlel{name = <<"destroy">>} = SubEl1] ->
|
||||
?INFO_MSG("Destroyed MUC room ~s by the owner ~s",
|
||||
[jlib:jid_to_string(StateData#state.jid),
|
||||
jlib:jid_to_string(From)]),
|
||||
[jid:to_string(StateData#state.jid),
|
||||
jid:to_string(From)]),
|
||||
add_to_log(room_existence, destroyed, StateData),
|
||||
destroy_room(SubEl1, StateData);
|
||||
Items ->
|
||||
@ -3265,7 +3265,7 @@ is_password_settings_correct(XEl, StateData) ->
|
||||
{<<"var">>, Var}],
|
||||
children =
|
||||
[#xmlel{name = <<"value">>, attrs = [],
|
||||
children = [{xmlcdata, jlib:jid_to_string(JID)}]}
|
||||
children = [{xmlcdata, jid:to_string(JID)}]}
|
||||
|| JID <- JIDList]}).
|
||||
|
||||
get_default_room_maxusers(RoomState) ->
|
||||
@ -3301,7 +3301,7 @@ get_config(Lang, StateData, From) ->
|
||||
translate:translate(
|
||||
Lang,
|
||||
<<"Configuration of room ~s">>),
|
||||
[jlib:jid_to_string(StateData#state.jid)]))}]},
|
||||
[jid:to_string(StateData#state.jid)]))}]},
|
||||
#xmlel{name = <<"field">>,
|
||||
attrs =
|
||||
[{<<"type">>, <<"hidden">>},
|
||||
@ -3799,7 +3799,7 @@ set_xoption([{<<"muc#roomconfig_captcha_whitelist">>,
|
||||
Vals}
|
||||
| Opts],
|
||||
Config) ->
|
||||
JIDs = [jlib:string_to_jid(Val) || Val <- Vals],
|
||||
JIDs = [jid:from_string(Val) || Val <- Vals],
|
||||
?SET_JIDMULTI_XOPT(captcha_whitelist, JIDs);
|
||||
set_xoption([{<<"FORM_TYPE">>, _} | Opts], Config) ->
|
||||
set_xoption(Opts, Config);
|
||||
@ -4051,7 +4051,7 @@ destroy_room(DEl, StateData) ->
|
||||
children =
|
||||
[]},
|
||||
DEl]}]},
|
||||
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid,
|
||||
ejabberd_router:route(jid:replace_resource(StateData#state.jid,
|
||||
Nick),
|
||||
Info#user.jid, Packet)
|
||||
end,
|
||||
@ -4218,7 +4218,7 @@ get_mucroom_disco_items(StateData) ->
|
||||
#xmlel{name = <<"item">>,
|
||||
attrs =
|
||||
[{<<"jid">>,
|
||||
jlib:jid_to_string({StateData#state.room,
|
||||
jid:to_string({StateData#state.room,
|
||||
StateData#state.host,
|
||||
Nick})},
|
||||
{<<"name">>, Nick}],
|
||||
@ -4295,7 +4295,7 @@ prepare_request_form(Requester, Nick, Lang) ->
|
||||
[{xmlcdata,
|
||||
<<"participant">>}]}]},
|
||||
?STRINGXFIELD(<<"User JID">>, <<"muc#jid">>,
|
||||
(jlib:jid_to_string(Requester))),
|
||||
(jid:to_string(Requester))),
|
||||
?STRINGXFIELD(<<"Nickname">>, <<"muc#roomnick">>,
|
||||
Nick),
|
||||
?BOOLXFIELD(<<"Grant voice to this person?">>,
|
||||
@ -4352,7 +4352,7 @@ extract_jid_from_voice_approvement(Els) ->
|
||||
Res -> Res
|
||||
end,
|
||||
lists:foldl(fun ({<<"muc#jid">>, [JIDStr]}, error) ->
|
||||
case jlib:string_to_jid(JIDStr) of
|
||||
case jid:from_string(JIDStr) of
|
||||
error -> error;
|
||||
J -> {ok, J}
|
||||
end;
|
||||
@ -4401,7 +4401,7 @@ check_invitation(From, Els, Lang, StateData) ->
|
||||
_ -> throw({error, ?ERR_BAD_REQUEST})
|
||||
end,
|
||||
JID = case
|
||||
jlib:string_to_jid(xml:get_tag_attr_s(<<"to">>,
|
||||
jid:from_string(xml:get_tag_attr_s(<<"to">>,
|
||||
InviteEl))
|
||||
of
|
||||
error -> throw({error, ?ERR_JID_MALFORMED});
|
||||
@ -4419,7 +4419,7 @@ check_invitation(From, Els, Lang, StateData) ->
|
||||
Continue1 -> [Continue1]
|
||||
end,
|
||||
IEl = [#xmlel{name = <<"invite">>,
|
||||
attrs = [{<<"from">>, jlib:jid_to_string(From)}],
|
||||
attrs = [{<<"from">>, jid:to_string(From)}],
|
||||
children =
|
||||
[#xmlel{name = <<"reason">>, attrs = [],
|
||||
children = [{xmlcdata, Reason}]}]
|
||||
@ -4442,8 +4442,8 @@ check_invitation(From, Els, Lang, StateData) ->
|
||||
translate:translate(
|
||||
Lang,
|
||||
<<"~s invites you to the room ~s">>),
|
||||
[jlib:jid_to_string(From),
|
||||
jlib:jid_to_string({StateData#state.room,
|
||||
[jid:to_string(From),
|
||||
jid:to_string({StateData#state.room,
|
||||
StateData#state.host,
|
||||
<<"">>})]),
|
||||
case
|
||||
@ -4473,7 +4473,7 @@ check_invitation(From, Els, Lang, StateData) ->
|
||||
attrs =
|
||||
[{<<"xmlns">>, ?NS_XCONFERENCE},
|
||||
{<<"jid">>,
|
||||
jlib:jid_to_string({StateData#state.room,
|
||||
jid:to_string({StateData#state.room,
|
||||
StateData#state.host,
|
||||
<<"">>})}],
|
||||
children = [{xmlcdata, Reason}]},
|
||||
@ -4506,7 +4506,7 @@ check_decline_invitation(Packet) ->
|
||||
(?NS_MUC_USER) = xml:get_tag_attr_s(<<"xmlns">>, XEl),
|
||||
DEl = xml:get_subtag(XEl, <<"decline">>),
|
||||
ToString = xml:get_tag_attr_s(<<"to">>, DEl),
|
||||
ToJID = jlib:string_to_jid(ToString),
|
||||
ToJID = jid:from_string(ToString),
|
||||
{true, {Packet, XEl, DEl, ToJID}}.
|
||||
|
||||
%% Send the decline to the inviter user.
|
||||
@ -4514,7 +4514,7 @@ check_decline_invitation(Packet) ->
|
||||
send_decline_invitation({Packet, XEl, DEl, ToJID},
|
||||
RoomJID, FromJID) ->
|
||||
FromString =
|
||||
jlib:jid_to_string(jlib:jid_remove_resource(FromJID)),
|
||||
jid:to_string(jid:remove_resource(FromJID)),
|
||||
#xmlel{name = <<"decline">>, attrs = DAttrs,
|
||||
children = DEls} =
|
||||
DEl,
|
||||
@ -4564,7 +4564,7 @@ add_to_log(Type, Data, StateData) ->
|
||||
%% Users number checking
|
||||
|
||||
tab_add_online_user(JID, StateData) ->
|
||||
{LUser, LServer, LResource} = jlib:jid_tolower(JID),
|
||||
{LUser, LServer, LResource} = jid:tolower(JID),
|
||||
US = {LUser, LServer},
|
||||
Room = StateData#state.room,
|
||||
Host = StateData#state.host,
|
||||
@ -4573,7 +4573,7 @@ tab_add_online_user(JID, StateData) ->
|
||||
room = Room, host = Host}).
|
||||
|
||||
tab_remove_online_user(JID, StateData) ->
|
||||
{LUser, LServer, LResource} = jlib:jid_tolower(JID),
|
||||
{LUser, LServer, LResource} = jid:tolower(JID),
|
||||
US = {LUser, LServer},
|
||||
Room = StateData#state.room,
|
||||
Host = StateData#state.host,
|
||||
@ -4582,7 +4582,7 @@ tab_remove_online_user(JID, StateData) ->
|
||||
room = Room, host = Host}).
|
||||
|
||||
tab_count_user(JID) ->
|
||||
{LUser, LServer, _} = jlib:jid_tolower(JID),
|
||||
{LUser, LServer, _} = jid:tolower(JID),
|
||||
US = {LUser, LServer},
|
||||
case catch ets:select(muc_online_users,
|
||||
[{#muc_online_users{us = US, _ = '_'}, [], [[]]}])
|
||||
|
@ -871,7 +871,7 @@ process_discoitems_result(From, LServiceS, Els) ->
|
||||
case XML of
|
||||
#xmlel{name = <<"item">>, attrs = Attrs} ->
|
||||
SJID = xml:get_attr_s(<<"jid">>, Attrs),
|
||||
case jlib:string_to_jid(SJID) of
|
||||
case jid:from_string(SJID) of
|
||||
#jid{luser = <<"">>,
|
||||
lresource = <<"">>} ->
|
||||
[SJID | Res];
|
||||
@ -1214,9 +1214,9 @@ make_reply(internal_server_error, Lang, ErrText) ->
|
||||
make_reply(forbidden, Lang, ErrText) ->
|
||||
?ERRT_FORBIDDEN(Lang, ErrText).
|
||||
|
||||
stj(String) -> jlib:string_to_jid(String).
|
||||
stj(String) -> jid:from_string(String).
|
||||
|
||||
jts(String) -> jlib:jid_to_string(String).
|
||||
jts(String) -> jid:to_string(String).
|
||||
|
||||
mod_opt_type(access) ->
|
||||
fun (A) when is_atom(A) -> A end;
|
||||
|
@ -248,7 +248,7 @@ store_offline_msg(Host, {User, _}, Msgs, Len, MaxOfflineMsgs,
|
||||
|
||||
get_max_user_messages(AccessRule, {User, Server}, Host) ->
|
||||
case acl:match_rule(
|
||||
Host, AccessRule, jlib:make_jid(User, Server, <<"">>)) of
|
||||
Host, AccessRule, jid:make(User, Server, <<"">>)) of
|
||||
Max when is_integer(Max) -> Max;
|
||||
infinity -> infinity;
|
||||
_ -> ?MAX_USER_MESSAGES
|
||||
@ -400,8 +400,8 @@ find_x_expire(TimeStamp, [El | Els]) ->
|
||||
end.
|
||||
|
||||
resend_offline_messages(User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
US = {LUser, LServer},
|
||||
F = fun () ->
|
||||
Rs = mnesia:wread({offline_msg, US}),
|
||||
@ -423,8 +423,8 @@ resend_offline_messages(User, Server) ->
|
||||
end.
|
||||
|
||||
pop_offline_messages(Ls, User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
pop_offline_messages(Ls, LUser, LServer,
|
||||
gen_mod:db_type(LServer, ?MODULE)).
|
||||
|
||||
@ -504,7 +504,7 @@ pop_offline_messages(Ls, LUser, LServer, riak) ->
|
||||
end.
|
||||
|
||||
remove_expired_messages(Server) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
remove_expired_messages(LServer,
|
||||
gen_mod:db_type(LServer, ?MODULE)).
|
||||
|
||||
@ -529,7 +529,7 @@ remove_expired_messages(_LServer, odbc) -> {atomic, ok};
|
||||
remove_expired_messages(_LServer, riak) -> {atomic, ok}.
|
||||
|
||||
remove_old_messages(Days, Server) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
remove_old_messages(Days, LServer,
|
||||
gen_mod:db_type(LServer, ?MODULE)).
|
||||
|
||||
@ -568,8 +568,8 @@ remove_old_messages(_Days, _LServer, riak) ->
|
||||
{atomic, ok}.
|
||||
|
||||
remove_user(User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
remove_user(LUser, LServer,
|
||||
gen_mod:db_type(LServer, ?MODULE)).
|
||||
|
||||
@ -678,8 +678,8 @@ offline_msg_to_route(LServer, #offline_msg{} = R) ->
|
||||
jlib:add_delay_info(R#offline_msg.packet, LServer, R#offline_msg.timestamp,
|
||||
<<"Offline Storage">>)};
|
||||
offline_msg_to_route(_LServer, #xmlel{} = El) ->
|
||||
To = jlib:string_to_jid(xml:get_tag_attr_s(<<"to">>, El)),
|
||||
From = jlib:string_to_jid(xml:get_tag_attr_s(<<"from">>, El)),
|
||||
To = jid:from_string(xml:get_tag_attr_s(<<"to">>, El)),
|
||||
From = jid:from_string(xml:get_tag_attr_s(<<"from">>, El)),
|
||||
if (To /= error) and (From /= error) ->
|
||||
{route, From, To, El};
|
||||
true ->
|
||||
@ -731,8 +731,8 @@ format_user_queue(Msgs, DBType) when DBType == mnesia; DBType == riak ->
|
||||
[Year, Month, Day,
|
||||
Hour, Minute,
|
||||
Second])),
|
||||
SFrom = jlib:jid_to_string(From),
|
||||
STo = jlib:jid_to_string(To),
|
||||
SFrom = jid:to_string(From),
|
||||
STo = jid:to_string(To),
|
||||
Attrs2 = jlib:replace_from_to_attrs(SFrom, STo, Attrs),
|
||||
Packet = #xmlel{name = Name, attrs = Attrs2,
|
||||
children = Els},
|
||||
@ -761,8 +761,8 @@ format_user_queue(Msgs, odbc) ->
|
||||
Msgs).
|
||||
|
||||
user_queue(User, Server, Query, Lang) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
US = {LUser, LServer},
|
||||
DBType = gen_mod:db_type(LServer, ?MODULE),
|
||||
Res = user_queue_parse_query(LUser, LServer, Query,
|
||||
@ -893,7 +893,7 @@ user_queue_parse_query(LUser, LServer, Query, odbc) ->
|
||||
end.
|
||||
|
||||
us_to_list({User, Server}) ->
|
||||
jlib:jid_to_string({User, Server, <<"">>}).
|
||||
jid:to_string({User, Server, <<"">>}).
|
||||
|
||||
get_queue_length(LUser, LServer) ->
|
||||
get_queue_length(LUser, LServer,
|
||||
@ -944,7 +944,7 @@ get_messages_subset2(Max, Length, MsgsAll, DBType)
|
||||
{MsgsFirstN, Msgs2} = lists:split(FirstN, MsgsAll),
|
||||
MsgsLastN = lists:nthtail(Length - FirstN - FirstN,
|
||||
Msgs2),
|
||||
NoJID = jlib:make_jid(<<"...">>, <<"...">>, <<"">>),
|
||||
NoJID = jid:make(<<"...">>, <<"...">>, <<"">>),
|
||||
IntermediateMsg = #offline_msg{timestamp = now(),
|
||||
from = NoJID, to = NoJID,
|
||||
packet =
|
||||
@ -961,8 +961,8 @@ get_messages_subset2(Max, Length, MsgsAll, odbc) ->
|
||||
MsgsFirstN ++ [IntermediateMsg] ++ MsgsLastN.
|
||||
|
||||
webadmin_user(Acc, User, Server, Lang) ->
|
||||
QueueLen = get_queue_length(jlib:nodeprep(User),
|
||||
jlib:nameprep(Server)),
|
||||
QueueLen = get_queue_length(jid:nodeprep(User),
|
||||
jid:nameprep(Server)),
|
||||
FQueueLen = [?AC(<<"queue/">>,
|
||||
(iolist_to_binary(integer_to_list(QueueLen))))],
|
||||
Acc ++
|
||||
@ -973,8 +973,8 @@ webadmin_user(Acc, User, Server, Lang) ->
|
||||
<<"Remove All Offline Messages">>)].
|
||||
|
||||
delete_all_msgs(User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
delete_all_msgs(LUser, LServer,
|
||||
gen_mod:db_type(LServer, ?MODULE)).
|
||||
|
||||
@ -1014,8 +1014,8 @@ webadmin_user_parse_query(Acc, _Action, _User, _Server,
|
||||
|
||||
%% Returns as integer the number of offline messages for a given user
|
||||
count_offline_messages(User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
DBType = gen_mod:db_type(LServer, ?MODULE),
|
||||
count_offline_messages(LUser, LServer, DBType).
|
||||
|
||||
@ -1099,9 +1099,9 @@ import(LServer) ->
|
||||
[{<<"select username, xml from spool;">>,
|
||||
fun([LUser, XML]) ->
|
||||
El = #xmlel{} = xml_stream:parse_element(XML),
|
||||
From = #jid{} = jlib:string_to_jid(
|
||||
From = #jid{} = jid:from_string(
|
||||
xml:get_attr_s(<<"from">>, El#xmlel.attrs)),
|
||||
To = #jid{} = jlib:string_to_jid(
|
||||
To = #jid{} = jid:from_string(
|
||||
xml:get_attr_s(<<"to">>, El#xmlel.attrs)),
|
||||
Stamp = xml:get_path_s(El, [{elem, <<"delay">>},
|
||||
{attr, <<"stamp">>}]),
|
||||
|
@ -191,7 +191,7 @@ handle_info({timeout, _TRef, {ping, JID}}, State) ->
|
||||
F = fun (Response) ->
|
||||
gen_server:cast(Pid, {iq_pong, JID, Response})
|
||||
end,
|
||||
From = jlib:make_jid(<<"">>, State#state.host, <<"">>),
|
||||
From = jid:make(<<"">>, State#state.host, <<"">>),
|
||||
ejabberd_local:route_iq(From, JID, IQ, F, State#state.ping_ack_timeout),
|
||||
Timers = add_timer(JID, State#state.ping_interval,
|
||||
State#state.timers),
|
||||
@ -227,7 +227,7 @@ user_send(Packet, _C2SState, JID, _From) ->
|
||||
%% Internal functions
|
||||
%%====================================================================
|
||||
add_timer(JID, Interval, Timers) ->
|
||||
LJID = jlib:jid_tolower(JID),
|
||||
LJID = jid:tolower(JID),
|
||||
NewTimers = case (?DICT):find(LJID, Timers) of
|
||||
{ok, OldTRef} ->
|
||||
cancel_timer(OldTRef), (?DICT):erase(LJID, Timers);
|
||||
@ -238,7 +238,7 @@ add_timer(JID, Interval, Timers) ->
|
||||
(?DICT):store(LJID, TRef, NewTimers).
|
||||
|
||||
del_timer(JID, Timers) ->
|
||||
LJID = jlib:jid_tolower(JID),
|
||||
LJID = jid:tolower(JID),
|
||||
case (?DICT):find(LJID, Timers) of
|
||||
{ok, TRef} ->
|
||||
cancel_timer(TRef), (?DICT):erase(LJID, Timers);
|
||||
|
@ -99,14 +99,14 @@ update(Server, JID, Dir) ->
|
||||
in ->
|
||||
?WARNING_MSG("User ~s is being flooded, ignoring received "
|
||||
"presence subscriptions",
|
||||
[jlib:jid_to_string(JID)]);
|
||||
[jid:to_string(JID)]);
|
||||
out ->
|
||||
IP = ejabberd_sm:get_user_ip(JID#jid.luser,
|
||||
JID#jid.lserver,
|
||||
JID#jid.lresource),
|
||||
?WARNING_MSG("Flooder detected: ~s, on IP: ~s ignoring "
|
||||
"sent presence subscriptions~n",
|
||||
[jlib:jid_to_string(JID),
|
||||
[jid:to_string(JID),
|
||||
jlib:ip_to_list(IP)])
|
||||
end,
|
||||
{stop, deny};
|
||||
|
@ -322,7 +322,7 @@ type_to_list(Type) ->
|
||||
|
||||
value_to_list(Type, Val) ->
|
||||
case Type of
|
||||
jid -> jlib:jid_to_string(Val);
|
||||
jid -> jid:to_string(Val);
|
||||
group -> Val;
|
||||
subscription ->
|
||||
case Val of
|
||||
@ -581,9 +581,9 @@ process_list_set(LUser, LServer, {value, Name}, Els) ->
|
||||
of
|
||||
{atomic, conflict} -> {error, ?ERR_CONFLICT};
|
||||
{atomic, ok} ->
|
||||
ejabberd_sm:route(jlib:make_jid(LUser, LServer,
|
||||
ejabberd_sm:route(jid:make(LUser, LServer,
|
||||
<<"">>),
|
||||
jlib:make_jid(LUser, LServer, <<"">>),
|
||||
jid:make(LUser, LServer, <<"">>),
|
||||
{broadcast, {privacy_list,
|
||||
#userlist{name = Name,
|
||||
list = []},
|
||||
@ -597,9 +597,9 @@ process_list_set(LUser, LServer, {value, Name}, Els) ->
|
||||
of
|
||||
{atomic, ok} ->
|
||||
NeedDb = is_list_needdb(List),
|
||||
ejabberd_sm:route(jlib:make_jid(LUser, LServer,
|
||||
ejabberd_sm:route(jid:make(LUser, LServer,
|
||||
<<"">>),
|
||||
jlib:make_jid(LUser, LServer, <<"">>),
|
||||
jid:make(LUser, LServer, <<"">>),
|
||||
{broadcast, {privacy_list,
|
||||
#userlist{name = Name,
|
||||
list = List,
|
||||
@ -645,11 +645,11 @@ parse_items([#xmlel{name = <<"item">>, attrs = Attrs,
|
||||
{{value, T}, {value, V}} ->
|
||||
case T of
|
||||
<<"jid">> ->
|
||||
case jlib:string_to_jid(V) of
|
||||
case jid:from_string(V) of
|
||||
error -> false;
|
||||
JID ->
|
||||
I1#listitem{type = jid,
|
||||
value = jlib:jid_tolower(JID)}
|
||||
value = jid:tolower(JID)}
|
||||
end;
|
||||
<<"group">> -> I1#listitem{type = group, value = V};
|
||||
<<"subscription">> ->
|
||||
@ -715,8 +715,8 @@ is_list_needdb(Items) ->
|
||||
Items).
|
||||
|
||||
get_user_list(Acc, User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
{Default, Items} = get_user_list(Acc, LUser, LServer,
|
||||
gen_mod:db_type(LServer, ?MODULE)),
|
||||
NeedDb = is_list_needdb(Items),
|
||||
@ -772,8 +772,8 @@ get_user_list(_, LUser, LServer, odbc) ->
|
||||
end.
|
||||
|
||||
get_user_lists(User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
get_user_lists(LUser, LServer, gen_mod:db_type(LServer, ?MODULE)).
|
||||
|
||||
get_user_lists(LUser, LServer, mnesia) ->
|
||||
@ -869,13 +869,13 @@ check_packet(_, User, Server,
|
||||
{_, _} -> other
|
||||
end,
|
||||
LJID = case Dir of
|
||||
in -> jlib:jid_tolower(From);
|
||||
out -> jlib:jid_tolower(To)
|
||||
in -> jid:tolower(From);
|
||||
out -> jid:tolower(To)
|
||||
end,
|
||||
{Subscription, Groups} = case NeedDb of
|
||||
true ->
|
||||
ejabberd_hooks:run_fold(roster_get_jid_info,
|
||||
jlib:nameprep(Server),
|
||||
jid:nameprep(Server),
|
||||
{none, []},
|
||||
[User, Server,
|
||||
LJID]);
|
||||
@ -944,8 +944,8 @@ is_type_match(Type, Value, JID, Subscription, Groups) ->
|
||||
end.
|
||||
|
||||
remove_user(User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
remove_user(LUser, LServer,
|
||||
gen_mod:db_type(LServer, ?MODULE)).
|
||||
|
||||
@ -971,9 +971,9 @@ raw_to_item([SType, SValue, SAction, SOrder, SMatchAll,
|
||||
{Type, Value} = case SType of
|
||||
<<"n">> -> {none, none};
|
||||
<<"j">> ->
|
||||
case jlib:string_to_jid(SValue) of
|
||||
case jid:from_string(SValue) of
|
||||
#jid{} = JID ->
|
||||
{jid, jlib:jid_tolower(JID)}
|
||||
{jid, jid:tolower(JID)}
|
||||
end;
|
||||
<<"g">> -> {group, SValue};
|
||||
<<"s">> ->
|
||||
@ -1013,7 +1013,7 @@ item_to_raw(#listitem{type = Type, value = Value,
|
||||
none -> {<<"n">>, <<"">>};
|
||||
jid ->
|
||||
{<<"j">>,
|
||||
ejabberd_odbc:escape(jlib:jid_to_string(Value))};
|
||||
ejabberd_odbc:escape(jid:to_string(Value))};
|
||||
group -> {<<"g">>, ejabberd_odbc:escape(Value)};
|
||||
subscription ->
|
||||
case Value of
|
||||
@ -1164,7 +1164,7 @@ update_table() ->
|
||||
end.
|
||||
|
||||
export(Server) ->
|
||||
case catch ejabberd_odbc:sql_query(jlib:nameprep(Server),
|
||||
case catch ejabberd_odbc:sql_query(jid:nameprep(Server),
|
||||
[<<"select id from privacy_list order by "
|
||||
"id desc limit 1;">>]) of
|
||||
{selected, [<<"id">>], [[I]]} ->
|
||||
|
@ -243,8 +243,8 @@ private_storage_schema() ->
|
||||
{record_info(fields, private_storage), #private_storage{}}.
|
||||
|
||||
remove_user(User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
remove_user(LUser, LServer,
|
||||
gen_mod:db_type(Server, ?MODULE)).
|
||||
|
||||
|
@ -179,15 +179,15 @@ process_iq(InitiatorJID,
|
||||
[{elem, <<"activate">>}]),
|
||||
SID = xml:get_tag_attr_s(<<"sid">>, SubEl),
|
||||
case catch
|
||||
jlib:string_to_jid(xml:get_tag_cdata(ActivateEl))
|
||||
jid:from_string(xml:get_tag_cdata(ActivateEl))
|
||||
of
|
||||
TargetJID
|
||||
when is_record(TargetJID, jid), SID /= <<"">>,
|
||||
byte_size(SID) =< 128, TargetJID /= InitiatorJID ->
|
||||
Target =
|
||||
jlib:jid_to_string(jlib:jid_tolower(TargetJID)),
|
||||
jid:to_string(jid:tolower(TargetJID)),
|
||||
Initiator =
|
||||
jlib:jid_to_string(jlib:jid_tolower(InitiatorJID)),
|
||||
jid:to_string(jid:tolower(InitiatorJID)),
|
||||
SHA1 = p1_sha:sha(<<SID/binary, Initiator/binary, Target/binary>>),
|
||||
case mod_proxy65_sm:activate_stream(SHA1, InitiatorJID,
|
||||
TargetJID, ServerHost)
|
||||
|
@ -120,8 +120,8 @@ activate({P1, J1}, {P2, J2}) ->
|
||||
{S1, S2} when is_port(S1), is_port(S2) ->
|
||||
P1 ! {activate, P2, S2, J1, J2},
|
||||
P2 ! {activate, P1, S1, J1, J2},
|
||||
JID1 = jlib:jid_to_string(J1),
|
||||
JID2 = jlib:jid_to_string(J2),
|
||||
JID1 = jid:to_string(J1),
|
||||
JID2 = jid:to_string(J2),
|
||||
?INFO_MSG("(~w:~w) Activated bytestream for ~s "
|
||||
"-> ~s",
|
||||
[P1, P2, JID1, JID2]),
|
||||
|
@ -393,8 +393,8 @@ send_loop(State) ->
|
||||
Host = State#state.host,
|
||||
ServerHost = State#state.server_host,
|
||||
DBType = State#state.db_type,
|
||||
LJID = jlib:jid_tolower(JID),
|
||||
BJID = jlib:jid_remove_resource(LJID),
|
||||
LJID = jid:tolower(JID),
|
||||
BJID = jid:remove_resource(LJID),
|
||||
lists:foreach(
|
||||
fun(PType) ->
|
||||
Subs = get_subscriptions_for_send_last(Host, PType, DBType, JID, LJID, BJID),
|
||||
@ -416,7 +416,7 @@ send_loop(State) ->
|
||||
fun({U, S, R}) when S == ServerHost ->
|
||||
case user_resources(U, S) of
|
||||
[] -> %% offline
|
||||
PeerJID = jlib:make_jid(U, S, R),
|
||||
PeerJID = jid:make(U, S, R),
|
||||
self() ! {presence, User, Server, [Resource], PeerJID};
|
||||
_ -> %% online
|
||||
% this is already handled by presence probe
|
||||
@ -437,7 +437,7 @@ send_loop(State) ->
|
||||
{presence, User, Server, Resources, JID} ->
|
||||
spawn(fun() ->
|
||||
Host = State#state.host,
|
||||
Owner = jlib:jid_remove_resource(jlib:jid_tolower(JID)),
|
||||
Owner = jid:remove_resource(jid:tolower(JID)),
|
||||
lists:foreach(fun(#pubsub_node{nodeid = {_, Node}, type = Type, id = Nidx, options = Options}) ->
|
||||
case match_option(Options, send_last_published_item, on_sub_and_presence) of
|
||||
true ->
|
||||
@ -533,7 +533,7 @@ disco_local_items(Acc, _From, _To, _Node, _Lang) -> Acc.
|
||||
disco_sm_identity(empty, From, To, Node, Lang) ->
|
||||
disco_sm_identity([], From, To, Node, Lang);
|
||||
disco_sm_identity(Acc, From, To, Node, _Lang) ->
|
||||
disco_identity(jlib:jid_tolower(jlib:jid_remove_resource(To)), Node, From)
|
||||
disco_identity(jid:tolower(jid:remove_resource(To)), Node, From)
|
||||
++ Acc.
|
||||
|
||||
disco_identity(_Host, <<>>, _From) ->
|
||||
@ -582,7 +582,7 @@ disco_sm_features(empty, From, To, Node, Lang) ->
|
||||
disco_sm_features({result, OtherFeatures} = _Acc, From, To, Node, _Lang) ->
|
||||
{result,
|
||||
OtherFeatures ++
|
||||
disco_features(jlib:jid_tolower(jlib:jid_remove_resource(To)), Node, From)};
|
||||
disco_features(jid:tolower(jid:remove_resource(To)), Node, From)};
|
||||
disco_sm_features(Acc, _From, _To, _Node, _Lang) -> Acc.
|
||||
|
||||
disco_features(Host, <<>>, _From) ->
|
||||
@ -617,7 +617,7 @@ disco_sm_items(empty, From, To, Node, Lang) ->
|
||||
disco_sm_items({result, []}, From, To, Node, Lang);
|
||||
disco_sm_items({result, OtherItems}, From, To, Node, _Lang) ->
|
||||
{result, lists:usort(OtherItems ++
|
||||
disco_items(jlib:jid_tolower(jlib:jid_remove_resource(To)), Node, From))};
|
||||
disco_items(jid:tolower(jid:remove_resource(To)), Node, From))};
|
||||
disco_sm_items(Acc, _From, _To, _Node, _Lang) -> Acc.
|
||||
|
||||
-spec(disco_items/3 ::
|
||||
@ -636,7 +636,7 @@ disco_items(Host, <<>>, From) ->
|
||||
{result, _} ->
|
||||
[#xmlel{name = <<"item">>,
|
||||
attrs = [{<<"node">>, (Node)},
|
||||
{<<"jid">>, jlib:jid_to_string(Host)}
|
||||
{<<"jid">>, jid:to_string(Host)}
|
||||
| case get_option(Options, title) of
|
||||
false -> [];
|
||||
[Title] -> [{<<"name">>, Title}]
|
||||
@ -660,7 +660,7 @@ disco_items(Host, Node, From) ->
|
||||
case get_allowed_items_call(Host, Nidx, From, Type, Options, Owners) of
|
||||
{result, Items} ->
|
||||
{result, [#xmlel{name = <<"item">>,
|
||||
attrs = [{<<"jid">>, jlib:jid_to_string(Host)},
|
||||
attrs = [{<<"jid">>, jid:to_string(Host)},
|
||||
{<<"name">>, ItemId}]}
|
||||
|| #pubsub_item{itemid = {ItemId, _}} <- Items]};
|
||||
_ ->
|
||||
@ -720,8 +720,8 @@ presence(ServerHost, Presence) ->
|
||||
%%
|
||||
|
||||
out_subscription(User, Server, JID, subscribed) ->
|
||||
Owner = jlib:make_jid(User, Server, <<>>),
|
||||
{PUser, PServer, PResource} = jlib:jid_tolower(JID),
|
||||
Owner = jid:make(User, Server, <<>>),
|
||||
{PUser, PServer, PResource} = jid:tolower(JID),
|
||||
PResources = case PResource of
|
||||
<<>> -> user_resources(PUser, PServer);
|
||||
_ -> [PResource]
|
||||
@ -732,7 +732,7 @@ out_subscription(_, _, _, _) ->
|
||||
true.
|
||||
|
||||
in_subscription(_, User, Server, Owner, unsubscribed, _) ->
|
||||
unsubscribe_user(jlib:make_jid(User, Server, <<>>), Owner),
|
||||
unsubscribe_user(jid:make(User, Server, <<>>), Owner),
|
||||
true;
|
||||
in_subscription(_, _, _, _, _, _) ->
|
||||
true.
|
||||
@ -749,7 +749,7 @@ unsubscribe_user(Entity, Owner) ->
|
||||
end, [], [Entity#jid.lserver, Owner#jid.lserver]))]
|
||||
end).
|
||||
unsubscribe_user(Host, Entity, Owner) ->
|
||||
BJID = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
||||
BJID = jid:tolower(jid:remove_resource(Owner)),
|
||||
lists:foreach(fun (PType) ->
|
||||
{result, Subs} = node_action(Host, PType,
|
||||
get_entity_subscriptions,
|
||||
@ -780,9 +780,9 @@ unsubscribe_user(Host, Entity, Owner) ->
|
||||
%%
|
||||
|
||||
remove_user(User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
Entity = jlib:make_jid(LUser, LServer, <<>>),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
Entity = jid:make(LUser, LServer, <<>>),
|
||||
Host = host(LServer),
|
||||
HomeTreeBase = <<"/home/", LServer/binary, "/", LUser/binary>>,
|
||||
spawn(fun () ->
|
||||
@ -1201,7 +1201,7 @@ iq_disco_items(Host, Item, From, RSM) ->
|
||||
).
|
||||
iq_sm(From, To, #iq{type = Type, sub_el = SubEl, xmlns = XMLNS, lang = Lang} = IQ) ->
|
||||
ServerHost = To#jid.lserver,
|
||||
LOwner = jlib:jid_tolower(jlib:jid_remove_resource(To)),
|
||||
LOwner = jid:tolower(jid:remove_resource(To)),
|
||||
Res = case XMLNS of
|
||||
?NS_PUBSUB ->
|
||||
iq_pubsub(LOwner, ServerHost, From, Type, SubEl, Lang);
|
||||
@ -1495,7 +1495,7 @@ get_pending_nodes(Host, Owner, Plugins) ->
|
||||
%% subscriptions on Host and Node.</p>
|
||||
send_pending_auth_events(Host, Node, Owner) ->
|
||||
?DEBUG("Sending pending auth events for ~s on ~s:~s",
|
||||
[jlib:jid_to_string(Owner), Host, Node]),
|
||||
[jid:to_string(Owner), Host, Node]),
|
||||
Action = fun (#pubsub_node{id = Nidx, type = Type}) ->
|
||||
case lists:member(<<"get-pending">>, plugin_features(Host, Type)) of
|
||||
true ->
|
||||
@ -1510,8 +1510,8 @@ send_pending_auth_events(Host, Node, Owner) ->
|
||||
case transaction(Host, Node, Action, sync_dirty) of
|
||||
{result, {N, Subs}} ->
|
||||
lists:foreach(fun
|
||||
({J, pending, _SubId}) -> send_authorization_request(N, jlib:make_jid(J));
|
||||
({J, pending}) -> send_authorization_request(N, jlib:make_jid(J));
|
||||
({J, pending, _SubId}) -> send_authorization_request(N, jid:make(J));
|
||||
({J, pending}) -> send_authorization_request(N, jid:make(J));
|
||||
(_) -> ok
|
||||
end,
|
||||
Subs),
|
||||
@ -1574,7 +1574,7 @@ send_authorization_request(#pubsub_node{nodeid = {Host, Node}, type = Type, id =
|
||||
[#xmlel{name = <<"value">>,
|
||||
attrs = [],
|
||||
children =
|
||||
[{xmlcdata, jlib:jid_to_string(Subscriber)}]}]},
|
||||
[{xmlcdata, jid:to_string(Subscriber)}]}]},
|
||||
#xmlel{name = <<"field">>,
|
||||
attrs =
|
||||
[{<<"var">>,
|
||||
@ -1590,7 +1590,7 @@ send_authorization_request(#pubsub_node{nodeid = {Host, Node}, type = Type, id =
|
||||
children =
|
||||
[{xmlcdata, <<"false">>}]}]}]}]},
|
||||
lists:foreach(fun (Owner) ->
|
||||
ejabberd_router:route(service_jid(Host), jlib:make_jid(Owner), Stanza)
|
||||
ejabberd_router:route(service_jid(Host), jid:make(Owner), Stanza)
|
||||
end,
|
||||
node_owners_action(Host, Type, Nidx, O)).
|
||||
|
||||
@ -1635,7 +1635,7 @@ send_authorization_approval(Host, JID, SNode, Subscription) ->
|
||||
[{<<"subscription">>, subscription_to_string(S)}]
|
||||
end,
|
||||
Stanza = event_stanza(<<"subscription">>,
|
||||
[{<<"jid">>, jlib:jid_to_string(JID)}
|
||||
[{<<"jid">>, jid:to_string(JID)}
|
||||
| nodeAttr(SNode)]
|
||||
++ SubAttrs),
|
||||
ejabberd_router:route(service_jid(Host), JID, Stanza).
|
||||
@ -1648,8 +1648,8 @@ handle_authorization_response(Host, From, To, Packet, XFields) ->
|
||||
{{value, {_, [Node]}},
|
||||
{value, {_, [SSubscriber]}},
|
||||
{value, {_, [SAllow]}}} ->
|
||||
FromLJID = jlib:jid_tolower(jlib:jid_remove_resource(From)),
|
||||
Subscriber = jlib:string_to_jid(SSubscriber),
|
||||
FromLJID = jid:tolower(jid:remove_resource(From)),
|
||||
Subscriber = jid:from_string(SSubscriber),
|
||||
Allow = case SAllow of
|
||||
<<"1">> -> true;
|
||||
<<"true">> -> true;
|
||||
@ -2045,7 +2045,7 @@ subscribe_node(Host, Node, From, JID, Configuration) ->
|
||||
[#xmlel{name = <<"pubsub">>,
|
||||
attrs = [{<<"xmlns">>, ?NS_PUBSUB}],
|
||||
children = [#xmlel{name = <<"subscription">>,
|
||||
attrs = [{<<"jid">>, jlib:jid_to_string(Subscriber)}
|
||||
attrs = [{<<"jid">>, jid:to_string(Subscriber)}
|
||||
| SubAttrs]}]}]
|
||||
end,
|
||||
case transaction(Host, Node, Action, sync_dirty) of
|
||||
@ -2526,13 +2526,13 @@ dispatch_items({FromU, FromS, FromR} = From, {ToU, ToS, ToR} = To, Node,
|
||||
Message = add_message_type(Stanza, NotificationType),
|
||||
ejabberd_c2s:send_filtered(C2SPid,
|
||||
{pep_message, <<Node/binary, "+notify">>},
|
||||
service_jid(From), jlib:make_jid(To),
|
||||
service_jid(From), jid:make(To),
|
||||
Message)
|
||||
end;
|
||||
dispatch_items(From, To, _Node, Options, Stanza) ->
|
||||
NotificationType = get_option(Options, notification_type, headline),
|
||||
Message = add_message_type(Stanza, NotificationType),
|
||||
ejabberd_router:route(service_jid(From), jlib:make_jid(To), Message).
|
||||
ejabberd_router:route(service_jid(From), jid:make(To), Message).
|
||||
|
||||
%% @doc <p>Return the list of affiliations as an XMPP response.</p>
|
||||
-spec(get_affiliations/4 ::
|
||||
@ -2620,7 +2620,7 @@ get_affiliations(Host, Node, JID) ->
|
||||
[];
|
||||
({AJID, Aff}) ->
|
||||
[#xmlel{name = <<"affiliation">>,
|
||||
attrs = [{<<"jid">>, jlib:jid_to_string(AJID)},
|
||||
attrs = [{<<"jid">>, jid:to_string(AJID)},
|
||||
{<<"affiliation">>, affiliation_to_string(Aff)}]}]
|
||||
end,
|
||||
Affs),
|
||||
@ -2644,17 +2644,17 @@ get_affiliations(Host, Node, JID) ->
|
||||
| {error, xmlel()}
|
||||
).
|
||||
set_affiliations(Host, Node, From, EntitiesEls) ->
|
||||
Owner = jlib:jid_tolower(jlib:jid_remove_resource(From)),
|
||||
Owner = jid:tolower(jid:remove_resource(From)),
|
||||
Entities = lists:foldl(fun
|
||||
(_, error) ->
|
||||
error;
|
||||
(El, Acc) ->
|
||||
case El of
|
||||
#xmlel{name = <<"affiliation">>, attrs = Attrs} ->
|
||||
JID = jlib:string_to_jid(xml:get_attr_s(<<"jid">>, Attrs)),
|
||||
JID = jid:from_string(xml:get_attr_s(<<"jid">>, Attrs)),
|
||||
Affiliation = string_to_affiliation(xml:get_attr_s(<<"affiliation">>, Attrs)),
|
||||
if (JID == error) or (Affiliation == false) -> error;
|
||||
true -> [{jlib:jid_tolower(JID), Affiliation} | Acc]
|
||||
true -> [{jid:tolower(JID), Affiliation} | Acc]
|
||||
end
|
||||
end
|
||||
end,
|
||||
@ -2667,7 +2667,7 @@ set_affiliations(Host, Node, From, EntitiesEls) ->
|
||||
Owners = node_owners_call(Host, Type, Nidx, O),
|
||||
case lists:member(Owner, Owners) of
|
||||
true ->
|
||||
OwnerJID = jlib:make_jid(Owner),
|
||||
OwnerJID = jid:make(Owner),
|
||||
FilteredEntities = case Owners of
|
||||
[Owner] -> [E || E <- Entities, element(1, E) =/= OwnerJID];
|
||||
_ -> Entities
|
||||
@ -2676,13 +2676,13 @@ set_affiliations(Host, Node, From, EntitiesEls) ->
|
||||
node_call(Host, Type, set_affiliation, [Nidx, JID, Affiliation]),
|
||||
case Affiliation of
|
||||
owner ->
|
||||
NewOwner = jlib:jid_tolower(jlib:jid_remove_resource(JID)),
|
||||
NewOwner = jid:tolower(jid:remove_resource(JID)),
|
||||
NewOwners = [NewOwner | Owners],
|
||||
tree_call(Host,
|
||||
set_node,
|
||||
[N#pubsub_node{owners = NewOwners}]);
|
||||
none ->
|
||||
OldOwner = jlib:jid_tolower(jlib:jid_remove_resource(JID)),
|
||||
OldOwner = jid:tolower(jid:remove_resource(JID)),
|
||||
case lists:member(OldOwner, Owners) of
|
||||
true ->
|
||||
NewOwners = Owners -- [OldOwner],
|
||||
@ -2756,7 +2756,7 @@ read_sub(Host, Node, Nidx, Subscriber, SubId, Lang) ->
|
||||
[XdataEl]
|
||||
end,
|
||||
OptionsEl = #xmlel{name = <<"options">>,
|
||||
attrs = [{<<"jid">>, jlib:jid_to_string(Subscriber)},
|
||||
attrs = [{<<"jid">>, jid:to_string(Subscriber)},
|
||||
{<<"subid">>, SubId}
|
||||
| nodeAttr(Node)],
|
||||
children = Children},
|
||||
@ -2832,7 +2832,7 @@ get_subscriptions(Host, Node, JID, Plugins) when is_list(Plugins) ->
|
||||
unsupported, <<"retrieve-subscriptions">>)},
|
||||
Acc};
|
||||
true ->
|
||||
Subscriber = jlib:jid_remove_resource(JID),
|
||||
Subscriber = jid:remove_resource(JID),
|
||||
{result, Subs} = node_action(Host, Type,
|
||||
get_entity_subscriptions,
|
||||
[Host, Subscriber]),
|
||||
@ -2866,14 +2866,14 @@ get_subscriptions(Host, Node, JID, Plugins) when is_list(Plugins) ->
|
||||
<<>> ->
|
||||
[#xmlel{name = <<"subscription">>,
|
||||
attrs =
|
||||
[{<<"jid">>, jlib:jid_to_string(SubJID)},
|
||||
[{<<"jid">>, jid:to_string(SubJID)},
|
||||
{<<"subid">>, SubId},
|
||||
{<<"subscription">>, subscription_to_string(Sub)}
|
||||
| nodeAttr(SubsNode)]}];
|
||||
SubsNode ->
|
||||
[#xmlel{name = <<"subscription">>,
|
||||
attrs =
|
||||
[{<<"jid">>, jlib:jid_to_string(SubJID)},
|
||||
[{<<"jid">>, jid:to_string(SubJID)},
|
||||
{<<"subid">>, SubId},
|
||||
{<<"subscription">>, subscription_to_string(Sub)}]}];
|
||||
_ ->
|
||||
@ -2884,13 +2884,13 @@ get_subscriptions(Host, Node, JID, Plugins) when is_list(Plugins) ->
|
||||
<<>> ->
|
||||
[#xmlel{name = <<"subscription">>,
|
||||
attrs =
|
||||
[{<<"jid">>, jlib:jid_to_string(SubJID)},
|
||||
[{<<"jid">>, jid:to_string(SubJID)},
|
||||
{<<"subscription">>, subscription_to_string(Sub)}
|
||||
| nodeAttr(SubsNode)]}];
|
||||
SubsNode ->
|
||||
[#xmlel{name = <<"subscription">>,
|
||||
attrs =
|
||||
[{<<"jid">>, jlib:jid_to_string(SubJID)},
|
||||
[{<<"jid">>, jid:to_string(SubJID)},
|
||||
{<<"subscription">>, subscription_to_string(Sub)}]}];
|
||||
_ ->
|
||||
[]
|
||||
@ -2930,12 +2930,12 @@ get_subscriptions(Host, Node, JID) ->
|
||||
({AJID, Sub}) ->
|
||||
[#xmlel{name = <<"subscription">>,
|
||||
attrs =
|
||||
[{<<"jid">>, jlib:jid_to_string(AJID)},
|
||||
[{<<"jid">>, jid:to_string(AJID)},
|
||||
{<<"subscription">>, subscription_to_string(Sub)}]}];
|
||||
({AJID, Sub, SubId}) ->
|
||||
[#xmlel{name = <<"subscription">>,
|
||||
attrs =
|
||||
[{<<"jid">>, jlib:jid_to_string(AJID)},
|
||||
[{<<"jid">>, jid:to_string(AJID)},
|
||||
{<<"subscription">>, subscription_to_string(Sub)},
|
||||
{<<"subid">>, SubId}]}]
|
||||
end,
|
||||
@ -2974,18 +2974,18 @@ get_subscriptions_for_send_last(_Host, _PType, _, _JID, _LJID, _BJID) ->
|
||||
[].
|
||||
|
||||
set_subscriptions(Host, Node, From, EntitiesEls) ->
|
||||
Owner = jlib:jid_tolower(jlib:jid_remove_resource(From)),
|
||||
Owner = jid:tolower(jid:remove_resource(From)),
|
||||
Entities = lists:foldl(fun
|
||||
(_, error) ->
|
||||
error;
|
||||
(El, Acc) ->
|
||||
case El of
|
||||
#xmlel{name = <<"subscription">>, attrs = Attrs} ->
|
||||
JID = jlib:string_to_jid(xml:get_attr_s(<<"jid">>, Attrs)),
|
||||
JID = jid:from_string(xml:get_attr_s(<<"jid">>, Attrs)),
|
||||
Sub = string_to_subscription(xml:get_attr_s(<<"subscription">>, Attrs)),
|
||||
SubId = xml:get_attr_s(<<"subid">>, Attrs),
|
||||
if (JID == error) or (Sub == false) -> error;
|
||||
true -> [{jlib:jid_tolower(JID), Sub, SubId} | Acc]
|
||||
true -> [{jid:tolower(JID), Sub, SubId} | Acc]
|
||||
end
|
||||
end
|
||||
end,
|
||||
@ -3001,10 +3001,10 @@ set_subscriptions(Host, Node, From, EntitiesEls) ->
|
||||
attrs = [{<<"xmlns">>, ?NS_PUBSUB}],
|
||||
children =
|
||||
[#xmlel{name = <<"subscription">>,
|
||||
attrs = [{<<"jid">>, jlib:jid_to_string(JID)},
|
||||
attrs = [{<<"jid">>, jid:to_string(JID)},
|
||||
{<<"subscription">>, subscription_to_string(Sub)}
|
||||
| nodeAttr(Node)]}]}]},
|
||||
ejabberd_router:route(service_jid(Host), jlib:make_jid(JID), Stanza)
|
||||
ejabberd_router:route(service_jid(Host), jid:make(JID), Stanza)
|
||||
end,
|
||||
Action = fun (#pubsub_node{type = Type, id = Nidx, owners = O}) ->
|
||||
Owners = node_owners_call(Host, Type, Nidx, O),
|
||||
@ -3076,7 +3076,7 @@ get_roster_info(OwnerUser, OwnerServer, {SubscriberUser, SubscriberServer, _}, A
|
||||
Groups),
|
||||
{PresenceSubscription, RosterGroup};
|
||||
get_roster_info(OwnerUser, OwnerServer, JID, AllowedGroups) ->
|
||||
get_roster_info(OwnerUser, OwnerServer, jlib:jid_tolower(JID), AllowedGroups).
|
||||
get_roster_info(OwnerUser, OwnerServer, jid:tolower(JID), AllowedGroups).
|
||||
|
||||
string_to_affiliation(<<"owner">>) -> owner;
|
||||
string_to_affiliation(<<"publisher">>) -> publisher;
|
||||
@ -3243,7 +3243,7 @@ items_event_stanza(Node, Items) ->
|
||||
DateTime = calendar:now_to_datetime(ModifNow),
|
||||
{T_string, Tz_string} = jlib:timestamp_to_iso(DateTime, utc),
|
||||
[#xmlel{name = <<"delay">>, attrs = [{<<"xmlns">>, ?NS_DELAY},
|
||||
{<<"from">>, jlib:jid_to_string(ModifUSR)},
|
||||
{<<"from">>, jid:to_string(ModifUSR)},
|
||||
{<<"stamp">>, <<T_string/binary, Tz_string/binary>>}],
|
||||
children = [{xmlcdata, <<>>}]}];
|
||||
_ ->
|
||||
@ -3445,7 +3445,7 @@ broadcast_stanza(Host, _Node, _Nidx, _Type, NodeOptions, SubsByDepth, NotifyType
|
||||
add_shim_headers(Stanza, subid_shim(SubIDs))
|
||||
end,
|
||||
lists:foreach(fun(To) ->
|
||||
ejabberd_router:route(From, jlib:make_jid(To), StanzaToSend)
|
||||
ejabberd_router:route(From, jid:make(To), StanzaToSend)
|
||||
end, LJIDs)
|
||||
end, SubIDsByJID).
|
||||
|
||||
@ -3462,9 +3462,9 @@ broadcast_stanza({LUser, LServer, LResource}, Publisher, Node, Nidx, Type, NodeO
|
||||
%% See XEP-0163 1.1 section 4.3.1
|
||||
ejabberd_c2s:broadcast(C2SPid,
|
||||
{pep_message, <<((Node))/binary, "+notify">>},
|
||||
_Sender = jlib:make_jid(LUser, LServer, <<"">>),
|
||||
_Sender = jid:make(LUser, LServer, <<"">>),
|
||||
_StanzaToSend = add_extended_headers(Stanza,
|
||||
_ReplyTo = extended_headers([jlib:jid_to_string(Publisher)])));
|
||||
_ReplyTo = extended_headers([jid:to_string(Publisher)])));
|
||||
_ ->
|
||||
?DEBUG("~p@~p has no session; can't deliver ~p to contacts", [LUser, LServer, BaseStanza])
|
||||
end;
|
||||
@ -3684,8 +3684,8 @@ max_items(Host, Options) ->
|
||||
-define(JLIST_CONFIG_FIELD(Label, Var, Opts),
|
||||
?LISTXFIELD(Label,
|
||||
<<"pubsub#", (atom_to_binary(Var, latin1))/binary>>,
|
||||
(jlib:jid_to_string(get_option(Options, Var))),
|
||||
[jlib:jid_to_string(O) || O <- Opts])).
|
||||
(jid:to_string(get_option(Options, Var))),
|
||||
[jid:to_string(O) || O <- Opts])).
|
||||
|
||||
-define(ALIST_CONFIG_FIELD(Label, Var, Opts),
|
||||
?LISTXFIELD(Label,
|
||||
@ -3910,7 +3910,7 @@ set_cached_item({_, ServerHost, _}, Nidx, ItemId, Publisher, Payload) ->
|
||||
set_cached_item(Host, Nidx, ItemId, Publisher, Payload) ->
|
||||
case is_last_item_cache_enabled(Host) of
|
||||
true -> mnesia:dirty_write({pubsub_last_item, Nidx, ItemId,
|
||||
{now(), jlib:jid_tolower(jlib:jid_remove_resource(Publisher))},
|
||||
{now(), jid:tolower(jid:remove_resource(Publisher))},
|
||||
Payload});
|
||||
_ -> ok
|
||||
end.
|
||||
@ -4206,11 +4206,11 @@ extended_error(#xmlel{name = Error, attrs = Attrs, children = SubEls}, Ext, ExtA
|
||||
children = lists:reverse([#xmlel{name = Ext, attrs = ExtAttrs} | SubEls])}.
|
||||
|
||||
string_to_ljid(JID) ->
|
||||
case jlib:string_to_jid(JID) of
|
||||
case jid:from_string(JID) of
|
||||
error ->
|
||||
{<<>>, <<>>, <<>>};
|
||||
J ->
|
||||
case jlib:jid_tolower(J) of
|
||||
case jid:tolower(J) of
|
||||
error -> {<<>>, <<>>, <<>>};
|
||||
J1 -> J1
|
||||
end
|
||||
@ -4279,7 +4279,7 @@ extended_headers(Jids) ->
|
||||
|| Jid <- Jids].
|
||||
|
||||
on_user_offline(_, JID, _) ->
|
||||
{User, Server, Resource} = jlib:jid_tolower(JID),
|
||||
{User, Server, Resource} = jid:tolower(JID),
|
||||
case user_resources(User, Server) of
|
||||
[] -> purge_offline({User, Server, Resource});
|
||||
_ -> true
|
||||
|
@ -89,19 +89,19 @@ unauthenticated_iq_register(_Acc, Server,
|
||||
{A, _Port} -> A;
|
||||
_ -> undefined
|
||||
end,
|
||||
ResIQ = process_iq(jlib:make_jid(<<"">>, <<"">>,
|
||||
ResIQ = process_iq(jid:make(<<"">>, <<"">>,
|
||||
<<"">>),
|
||||
jlib:make_jid(<<"">>, Server, <<"">>), IQ, Address),
|
||||
Res1 = jlib:replace_from_to(jlib:make_jid(<<"">>,
|
||||
jid:make(<<"">>, Server, <<"">>), IQ, Address),
|
||||
Res1 = jlib:replace_from_to(jid:make(<<"">>,
|
||||
Server, <<"">>),
|
||||
jlib:make_jid(<<"">>, <<"">>, <<"">>),
|
||||
jid:make(<<"">>, <<"">>, <<"">>),
|
||||
jlib:iq_to_xml(ResIQ)),
|
||||
jlib:remove_attr(<<"to">>, Res1);
|
||||
unauthenticated_iq_register(Acc, _Server, _IQ, _IP) ->
|
||||
Acc.
|
||||
|
||||
process_iq(From, To, IQ) ->
|
||||
process_iq(From, To, IQ, jlib:jid_tolower(From)).
|
||||
process_iq(From, To, IQ, jid:tolower(From)).
|
||||
|
||||
process_iq(From, To,
|
||||
#iq{type = Type, lang = Lang, sub_el = SubEl, id = ID} =
|
||||
@ -171,9 +171,9 @@ process_iq(From, To,
|
||||
resource = Resource} ->
|
||||
ResIQ = #iq{type = result, xmlns = ?NS_REGISTER,
|
||||
id = ID, sub_el = []},
|
||||
ejabberd_router:route(jlib:make_jid(User, Server,
|
||||
ejabberd_router:route(jid:make(User, Server,
|
||||
Resource),
|
||||
jlib:make_jid(User, Server,
|
||||
jid:make(User, Server,
|
||||
Resource),
|
||||
jlib:iq_to_xml(ResIQ)),
|
||||
ejabberd_auth:remove_user(User, Server),
|
||||
@ -373,10 +373,10 @@ try_set_password(User, Server, Password, IQ, SubEl,
|
||||
end.
|
||||
|
||||
try_register(User, Server, Password, SourceRaw, Lang) ->
|
||||
case jlib:is_nodename(User) of
|
||||
case jid:is_nodename(User) of
|
||||
false -> {error, ?ERR_BAD_REQUEST};
|
||||
_ ->
|
||||
JID = jlib:make_jid(User, Server, <<"">>),
|
||||
JID = jid:make(User, Server, <<"">>),
|
||||
Access = gen_mod:get_module_opt(Server, ?MODULE, access,
|
||||
fun(A) when is_atom(A) -> A end,
|
||||
all),
|
||||
@ -441,7 +441,7 @@ send_welcome_message(JID) ->
|
||||
of
|
||||
{<<"">>, <<"">>} -> ok;
|
||||
{Subj, Body} ->
|
||||
ejabberd_router:route(jlib:make_jid(<<"">>, Host,
|
||||
ejabberd_router:route(jid:make(<<"">>, Host,
|
||||
<<"">>),
|
||||
JID,
|
||||
#xmlel{name = <<"message">>,
|
||||
@ -463,7 +463,7 @@ send_registration_notifications(Mod, UJID, Source) ->
|
||||
case gen_mod:get_module_opt(
|
||||
Host, Mod, registration_watchers,
|
||||
fun(Ss) ->
|
||||
[#jid{} = jlib:string_to_jid(iolist_to_binary(S))
|
||||
[#jid{} = jid:from_string(iolist_to_binary(S))
|
||||
|| S <- Ss]
|
||||
end, []) of
|
||||
[] -> ok;
|
||||
@ -472,13 +472,13 @@ send_registration_notifications(Mod, UJID, Source) ->
|
||||
iolist_to_binary(io_lib:format("[~s] The account ~s was registered from "
|
||||
"IP address ~s on node ~w using ~p.",
|
||||
[get_time_string(),
|
||||
jlib:jid_to_string(UJID),
|
||||
jid:to_string(UJID),
|
||||
ip_to_string(Source), node(),
|
||||
Mod])),
|
||||
lists:foreach(
|
||||
fun(JID) ->
|
||||
ejabberd_router:route(
|
||||
jlib:make_jid(<<"">>, Host, <<"">>),
|
||||
jid:make(<<"">>, Host, <<"">>),
|
||||
JID,
|
||||
#xmlel{name = <<"message">>,
|
||||
attrs = [{<<"type">>, <<"chat">>}],
|
||||
@ -610,7 +610,7 @@ process_xdata_submit(El) ->
|
||||
end.
|
||||
|
||||
is_strong_password(Server, Password) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
case gen_mod:get_module_opt(LServer, ?MODULE, password_strength,
|
||||
fun(N) when is_number(N), N>=0 -> N end,
|
||||
0) of
|
||||
@ -673,7 +673,7 @@ transform_module_options(Opts) ->
|
||||
%%%
|
||||
|
||||
may_remove_resource({_, _, _} = From) ->
|
||||
jlib:jid_remove_resource(From);
|
||||
jid:remove_resource(From);
|
||||
may_remove_resource(From) -> From.
|
||||
|
||||
get_ip_access(Host) ->
|
||||
@ -706,7 +706,7 @@ mod_opt_type(password_strength) ->
|
||||
fun (N) when is_number(N), N >= 0 -> N end;
|
||||
mod_opt_type(registration_watchers) ->
|
||||
fun (Ss) ->
|
||||
[#jid{} = jlib:string_to_jid(iolist_to_binary(S))
|
||||
[#jid{} = jid:from_string(iolist_to_binary(S))
|
||||
|| S <- Ss]
|
||||
end;
|
||||
mod_opt_type(welcome_message) ->
|
||||
|
@ -100,7 +100,7 @@ process([<<"new">>],
|
||||
lang = Lang, host = _HTTPHost}) ->
|
||||
case form_new_post(Q) of
|
||||
{success, ok, {Username, Host, _Password}} ->
|
||||
Jid = jlib:make_jid(Username, Host, <<"">>),
|
||||
Jid = jid:make(Username, Host, <<"">>),
|
||||
mod_register:send_registration_notifications(?MODULE, Jid, Ip),
|
||||
Text = (?T(<<"Your Jabber account was successfully "
|
||||
"created.">>)),
|
||||
@ -491,7 +491,7 @@ register_account(Username, Host, Password) ->
|
||||
Access = gen_mod:get_module_opt(Host, mod_register, access,
|
||||
fun(A) when is_atom(A) -> A end,
|
||||
all),
|
||||
case jlib:make_jid(Username, Host, <<"">>) of
|
||||
case jid:make(Username, Host, <<"">>) of
|
||||
error -> {error, invalid_jid};
|
||||
JID ->
|
||||
case acl:match_rule(Host, Access, JID) of
|
||||
|
@ -396,7 +396,7 @@ get_roster(LUser, LServer, odbc) ->
|
||||
error -> [];
|
||||
R ->
|
||||
SJID =
|
||||
jlib:jid_to_string(R#roster.jid),
|
||||
jid:to_string(R#roster.jid),
|
||||
Groups = case dict:find(SJID,
|
||||
GroupsDict)
|
||||
of
|
||||
@ -413,7 +413,7 @@ get_roster(LUser, LServer, odbc) ->
|
||||
|
||||
item_to_xml(Item) ->
|
||||
Attrs1 = [{<<"jid">>,
|
||||
jlib:jid_to_string(Item#roster.jid)}],
|
||||
jid:to_string(Item#roster.jid)}],
|
||||
Attrs2 = case Item#roster.name of
|
||||
<<"">> -> Attrs1;
|
||||
Name -> [{<<"name">>, Name} | Attrs1]
|
||||
@ -454,7 +454,7 @@ get_roster_by_jid_t(LUser, LServer, LJID, mnesia) ->
|
||||
end;
|
||||
get_roster_by_jid_t(LUser, LServer, LJID, odbc) ->
|
||||
Username = ejabberd_odbc:escape(LUser),
|
||||
SJID = ejabberd_odbc:escape(jlib:jid_to_string(LJID)),
|
||||
SJID = ejabberd_odbc:escape(jid:to_string(LJID)),
|
||||
{selected,
|
||||
[<<"username">>, <<"jid">>, <<"nick">>,
|
||||
<<"subscription">>, <<"ask">>, <<"askmessage">>,
|
||||
@ -509,14 +509,14 @@ process_iq_set(From, To, #iq{sub_el = SubEl, id = Id} = IQ) ->
|
||||
|
||||
process_item_set(From, To,
|
||||
#xmlel{attrs = Attrs, children = Els}, Managed) ->
|
||||
JID1 = jlib:string_to_jid(xml:get_attr_s(<<"jid">>,
|
||||
JID1 = jid:from_string(xml:get_attr_s(<<"jid">>,
|
||||
Attrs)),
|
||||
#jid{user = User, luser = LUser, lserver = LServer} =
|
||||
From,
|
||||
case JID1 of
|
||||
error -> ok;
|
||||
_ ->
|
||||
LJID = jlib:jid_tolower(JID1),
|
||||
LJID = jid:tolower(JID1),
|
||||
F = fun () ->
|
||||
Item = get_roster_by_jid_t(LUser, LServer, LJID),
|
||||
Item1 = process_item_attrs_managed(Item, Attrs, Managed),
|
||||
@ -552,7 +552,7 @@ process_item_set(_From, _To, _, _Managed) -> ok.
|
||||
process_item_attrs(Item, [{Attr, Val} | Attrs]) ->
|
||||
case Attr of
|
||||
<<"jid">> ->
|
||||
case jlib:string_to_jid(Val) of
|
||||
case jid:from_string(Val) of
|
||||
error -> process_item_attrs(Item, Attrs);
|
||||
JID1 ->
|
||||
JID = {JID1#jid.luser, JID1#jid.lserver,
|
||||
@ -595,8 +595,8 @@ process_item_els(Item, [{xmlcdata, _} | Els]) ->
|
||||
process_item_els(Item, []) -> Item.
|
||||
|
||||
push_item(User, Server, From, Item) ->
|
||||
ejabberd_sm:route(jlib:make_jid(<<"">>, <<"">>, <<"">>),
|
||||
jlib:make_jid(User, Server, <<"">>),
|
||||
ejabberd_sm:route(jid:make(<<"">>, <<"">>, <<"">>),
|
||||
jid:make(User, Server, <<"">>),
|
||||
{broadcast, {item, Item#roster.jid,
|
||||
Item#roster.subscription}}),
|
||||
case roster_versioning_enabled(Server) of
|
||||
@ -629,7 +629,7 @@ push_item(User, Server, Resource, From, Item,
|
||||
attrs = [{<<"xmlns">>, ?NS_ROSTER} | ExtraAttrs],
|
||||
children = [item_to_xml(Item)]}]},
|
||||
ejabberd_router:route(From,
|
||||
jlib:make_jid(User, Server, Resource),
|
||||
jid:make(User, Server, Resource),
|
||||
jlib:iq_to_xml(ResIQ)).
|
||||
|
||||
push_item_version(Server, User, From, Item,
|
||||
@ -641,8 +641,8 @@ push_item_version(Server, User, From, Item,
|
||||
ejabberd_sm:get_user_resources(User, Server)).
|
||||
|
||||
get_subscription_lists(Acc, User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
DBType = gen_mod:db_type(LServer, ?MODULE),
|
||||
Items = get_subscription_lists(Acc, LUser, LServer,
|
||||
DBType),
|
||||
@ -707,7 +707,7 @@ roster_subscribe_t(_LUser, _LServer, _LJID, Item,
|
||||
roster_subscribe_t(LUser, LServer, LJID, Item, odbc) ->
|
||||
ItemVals = record_to_string(Item),
|
||||
Username = ejabberd_odbc:escape(LUser),
|
||||
SJID = ejabberd_odbc:escape(jlib:jid_to_string(LJID)),
|
||||
SJID = ejabberd_odbc:escape(jid:to_string(LJID)),
|
||||
odbc_queries:roster_subscribe(LServer, Username, SJID,
|
||||
ItemVals);
|
||||
roster_subscribe_t(LUser, LServer, _LJID, Item, riak) ->
|
||||
@ -744,7 +744,7 @@ get_roster_by_jid_with_groups_t(LUser, LServer, LJID,
|
||||
get_roster_by_jid_with_groups_t(LUser, LServer, LJID,
|
||||
odbc) ->
|
||||
Username = ejabberd_odbc:escape(LUser),
|
||||
SJID = ejabberd_odbc:escape(jlib:jid_to_string(LJID)),
|
||||
SJID = ejabberd_odbc:escape(jid:to_string(LJID)),
|
||||
case odbc_queries:get_roster_by_jid(LServer, Username,
|
||||
SJID)
|
||||
of
|
||||
@ -783,9 +783,9 @@ get_roster_by_jid_with_groups_t(LUser, LServer, LJID, riak) ->
|
||||
|
||||
process_subscription(Direction, User, Server, JID1,
|
||||
Type, Reason) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LJID = jlib:jid_tolower(JID1),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
LJID = jid:tolower(JID1),
|
||||
F = fun () ->
|
||||
Item = get_roster_by_jid_with_groups_t(LUser, LServer,
|
||||
LJID),
|
||||
@ -836,7 +836,7 @@ process_subscription(Direction, User, Server, JID1,
|
||||
subscribed -> <<"subscribed">>;
|
||||
unsubscribed -> <<"unsubscribed">>
|
||||
end,
|
||||
ejabberd_router:route(jlib:make_jid(User, Server,
|
||||
ejabberd_router:route(jid:make(User, Server,
|
||||
<<"">>),
|
||||
JID1,
|
||||
#xmlel{name = <<"presence">>,
|
||||
@ -850,7 +850,7 @@ process_subscription(Direction, User, Server, JID1,
|
||||
ok;
|
||||
true ->
|
||||
push_item(User, Server,
|
||||
jlib:make_jid(User, Server, <<"">>), Item)
|
||||
jid:make(User, Server, <<"">>), Item)
|
||||
end,
|
||||
true;
|
||||
none -> false
|
||||
@ -974,8 +974,8 @@ in_auto_reply(both, none, unsubscribe) -> unsubscribed;
|
||||
in_auto_reply(_, _, _) -> none.
|
||||
|
||||
remove_user(User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
send_unsubscription_to_rosteritems(LUser, LServer),
|
||||
remove_user(LUser, LServer,
|
||||
gen_mod:db_type(LServer, ?MODULE)).
|
||||
@ -999,7 +999,7 @@ remove_user(LUser, LServer, riak) ->
|
||||
%% Both or To, send a "unsubscribe" presence stanza.
|
||||
send_unsubscription_to_rosteritems(LUser, LServer) ->
|
||||
RosterItems = get_user_roster([], {LUser, LServer}),
|
||||
From = jlib:make_jid({LUser, LServer, <<"">>}),
|
||||
From = jid:make({LUser, LServer, <<"">>}),
|
||||
lists:foreach(fun (RosterItem) ->
|
||||
send_unsubscribing_presence(From, RosterItem)
|
||||
end,
|
||||
@ -1017,14 +1017,14 @@ send_unsubscribing_presence(From, Item) ->
|
||||
_ -> false
|
||||
end,
|
||||
if IsTo ->
|
||||
send_presence_type(jlib:jid_remove_resource(From),
|
||||
jlib:make_jid(Item#roster.jid),
|
||||
send_presence_type(jid:remove_resource(From),
|
||||
jid:make(Item#roster.jid),
|
||||
<<"unsubscribe">>);
|
||||
true -> ok
|
||||
end,
|
||||
if IsFrom ->
|
||||
send_presence_type(jlib:jid_remove_resource(From),
|
||||
jlib:make_jid(Item#roster.jid),
|
||||
send_presence_type(jid:remove_resource(From),
|
||||
jid:make(Item#roster.jid),
|
||||
<<"unsubscribed">>);
|
||||
true -> ok
|
||||
end,
|
||||
@ -1039,8 +1039,8 @@ send_presence_type(From, To, Type) ->
|
||||
|
||||
set_items(User, Server, SubEl) ->
|
||||
#xmlel{children = Els} = SubEl,
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
F = fun () ->
|
||||
lists:foreach(fun (El) ->
|
||||
process_item_set_t(LUser, LServer, El)
|
||||
@ -1058,7 +1058,7 @@ update_roster_t(_LUser, _LServer, _LJID, Item,
|
||||
mnesia:write(Item);
|
||||
update_roster_t(LUser, LServer, LJID, Item, odbc) ->
|
||||
Username = ejabberd_odbc:escape(LUser),
|
||||
SJID = ejabberd_odbc:escape(jlib:jid_to_string(LJID)),
|
||||
SJID = ejabberd_odbc:escape(jid:to_string(LJID)),
|
||||
ItemVals = record_to_string(Item),
|
||||
ItemGroups = groups_to_string(Item),
|
||||
odbc_queries:update_roster(LServer, Username, SJID, ItemVals,
|
||||
@ -1075,14 +1075,14 @@ del_roster_t(LUser, LServer, LJID, mnesia) ->
|
||||
mnesia:delete({roster, {LUser, LServer, LJID}});
|
||||
del_roster_t(LUser, LServer, LJID, odbc) ->
|
||||
Username = ejabberd_odbc:escape(LUser),
|
||||
SJID = ejabberd_odbc:escape(jlib:jid_to_string(LJID)),
|
||||
SJID = ejabberd_odbc:escape(jid:to_string(LJID)),
|
||||
odbc_queries:del_roster(LServer, Username, SJID);
|
||||
del_roster_t(LUser, LServer, LJID, riak) ->
|
||||
ejabberd_riak:delete(roster, {LUser, LServer, LJID}).
|
||||
|
||||
process_item_set_t(LUser, LServer,
|
||||
#xmlel{attrs = Attrs, children = Els}) ->
|
||||
JID1 = jlib:string_to_jid(xml:get_attr_s(<<"jid">>,
|
||||
JID1 = jid:from_string(xml:get_attr_s(<<"jid">>,
|
||||
Attrs)),
|
||||
case JID1 of
|
||||
error -> ok;
|
||||
@ -1105,7 +1105,7 @@ process_item_set_t(_LUser, _LServer, _) -> ok.
|
||||
process_item_attrs_ws(Item, [{Attr, Val} | Attrs]) ->
|
||||
case Attr of
|
||||
<<"jid">> ->
|
||||
case jlib:string_to_jid(Val) of
|
||||
case jid:from_string(Val) of
|
||||
error -> process_item_attrs_ws(Item, Attrs);
|
||||
JID1 ->
|
||||
JID = {JID1#jid.luser, JID1#jid.lserver,
|
||||
@ -1140,13 +1140,13 @@ process_item_attrs_ws(Item, [{Attr, Val} | Attrs]) ->
|
||||
process_item_attrs_ws(Item, []) -> Item.
|
||||
|
||||
get_in_pending_subscriptions(Ls, User, Server) ->
|
||||
LServer = jlib:nameprep(Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
get_in_pending_subscriptions(Ls, User, Server,
|
||||
gen_mod:db_type(LServer, ?MODULE)).
|
||||
|
||||
get_in_pending_subscriptions(Ls, User, Server, DBType)
|
||||
when DBType == mnesia; DBType == riak ->
|
||||
JID = jlib:make_jid(User, Server, <<"">>),
|
||||
JID = jid:make(User, Server, <<"">>),
|
||||
Result = get_roster(JID#jid.luser, JID#jid.lserver, DBType),
|
||||
Ls ++ lists:map(fun (R) ->
|
||||
Message = R#roster.askmessage,
|
||||
@ -1156,8 +1156,8 @@ get_in_pending_subscriptions(Ls, User, Server, DBType)
|
||||
#xmlel{name = <<"presence">>,
|
||||
attrs =
|
||||
[{<<"from">>,
|
||||
jlib:jid_to_string(R#roster.jid)},
|
||||
{<<"to">>, jlib:jid_to_string(JID)},
|
||||
jid:to_string(R#roster.jid)},
|
||||
{<<"to">>, jid:to_string(JID)},
|
||||
{<<"type">>, <<"subscribe">>}],
|
||||
children =
|
||||
[#xmlel{name = <<"status">>,
|
||||
@ -1174,7 +1174,7 @@ get_in_pending_subscriptions(Ls, User, Server, DBType)
|
||||
end,
|
||||
Result));
|
||||
get_in_pending_subscriptions(Ls, User, Server, odbc) ->
|
||||
JID = jlib:make_jid(User, Server, <<"">>),
|
||||
JID = jid:make(User, Server, <<"">>),
|
||||
LUser = JID#jid.luser,
|
||||
LServer = JID#jid.lserver,
|
||||
Username = ejabberd_odbc:escape(LUser),
|
||||
@ -1191,8 +1191,8 @@ get_in_pending_subscriptions(Ls, User, Server, odbc) ->
|
||||
#xmlel{name = <<"presence">>,
|
||||
attrs =
|
||||
[{<<"from">>,
|
||||
jlib:jid_to_string(R#roster.jid)},
|
||||
{<<"to">>, jlib:jid_to_string(JID)},
|
||||
jid:to_string(R#roster.jid)},
|
||||
{<<"to">>, jid:to_string(JID)},
|
||||
{<<"type">>, <<"subscribe">>}],
|
||||
children =
|
||||
[#xmlel{name = <<"status">>,
|
||||
@ -1219,8 +1219,8 @@ get_in_pending_subscriptions(Ls, User, Server, odbc) ->
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
read_subscription_and_groups(User, Server, LJID) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
read_subscription_and_groups(LUser, LServer, LJID,
|
||||
gen_mod:db_type(LServer, ?MODULE)).
|
||||
|
||||
@ -1237,7 +1237,7 @@ read_subscription_and_groups(LUser, LServer, LJID,
|
||||
read_subscription_and_groups(LUser, LServer, LJID,
|
||||
odbc) ->
|
||||
Username = ejabberd_odbc:escape(LUser),
|
||||
SJID = ejabberd_odbc:escape(jlib:jid_to_string(LJID)),
|
||||
SJID = ejabberd_odbc:escape(jid:to_string(LJID)),
|
||||
case catch odbc_queries:get_subscription(LServer,
|
||||
Username, SJID)
|
||||
of
|
||||
@ -1270,11 +1270,11 @@ read_subscription_and_groups(LUser, LServer, LJID,
|
||||
end.
|
||||
|
||||
get_jid_info(_, User, Server, JID) ->
|
||||
LJID = jlib:jid_tolower(JID),
|
||||
LJID = jid:tolower(JID),
|
||||
case read_subscription_and_groups(User, Server, LJID) of
|
||||
{Subscription, Groups} -> {Subscription, Groups};
|
||||
error ->
|
||||
LRJID = jlib:jid_tolower(jlib:jid_remove_resource(JID)),
|
||||
LRJID = jid:tolower(jid:remove_resource(JID)),
|
||||
if LRJID == LJID -> {none, []};
|
||||
true ->
|
||||
case read_subscription_and_groups(User, Server, LRJID)
|
||||
@ -1290,10 +1290,10 @@ get_jid_info(_, User, Server, JID) ->
|
||||
raw_to_record(LServer,
|
||||
[User, SJID, Nick, SSubscription, SAsk, SAskMessage,
|
||||
_SServer, _SSubscribe, _SType]) ->
|
||||
case jlib:string_to_jid(SJID) of
|
||||
case jid:from_string(SJID) of
|
||||
error -> error;
|
||||
JID ->
|
||||
LJID = jlib:jid_tolower(JID),
|
||||
LJID = jid:tolower(JID),
|
||||
Subscription = case SSubscription of
|
||||
<<"B">> -> both;
|
||||
<<"T">> -> to;
|
||||
@ -1319,7 +1319,7 @@ record_to_string(#roster{us = {User, _Server},
|
||||
ask = Ask, askmessage = AskMessage}) ->
|
||||
Username = ejabberd_odbc:escape(User),
|
||||
SJID =
|
||||
ejabberd_odbc:escape(jlib:jid_to_string(jlib:jid_tolower(JID))),
|
||||
ejabberd_odbc:escape(jid:to_string(jid:tolower(JID))),
|
||||
Nick = ejabberd_odbc:escape(Name),
|
||||
SSubscription = case Subscription of
|
||||
both -> <<"B">>;
|
||||
@ -1343,7 +1343,7 @@ groups_to_string(#roster{us = {User, _Server},
|
||||
jid = JID, groups = Groups}) ->
|
||||
Username = ejabberd_odbc:escape(User),
|
||||
SJID =
|
||||
ejabberd_odbc:escape(jlib:jid_to_string(jlib:jid_tolower(JID))),
|
||||
ejabberd_odbc:escape(jid:to_string(jid:tolower(JID))),
|
||||
lists:foldl(fun (<<"">>, Acc) -> Acc;
|
||||
(Group, Acc) ->
|
||||
G = ejabberd_odbc:escape(Group),
|
||||
@ -1417,8 +1417,8 @@ webadmin_page(_, Host,
|
||||
webadmin_page(Acc, _, _) -> Acc.
|
||||
|
||||
user_roster(User, Server, Query, Lang) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
US = {LUser, LServer},
|
||||
Items1 = get_roster(LUser, LServer),
|
||||
Res = user_roster_parse_query(User, Server, Items1,
|
||||
@ -1504,7 +1504,7 @@ user_roster(User, Server, Query, Lang) ->
|
||||
<<"Add Jabber ID">>)]))].
|
||||
|
||||
build_contact_jid_td(RosterJID) ->
|
||||
ContactJID = jlib:make_jid(RosterJID),
|
||||
ContactJID = jid:make(RosterJID),
|
||||
JIDURI = case {ContactJID#jid.luser,
|
||||
ContactJID#jid.lserver}
|
||||
of
|
||||
@ -1520,10 +1520,10 @@ build_contact_jid_td(RosterJID) ->
|
||||
case JIDURI of
|
||||
<<>> ->
|
||||
?XAC(<<"td">>, [{<<"class">>, <<"valign">>}],
|
||||
(jlib:jid_to_string(RosterJID)));
|
||||
(jid:to_string(RosterJID)));
|
||||
URI when is_binary(URI) ->
|
||||
?XAE(<<"td">>, [{<<"class">>, <<"valign">>}],
|
||||
[?AC(JIDURI, (jlib:jid_to_string(RosterJID)))])
|
||||
[?AC(JIDURI, (jid:to_string(RosterJID)))])
|
||||
end.
|
||||
|
||||
user_roster_parse_query(User, Server, Items, Query) ->
|
||||
@ -1531,7 +1531,7 @@ user_roster_parse_query(User, Server, Items, Query) ->
|
||||
{value, _} ->
|
||||
case lists:keysearch(<<"newjid">>, 1, Query) of
|
||||
{value, {_, SJID}} ->
|
||||
case jlib:string_to_jid(SJID) of
|
||||
case jid:from_string(SJID) of
|
||||
JID when is_record(JID, jid) ->
|
||||
user_roster_subscribe_jid(User, Server, JID), ok;
|
||||
error -> error
|
||||
@ -1550,7 +1550,7 @@ user_roster_parse_query(User, Server, Items, Query) ->
|
||||
|
||||
user_roster_subscribe_jid(User, Server, JID) ->
|
||||
out_subscription(User, Server, JID, subscribe),
|
||||
UJID = jlib:make_jid(User, Server, <<"">>),
|
||||
UJID = jid:make(User, Server, <<"">>),
|
||||
ejabberd_router:route(UJID, JID,
|
||||
#xmlel{name = <<"presence">>,
|
||||
attrs = [{<<"type">>, <<"subscribe">>}],
|
||||
@ -1565,10 +1565,10 @@ user_roster_item_parse_query(User, Server, Items,
|
||||
1, Query)
|
||||
of
|
||||
{value, _} ->
|
||||
JID1 = jlib:make_jid(JID),
|
||||
JID1 = jid:make(JID),
|
||||
out_subscription(User, Server, JID1,
|
||||
subscribed),
|
||||
UJID = jlib:make_jid(User, Server, <<"">>),
|
||||
UJID = jid:make(User, Server, <<"">>),
|
||||
ejabberd_router:route(UJID, JID1,
|
||||
#xmlel{name =
|
||||
<<"presence">>,
|
||||
@ -1583,7 +1583,7 @@ user_roster_item_parse_query(User, Server, Items,
|
||||
1, Query)
|
||||
of
|
||||
{value, _} ->
|
||||
UJID = jlib:make_jid(User, Server,
|
||||
UJID = jid:make(User, Server,
|
||||
<<"">>),
|
||||
process_iq_set(UJID, UJID,
|
||||
#iq{type = set,
|
||||
@ -1600,7 +1600,7 @@ user_roster_item_parse_query(User, Server, Items,
|
||||
attrs
|
||||
=
|
||||
[{<<"jid">>,
|
||||
jlib:jid_to_string(JID)},
|
||||
jid:to_string(JID)},
|
||||
{<<"subscription">>,
|
||||
<<"remove">>}],
|
||||
children
|
||||
@ -1615,7 +1615,7 @@ user_roster_item_parse_query(User, Server, Items,
|
||||
nothing.
|
||||
|
||||
us_to_list({User, Server}) ->
|
||||
jlib:jid_to_string({User, Server, <<"">>}).
|
||||
jid:to_string({User, Server, <<"">>}).
|
||||
|
||||
webadmin_user(Acc, _User, _Server, Lang) ->
|
||||
Acc ++
|
||||
@ -1676,7 +1676,7 @@ is_item_of_domain(_MatchDomain, {xmlcdata, _}) ->
|
||||
false.
|
||||
|
||||
is_jid_of_domain(MatchDomain, {<<"jid">>, JIDString}) ->
|
||||
case jlib:string_to_jid(JIDString) of
|
||||
case jid:from_string(JIDString) of
|
||||
JID when JID#jid.lserver == MatchDomain -> true;
|
||||
_ -> false
|
||||
end;
|
||||
@ -1716,7 +1716,7 @@ export(_Server) ->
|
||||
fun(Host, #roster{usj = {LUser, LServer, LJID}} = R)
|
||||
when LServer == Host ->
|
||||
Username = ejabberd_odbc:escape(LUser),
|
||||
SJID = ejabberd_odbc:escape(jlib:jid_to_string(LJID)),
|
||||
SJID = ejabberd_odbc:escape(jid:to_string(LJID)),
|
||||
ItemVals = record_to_string(R),
|
||||
ItemGroups = groups_to_string(R),
|
||||
odbc_queries:update_roster_sql(Username, SJID,
|
||||
|
@ -67,7 +67,7 @@ log_packet(From, To,
|
||||
lists:map(
|
||||
fun(S) ->
|
||||
B = iolist_to_binary(S),
|
||||
N = jlib:nameprep(B),
|
||||
N = jid:nameprep(B),
|
||||
if N /= error ->
|
||||
N
|
||||
end
|
||||
@ -77,8 +77,8 @@ log_packet(From, To,
|
||||
resource = <<"">>, luser = <<"">>, lserver = Host,
|
||||
lresource = <<"">>},
|
||||
NewAttrs =
|
||||
jlib:replace_from_to_attrs(jlib:jid_to_string(From),
|
||||
jlib:jid_to_string(To), Attrs),
|
||||
jlib:replace_from_to_attrs(jid:to_string(From),
|
||||
jid:to_string(To), Attrs),
|
||||
FixedPacket = #xmlel{name = Name, attrs = NewAttrs,
|
||||
children = Els},
|
||||
lists:foreach(fun (Logger) ->
|
||||
@ -100,7 +100,7 @@ mod_opt_type(loggers) ->
|
||||
fun (L) ->
|
||||
lists:map(fun (S) ->
|
||||
B = iolist_to_binary(S),
|
||||
N = jlib:nameprep(B),
|
||||
N = jid:nameprep(B),
|
||||
if N /= error -> N end
|
||||
end,
|
||||
L)
|
||||
|
@ -182,8 +182,8 @@ get_vcard_module(Server) ->
|
||||
|
||||
get_rosteritem_name([], _, _) -> <<"">>;
|
||||
get_rosteritem_name([ModVcard], U, S) ->
|
||||
From = jlib:make_jid(<<"">>, S, jlib:atom_to_binary(?MODULE)),
|
||||
To = jlib:make_jid(U, S, <<"">>),
|
||||
From = jid:make(<<"">>, S, jlib:atom_to_binary(?MODULE)),
|
||||
To = jid:make(U, S, <<"">>),
|
||||
case lists:member(To#jid.lserver, ?MYHOSTS) of
|
||||
true ->
|
||||
IQ = {iq, <<"">>, get, <<"vcard-temp">>, <<"">>,
|
||||
@ -246,11 +246,11 @@ process_item(RosterItem, Host) ->
|
||||
%% existing roster groups.
|
||||
[] ->
|
||||
mod_roster:out_subscription(UserTo, ServerTo,
|
||||
jlib:make_jid(UserFrom, ServerFrom,
|
||||
jid:make(UserFrom, ServerFrom,
|
||||
<<"">>),
|
||||
unsubscribe),
|
||||
mod_roster:in_subscription(aaaa, UserFrom, ServerFrom,
|
||||
jlib:make_jid(UserTo, ServerTo,
|
||||
jid:make(UserTo, ServerTo,
|
||||
<<"">>),
|
||||
unsubscribe, <<"">>),
|
||||
RosterItem#roster{subscription = both, ask = none};
|
||||
@ -275,8 +275,8 @@ set_new_rosteritems(UserFrom, ServerFrom, UserTo,
|
||||
RIFrom = build_roster_record(UserFrom, ServerFrom,
|
||||
UserTo, ServerTo, NameTo, GroupsFrom),
|
||||
set_item(UserFrom, ServerFrom, ResourceTo, RIFrom),
|
||||
JIDTo = jlib:make_jid(UserTo, ServerTo, <<"">>),
|
||||
JIDFrom = jlib:make_jid(UserFrom, ServerFrom, <<"">>),
|
||||
JIDTo = jid:make(UserTo, ServerTo, <<"">>),
|
||||
JIDFrom = jid:make(UserFrom, ServerFrom, <<"">>),
|
||||
RITo = build_roster_record(UserTo, ServerTo, UserFrom,
|
||||
ServerFrom, UserFrom, []),
|
||||
set_item(UserTo, ServerTo, <<"">>, RITo),
|
||||
@ -305,14 +305,14 @@ set_item(User, Server, Resource, Item) ->
|
||||
[#xmlel{name = <<"query">>,
|
||||
attrs = [{<<"xmlns">>, ?NS_ROSTER}],
|
||||
children = [mod_roster:item_to_xml(Item)]}]},
|
||||
ejabberd_router:route(jlib:make_jid(User, Server,
|
||||
ejabberd_router:route(jid:make(User, Server,
|
||||
Resource),
|
||||
jlib:make_jid(<<"">>, Server, <<"">>),
|
||||
jid:make(<<"">>, Server, <<"">>),
|
||||
jlib:iq_to_xml(ResIQ)).
|
||||
|
||||
get_subscription_lists({F, T}, User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
US = {LUser, LServer},
|
||||
DisplayedGroups = get_user_displayed_groups(US),
|
||||
SRUsers = lists:usort(lists:flatmap(fun (Group) ->
|
||||
@ -324,10 +324,10 @@ get_subscription_lists({F, T}, User, Server) ->
|
||||
|
||||
get_jid_info({Subscription, Groups}, User, Server,
|
||||
JID) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
US = {LUser, LServer},
|
||||
{U1, S1, _} = jlib:jid_tolower(JID),
|
||||
{U1, S1, _} = jid:tolower(JID),
|
||||
US1 = {U1, S1},
|
||||
DisplayedGroups = get_user_displayed_groups(US),
|
||||
SRUsers = lists:foldl(fun (Group, Acc1) ->
|
||||
@ -357,7 +357,7 @@ in_subscription(Acc, User, Server, JID, Type,
|
||||
out_subscription(UserFrom, ServerFrom, JIDTo,
|
||||
unsubscribed) ->
|
||||
#jid{luser = UserTo, lserver = ServerTo} = JIDTo,
|
||||
JIDFrom = jlib:make_jid(UserFrom, ServerFrom, <<"">>),
|
||||
JIDFrom = jid:make(UserFrom, ServerFrom, <<"">>),
|
||||
mod_roster:out_subscription(UserTo, ServerTo, JIDFrom,
|
||||
unsubscribe),
|
||||
mod_roster:in_subscription(aaaa, UserFrom, ServerFrom,
|
||||
@ -370,11 +370,11 @@ out_subscription(User, Server, JID, Type) ->
|
||||
|
||||
process_subscription(Direction, User, Server, JID,
|
||||
_Type, Acc) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
US = {LUser, LServer},
|
||||
{U1, S1, _} =
|
||||
jlib:jid_tolower(jlib:jid_remove_resource(JID)),
|
||||
jid:tolower(jid:remove_resource(JID)),
|
||||
US1 = {U1, S1},
|
||||
DisplayedGroups = get_user_displayed_groups(US),
|
||||
SRUsers = lists:usort(lists:flatmap(fun (Group) ->
|
||||
@ -657,7 +657,7 @@ get_group_explicit_users(Host, Group, odbc) ->
|
||||
{selected, [<<"jid">>], Rs} ->
|
||||
lists:map(fun ([JID]) ->
|
||||
{U, S, _} =
|
||||
jlib:jid_tolower(jlib:string_to_jid(JID)),
|
||||
jid:tolower(jid:from_string(JID)),
|
||||
{U, S}
|
||||
end,
|
||||
Rs);
|
||||
@ -949,8 +949,8 @@ remove_user(User, Server) ->
|
||||
push_user_to_members(User, Server, remove).
|
||||
|
||||
push_user_to_members(User, Server, Subscription) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
GroupsOpts = groups_with_opts(LServer),
|
||||
SpecialGroups =
|
||||
get_special_displayed_groups(GroupsOpts),
|
||||
@ -1024,8 +1024,8 @@ push_item(User, Server, Item) ->
|
||||
attrs = [{<<"xmlns">>, ?NS_ROSTER}],
|
||||
children = [item_to_xml(Item)]}]}),
|
||||
lists:foreach(fun (Resource) ->
|
||||
JID = jlib:make_jid(User, Server, Resource),
|
||||
ejabberd_router:route(jlib:jid_remove_resource(JID), JID, Stanza)
|
||||
JID = jid:make(User, Server, Resource),
|
||||
ejabberd_router:route(jid:remove_resource(JID), JID, Stanza)
|
||||
end,
|
||||
ejabberd_sm:get_user_resources(User, Server)).
|
||||
|
||||
@ -1040,7 +1040,7 @@ push_roster_item(User, Server, ContactU, ContactS,
|
||||
|
||||
item_to_xml(Item) ->
|
||||
Attrs1 = [{<<"jid">>,
|
||||
jlib:jid_to_string(Item#roster.jid)}],
|
||||
jid:to_string(Item#roster.jid)}],
|
||||
Attrs2 = case Item#roster.name of
|
||||
<<"">> -> Attrs1;
|
||||
Name -> [{<<"name">>, Name} | Attrs1]
|
||||
@ -1298,7 +1298,7 @@ shared_roster_group_parse_query(Host, Group, Query) ->
|
||||
<<"@all@">> -> USs;
|
||||
<<"@online@">> -> USs;
|
||||
_ ->
|
||||
case jlib:string_to_jid(SJID)
|
||||
case jid:from_string(SJID)
|
||||
of
|
||||
JID
|
||||
when is_record(JID,
|
||||
@ -1358,7 +1358,7 @@ get_opt(Opts, Opt, Default) ->
|
||||
end.
|
||||
|
||||
us_to_list({User, Server}) ->
|
||||
jlib:jid_to_string({User, Server, <<"">>}).
|
||||
jid:to_string({User, Server, <<"">>}).
|
||||
|
||||
split_grouphost(Host, Group) ->
|
||||
case str:tokens(Group, <<"@">>) of
|
||||
@ -1368,8 +1368,8 @@ split_grouphost(Host, Group) ->
|
||||
|
||||
broadcast_subscription(User, Server, ContactJid, Subscription) ->
|
||||
ejabberd_sm:route(
|
||||
jlib:make_jid(<<"">>, Server, <<"">>),
|
||||
jlib:make_jid(User, Server, <<"">>),
|
||||
jid:make(<<"">>, Server, <<"">>),
|
||||
jid:make(User, Server, <<"">>),
|
||||
{broadcast, {item, ContactJid,
|
||||
Subscription}}).
|
||||
|
||||
@ -1386,7 +1386,7 @@ displayed_groups_update(Members, DisplayedGroups, Subscription) ->
|
||||
end, Members).
|
||||
|
||||
make_jid_s(U, S) ->
|
||||
ejabberd_odbc:escape(jlib:jid_to_string(jlib:jid_tolower(jlib:make_jid(U,
|
||||
ejabberd_odbc:escape(jid:to_string(jid:tolower(jid:make(U,
|
||||
S,
|
||||
<<"">>)))).
|
||||
|
||||
@ -1466,9 +1466,9 @@ export(_Server) ->
|
||||
when LServer == Host ->
|
||||
SGroup = ejabberd_odbc:escape(Group),
|
||||
SJID = ejabberd_odbc:escape(
|
||||
jlib:jid_to_string(
|
||||
jlib:jid_tolower(
|
||||
jlib:make_jid(U, S, <<"">>)))),
|
||||
jid:to_string(
|
||||
jid:tolower(
|
||||
jid:make(U, S, <<"">>)))),
|
||||
[[<<"delete from sr_user where jid='">>, SJID,
|
||||
<<"'and grp='">>, Group, <<"';">>],
|
||||
[<<"insert into sr_user(jid, grp) values ('">>,
|
||||
@ -1485,7 +1485,7 @@ import(LServer) ->
|
||||
end},
|
||||
{<<"select jid, grp from sr_user;">>,
|
||||
fun([SJID, Group]) ->
|
||||
#jid{luser = U, lserver = S} = jlib:string_to_jid(SJID),
|
||||
#jid{luser = U, lserver = S} = jid:from_string(SJID),
|
||||
#sr_user{us = {U, S}, group_host = {Group, LServer}}
|
||||
end}].
|
||||
|
||||
|
@ -159,8 +159,8 @@ process_item(RosterItem, _Host) ->
|
||||
end.
|
||||
|
||||
get_subscription_lists({F, T}, User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
US = {LUser, LServer},
|
||||
DisplayedGroups = get_user_displayed_groups(US),
|
||||
SRUsers = lists:usort(lists:flatmap(fun (Group) ->
|
||||
@ -172,10 +172,10 @@ get_subscription_lists({F, T}, User, Server) ->
|
||||
|
||||
get_jid_info({Subscription, Groups}, User, Server,
|
||||
JID) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
US = {LUser, LServer},
|
||||
{U1, S1, _} = jlib:jid_tolower(JID),
|
||||
{U1, S1, _} = jid:tolower(JID),
|
||||
US1 = {U1, S1},
|
||||
SRUsers = get_user_to_groups_map(US, false),
|
||||
case dict:find(US1, SRUsers) of
|
||||
@ -197,11 +197,11 @@ out_subscription(User, Server, JID, Type) ->
|
||||
|
||||
process_subscription(Direction, User, Server, JID,
|
||||
_Type, Acc) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
US = {LUser, LServer},
|
||||
{U1, S1, _} =
|
||||
jlib:jid_tolower(jlib:jid_remove_resource(JID)),
|
||||
jid:tolower(jid:remove_resource(JID)),
|
||||
US1 = {U1, S1},
|
||||
DisplayedGroups = get_user_displayed_groups(US),
|
||||
SRUsers = lists:usort(lists:flatmap(fun (Group) ->
|
||||
@ -417,7 +417,7 @@ search_group_info(State, Group) ->
|
||||
UID},
|
||||
L) ->
|
||||
PUID =
|
||||
jlib:nodeprep(UID),
|
||||
jid:nodeprep(UID),
|
||||
case
|
||||
PUID
|
||||
of
|
||||
|
@ -160,8 +160,8 @@ locate(_SIPMsg) ->
|
||||
ok.
|
||||
|
||||
find(#uri{user = User, host = Host}) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Host),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Host),
|
||||
if LUser == <<"">> ->
|
||||
to_me;
|
||||
true ->
|
||||
@ -192,7 +192,7 @@ action(#sip{method = <<"REGISTER">>, type = request, hdrs = Hdrs,
|
||||
true ->
|
||||
register;
|
||||
false ->
|
||||
{auth, jlib:nameprep(ToURI#uri.host)}
|
||||
{auth, jid:nameprep(ToURI#uri.host)}
|
||||
end;
|
||||
false ->
|
||||
deny
|
||||
@ -223,7 +223,7 @@ action(#sip{method = Method, hdrs = Hdrs, type = request} = Req, SIPSock) ->
|
||||
true ->
|
||||
find(ToURI);
|
||||
false ->
|
||||
LServer = jlib:nameprep(FromURI#uri.host),
|
||||
LServer = jid:nameprep(FromURI#uri.host),
|
||||
{relay, LServer}
|
||||
end;
|
||||
false ->
|
||||
@ -250,8 +250,8 @@ check_auth(#sip{method = Method, hdrs = Hdrs, body = Body}, AuthHdr, _SIPSock) -
|
||||
from
|
||||
end,
|
||||
{_, #uri{user = User, host = Host}, _} = esip:get_hdr(Issuer, Hdrs),
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Host),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Host),
|
||||
case lists:filter(
|
||||
fun({_, Params}) ->
|
||||
Username = esip:get_param(<<"username">>, Params),
|
||||
@ -299,7 +299,7 @@ make_response(Req, Resp) ->
|
||||
esip:make_response(Req, Resp, esip:make_tag()).
|
||||
|
||||
at_my_host(#uri{host = Host}) ->
|
||||
is_my_host(jlib:nameprep(Host)).
|
||||
is_my_host(jid:nameprep(Host)).
|
||||
|
||||
is_my_host(LServer) ->
|
||||
gen_mod:is_loaded(LServer, ?MODULE).
|
||||
|
@ -249,8 +249,8 @@ connect(#sip{hdrs = Hdrs} = Req, Opts) ->
|
||||
{_, ToURI, _} = esip:get_hdr('to', Hdrs),
|
||||
case mod_sip:at_my_host(ToURI) of
|
||||
true ->
|
||||
LUser = jlib:nodeprep(ToURI#uri.user),
|
||||
LServer = jlib:nameprep(ToURI#uri.host),
|
||||
LUser = jid:nodeprep(ToURI#uri.user),
|
||||
LServer = jid:nameprep(ToURI#uri.host),
|
||||
case mod_sip_registrar:find_sockets(LUser, LServer) of
|
||||
[_|_] = SIPSocks ->
|
||||
{ok, SIPSocks};
|
||||
@ -412,7 +412,7 @@ choose_best_response(#state{responses = Responses} = State) ->
|
||||
|
||||
%% Just compare host part only.
|
||||
cmp_uri(#uri{host = H1}, #uri{host = H2}) ->
|
||||
jlib:nameprep(H1) == jlib:nameprep(H2).
|
||||
jid:nameprep(H1) == jid:nameprep(H2).
|
||||
|
||||
is_my_route(URI, URIs) ->
|
||||
lists:any(fun(U) -> cmp_uri(URI, U) end, URIs).
|
||||
@ -441,20 +441,20 @@ prepare_request(LServer, #sip{hdrs = Hdrs} = Req) ->
|
||||
Hdrs3 = lists:filter(
|
||||
fun({'proxy-authorization', {_, Params}}) ->
|
||||
Realm = esip:unquote(esip:get_param(<<"realm">>, Params)),
|
||||
not mod_sip:is_my_host(jlib:nameprep(Realm));
|
||||
not mod_sip:is_my_host(jid:nameprep(Realm));
|
||||
(_) ->
|
||||
true
|
||||
end, Hdrs2),
|
||||
Req#sip{hdrs = Hdrs3}.
|
||||
|
||||
safe_nodeprep(S) ->
|
||||
case jlib:nodeprep(S) of
|
||||
case jid:nodeprep(S) of
|
||||
error -> S;
|
||||
S1 -> S1
|
||||
end.
|
||||
|
||||
safe_nameprep(S) ->
|
||||
case jlib:nameprep(S) of
|
||||
case jid:nameprep(S) of
|
||||
error -> S;
|
||||
S1 -> S1
|
||||
end.
|
||||
|
@ -65,8 +65,8 @@ start_link() ->
|
||||
|
||||
request(#sip{hdrs = Hdrs} = Req, SIPSock) ->
|
||||
{_, #uri{user = U, host = S}, _} = esip:get_hdr('to', Hdrs),
|
||||
LUser = jlib:nodeprep(U),
|
||||
LServer = jlib:nameprep(S),
|
||||
LUser = jid:nodeprep(U),
|
||||
LServer = jid:nameprep(S),
|
||||
{PeerIP, _} = SIPSock#sip_socket.peer,
|
||||
US = {LUser, LServer},
|
||||
CallID = esip:get_hdr('call-id', Hdrs),
|
||||
|
@ -261,7 +261,7 @@ set_vcard(User, LServer, VCARD) ->
|
||||
<<"">> -> EMail2;
|
||||
_ -> EMail1
|
||||
end,
|
||||
LUser = jlib:nodeprep(User),
|
||||
LUser = jid:nodeprep(User),
|
||||
LFN = string2lower(FN),
|
||||
LFamily = string2lower(Family),
|
||||
LGiven = string2lower(Given),
|
||||
@ -404,7 +404,7 @@ string2lower(String) ->
|
||||
[{xmlcdata,
|
||||
<<(translate:translate(Lang,
|
||||
<<"Search users in ">>))/binary,
|
||||
(jlib:jid_to_string(JID))/binary>>}]},
|
||||
(jid:to_string(JID))/binary>>}]},
|
||||
#xmlel{name = <<"instructions">>, attrs = [],
|
||||
children =
|
||||
[{xmlcdata,
|
||||
@ -607,7 +607,7 @@ search_result(Lang, JID, ServerHost, Data) ->
|
||||
[{xmlcdata,
|
||||
<<(translate:translate(Lang,
|
||||
<<"Search Results for ">>))/binary,
|
||||
(jlib:jid_to_string(JID))/binary>>}]},
|
||||
(jid:to_string(JID))/binary>>}]},
|
||||
#xmlel{name = <<"reported">>, attrs = [],
|
||||
children =
|
||||
[?TLFIELD(<<"text-single">>, <<"Jabber ID">>,
|
||||
@ -916,8 +916,8 @@ reindex_vcards() ->
|
||||
mnesia:transaction(F).
|
||||
|
||||
remove_user(User, Server) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
LUser = jid:nodeprep(User),
|
||||
LServer = jid:nameprep(Server),
|
||||
remove_user(LUser, LServer,
|
||||
gen_mod:db_type(LServer, ?MODULE)).
|
||||
|
||||
|
@ -422,7 +422,7 @@ ldap_attribute_to_vcard(_, _) -> none.
|
||||
[{xmlcdata,
|
||||
<<(translate:translate(Lang,
|
||||
<<"Search users in ">>))/binary,
|
||||
(jlib:jid_to_string(JID))/binary>>}]},
|
||||
(jid:to_string(JID))/binary>>}]},
|
||||
#xmlel{name = <<"instructions">>, attrs = [],
|
||||
children =
|
||||
[{xmlcdata,
|
||||
@ -600,7 +600,7 @@ search_result(Lang, JID, State, Data) ->
|
||||
[{xmlcdata,
|
||||
<<(translate:translate(Lang,
|
||||
<<"Search Results for ">>))/binary,
|
||||
(jlib:jid_to_string(JID))/binary>>}]},
|
||||
(jid:to_string(JID))/binary>>}]},
|
||||
#xmlel{name = <<"reported">>, attrs = [],
|
||||
children =
|
||||
[?TLFIELD(<<"text-single">>, <<"Jabber ID">>,
|
||||
|
@ -116,7 +116,7 @@ features() ->
|
||||
%% checked. This parameter depends on the value of the
|
||||
%% <tt>access_createnode</tt> ACL value in ejabberd config file.</p>
|
||||
create_node_permission(Host, ServerHost, _Node, _ParentNode, Owner, Access) ->
|
||||
LOwner = jlib:jid_tolower(Owner),
|
||||
LOwner = jid:tolower(Owner),
|
||||
Allowed = case LOwner of
|
||||
{<<"">>, Host, <<"">>} ->
|
||||
true; % pubsub service always allowed
|
||||
@ -126,7 +126,7 @@ create_node_permission(Host, ServerHost, _Node, _ParentNode, Owner, Access) ->
|
||||
{result, Allowed}.
|
||||
|
||||
create_node(Nidx, Owner) ->
|
||||
OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
||||
OwnerKey = jid:tolower(jid:remove_resource(Owner)),
|
||||
set_state(#pubsub_state{stateid = {OwnerKey, Nidx},
|
||||
affiliation = owner}),
|
||||
{result, {default, broadcast}}.
|
||||
@ -178,9 +178,9 @@ delete_node(Nodes) ->
|
||||
%% <p>In the default plugin module, the record is unchanged.</p>
|
||||
subscribe_node(Nidx, Sender, Subscriber, AccessModel,
|
||||
SendLast, PresenceSubscription, RosterGroup, Options) ->
|
||||
SubKey = jlib:jid_tolower(Subscriber),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
Authorized = jlib:jid_tolower(jlib:jid_remove_resource(Sender)) == GenKey,
|
||||
SubKey = jid:tolower(Subscriber),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
Authorized = jid:tolower(jid:remove_resource(Sender)) == GenKey,
|
||||
GenState = get_state(Nidx, GenKey),
|
||||
SubState = case SubKey of
|
||||
GenKey -> GenState;
|
||||
@ -238,9 +238,9 @@ subscribe_node(Nidx, Sender, Subscriber, AccessModel,
|
||||
|
||||
%% @doc <p>Unsubscribe the <tt>Subscriber</tt> from the <tt>Node</tt>.</p>
|
||||
unsubscribe_node(Nidx, Sender, Subscriber, SubId) ->
|
||||
SubKey = jlib:jid_tolower(Subscriber),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
Authorized = jlib:jid_tolower(jlib:jid_remove_resource(Sender)) == GenKey,
|
||||
SubKey = jid:tolower(Subscriber),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
Authorized = jid:tolower(jid:remove_resource(Sender)) == GenKey,
|
||||
GenState = get_state(Nidx, GenKey),
|
||||
SubState = case SubKey of
|
||||
GenKey -> GenState;
|
||||
@ -340,8 +340,8 @@ delete_subscriptions(SubKey, Nidx, Subscriptions, SubState) ->
|
||||
%% </p>
|
||||
%% <p>In the default plugin module, the record is unchanged.</p>
|
||||
publish_item(Nidx, Publisher, PublishModel, MaxItems, ItemId, Payload) ->
|
||||
SubKey = jlib:jid_tolower(Publisher),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
SubKey = jid:tolower(Publisher),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
GenState = get_state(Nidx, GenKey),
|
||||
SubState = case SubKey of
|
||||
GenKey -> GenState;
|
||||
@ -406,8 +406,8 @@ remove_extra_items(Nidx, MaxItems, ItemIds) ->
|
||||
%% <p>Default plugin: The user performing the deletion must be the node owner
|
||||
%% or a publisher, or PublishModel being open.</p>
|
||||
delete_item(Nidx, Publisher, PublishModel, ItemId) ->
|
||||
SubKey = jlib:jid_tolower(Publisher),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
SubKey = jid:tolower(Publisher),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
GenState = get_state(Nidx, GenKey),
|
||||
#pubsub_state{affiliation = Affiliation, items = Items} = GenState,
|
||||
Allowed = Affiliation == publisher orelse
|
||||
@ -451,8 +451,8 @@ delete_item(Nidx, Publisher, PublishModel, ItemId) ->
|
||||
end.
|
||||
|
||||
purge_node(Nidx, Owner) ->
|
||||
SubKey = jlib:jid_tolower(Owner),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
SubKey = jid:tolower(Owner),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
GenState = get_state(Nidx, GenKey),
|
||||
case GenState of
|
||||
#pubsub_state{affiliation = owner} ->
|
||||
@ -478,8 +478,8 @@ purge_node(Nidx, Owner) ->
|
||||
%% that will be added to the affiliation stored in the main
|
||||
%% <tt>pubsub_state</tt> table.</p>
|
||||
get_entity_affiliations(Host, Owner) ->
|
||||
SubKey = jlib:jid_tolower(Owner),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
SubKey = jid:tolower(Owner),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
States = mnesia:match_object(#pubsub_state{stateid = {GenKey, '_'}, _ = '_'}),
|
||||
NodeTree = mod_pubsub:tree(Host),
|
||||
Reply = lists:foldl(fun (#pubsub_state{stateid = {_, N}, affiliation = A}, Acc) ->
|
||||
@ -497,14 +497,14 @@ get_node_affiliations(Nidx) ->
|
||||
{result, lists:map(Tr, States)}.
|
||||
|
||||
get_affiliation(Nidx, Owner) ->
|
||||
SubKey = jlib:jid_tolower(Owner),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
SubKey = jid:tolower(Owner),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
#pubsub_state{affiliation = Affiliation} = get_state(Nidx, GenKey),
|
||||
{result, Affiliation}.
|
||||
|
||||
set_affiliation(Nidx, Owner, Affiliation) ->
|
||||
SubKey = jlib:jid_tolower(Owner),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
SubKey = jid:tolower(Owner),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
GenState = get_state(Nidx, GenKey),
|
||||
case {Affiliation, GenState#pubsub_state.subscriptions} of
|
||||
{none, []} -> del_state(Nidx, GenKey);
|
||||
@ -519,8 +519,8 @@ set_affiliation(Nidx, Owner, Affiliation) ->
|
||||
%% that will be added to the affiliation stored in the main
|
||||
%% <tt>pubsub_state</tt> table.</p>
|
||||
get_entity_subscriptions(Host, Owner) ->
|
||||
{U, D, _} = SubKey = jlib:jid_tolower(Owner),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
{U, D, _} = SubKey = jid:tolower(Owner),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
States = case SubKey of
|
||||
GenKey ->
|
||||
mnesia:match_object(#pubsub_state{stateid = {{U, D, '_'}, '_'}, _ = '_'});
|
||||
@ -562,12 +562,12 @@ get_node_subscriptions(Nidx) ->
|
||||
{result, lists:flatmap(Tr, States)}.
|
||||
|
||||
get_subscriptions(Nidx, Owner) ->
|
||||
SubKey = jlib:jid_tolower(Owner),
|
||||
SubKey = jid:tolower(Owner),
|
||||
SubState = get_state(Nidx, SubKey),
|
||||
{result, SubState#pubsub_state.subscriptions}.
|
||||
|
||||
set_subscriptions(Nidx, Owner, Subscription, SubId) ->
|
||||
SubKey = jlib:jid_tolower(Owner),
|
||||
SubKey = jid:tolower(Owner),
|
||||
SubState = get_state(Nidx, SubKey),
|
||||
case {SubId, SubState#pubsub_state.subscriptions} of
|
||||
{_, []} ->
|
||||
@ -620,7 +620,7 @@ unsub_with_subid(Nidx, SubId, #pubsub_state{stateid = {Entity, _}} = SubState) -
|
||||
%% @doc <p>Returns a list of Owner's nodes on Host with pending
|
||||
%% subscriptions.</p>
|
||||
get_pending_nodes(Host, Owner) ->
|
||||
GenKey = jlib:jid_remove_resource(jlib:jid_tolower(Owner)),
|
||||
GenKey = jid:remove_resource(jid:tolower(Owner)),
|
||||
States = mnesia:match_object(#pubsub_state{stateid = {GenKey, '_'},
|
||||
affiliation = owner,
|
||||
_ = '_'}),
|
||||
@ -702,8 +702,8 @@ get_items(Nidx, _From, _RSM) ->
|
||||
{result, {lists:reverse(lists:keysort(#pubsub_item.modification, Items)), none}}.
|
||||
|
||||
get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId, RSM) ->
|
||||
SubKey = jlib:jid_tolower(JID),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
SubKey = jid:tolower(JID),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
GenState = get_state(Nidx, GenKey),
|
||||
SubState = get_state(Nidx, SubKey),
|
||||
Affiliation = GenState#pubsub_state.affiliation,
|
||||
@ -746,8 +746,8 @@ get_item(Nidx, ItemId) ->
|
||||
end.
|
||||
|
||||
get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId) ->
|
||||
SubKey = jlib:jid_tolower(JID),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
SubKey = jid:tolower(JID),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
GenState = get_state(Nidx, GenKey),
|
||||
Affiliation = GenState#pubsub_state.affiliation,
|
||||
Subscriptions = GenState#pubsub_state.subscriptions,
|
||||
|
@ -73,7 +73,7 @@ create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) ->
|
||||
node_flat:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
|
||||
|
||||
create_node(Nidx, Owner) ->
|
||||
{_U, _S, _R} = OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
||||
{_U, _S, _R} = OwnerKey = jid:tolower(jid:remove_resource(Owner)),
|
||||
State = #pubsub_state{stateid = {OwnerKey, Nidx}, affiliation = owner},
|
||||
catch ejabberd_odbc:sql_query_t([<<"insert into pubsub_state(nodeid, jid, affiliation, subscriptions) "
|
||||
"values(">>, state_to_raw(Nidx, State), <<");">>]),
|
||||
@ -96,9 +96,9 @@ delete_node(Nodes) ->
|
||||
|
||||
subscribe_node(Nidx, Sender, Subscriber, AccessModel,
|
||||
SendLast, PresenceSubscription, RosterGroup, Options) ->
|
||||
SubKey = jlib:jid_tolower(Subscriber),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
Authorized = jlib:jid_tolower(jlib:jid_remove_resource(Sender)) == GenKey,
|
||||
SubKey = jid:tolower(Subscriber),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
Authorized = jid:tolower(jid:remove_resource(Sender)) == GenKey,
|
||||
{Affiliation, Subscriptions} = select_affiliation_subscriptions(Nidx, GenKey, SubKey),
|
||||
Whitelisted = lists:member(Affiliation, [member, publisher, owner]),
|
||||
PendingSubscription = lists:any(fun
|
||||
@ -145,9 +145,9 @@ subscribe_node(Nidx, Sender, Subscriber, AccessModel,
|
||||
end.
|
||||
|
||||
unsubscribe_node(Nidx, Sender, Subscriber, SubId) ->
|
||||
SubKey = jlib:jid_tolower(Subscriber),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
Authorized = jlib:jid_tolower(jlib:jid_remove_resource(Sender)) == GenKey,
|
||||
SubKey = jid:tolower(Subscriber),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
Authorized = jid:tolower(jid:remove_resource(Sender)) == GenKey,
|
||||
{Affiliation, Subscriptions} = select_affiliation_subscriptions(Nidx, SubKey),
|
||||
SubIdExists = case SubId of
|
||||
<<>> -> false;
|
||||
@ -207,8 +207,8 @@ delete_subscription(SubKey, Nidx, {Subscription, SubId}, Affiliation, Subscripti
|
||||
end.
|
||||
|
||||
publish_item(Nidx, Publisher, PublishModel, MaxItems, ItemId, Payload) ->
|
||||
SubKey = jlib:jid_tolower(Publisher),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
SubKey = jid:tolower(Publisher),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
{Affiliation, Subscriptions} = select_affiliation_subscriptions(Nidx, GenKey, SubKey),
|
||||
Subscribed = case PublishModel of
|
||||
subscribers -> node_flat:is_subscribed(Subscriptions);
|
||||
@ -245,8 +245,8 @@ remove_extra_items(Nidx, MaxItems, ItemIds) ->
|
||||
{result, {NewItems, OldItems}}.
|
||||
|
||||
delete_item(Nidx, Publisher, PublishModel, ItemId) ->
|
||||
SubKey = jlib:jid_tolower(Publisher),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
SubKey = jid:tolower(Publisher),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
{result, Affiliation} = get_affiliation(Nidx, GenKey),
|
||||
Allowed = Affiliation == publisher orelse
|
||||
Affiliation == owner orelse
|
||||
@ -265,8 +265,8 @@ delete_item(Nidx, Publisher, PublishModel, ItemId) ->
|
||||
end.
|
||||
|
||||
purge_node(Nidx, Owner) ->
|
||||
SubKey = jlib:jid_tolower(Owner),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
SubKey = jid:tolower(Owner),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
GenState = get_state(Nidx, GenKey),
|
||||
case GenState of
|
||||
#pubsub_state{affiliation = owner} ->
|
||||
@ -282,8 +282,8 @@ purge_node(Nidx, Owner) ->
|
||||
end.
|
||||
|
||||
get_entity_affiliations(Host, Owner) ->
|
||||
SubKey = jlib:jid_tolower(Owner),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
SubKey = jid:tolower(Owner),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
H = encode_host(Host),
|
||||
J = encode_jid(GenKey),
|
||||
Reply = case catch
|
||||
@ -312,8 +312,8 @@ get_node_affiliations(Nidx) ->
|
||||
{result, Reply}.
|
||||
|
||||
get_affiliation(Nidx, Owner) ->
|
||||
SubKey = jlib:jid_tolower(Owner),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
SubKey = jid:tolower(Owner),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
J = encode_jid(GenKey),
|
||||
Reply = case catch
|
||||
ejabberd_odbc:sql_query_t([<<"select affiliation from pubsub_state "
|
||||
@ -327,8 +327,8 @@ get_affiliation(Nidx, Owner) ->
|
||||
{result, Reply}.
|
||||
|
||||
set_affiliation(Nidx, Owner, Affiliation) ->
|
||||
SubKey = jlib:jid_tolower(Owner),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
SubKey = jid:tolower(Owner),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
{_, Subscriptions} = select_affiliation_subscriptions(Nidx, GenKey),
|
||||
case {Affiliation, Subscriptions} of
|
||||
{none, []} -> del_state(Nidx, GenKey);
|
||||
@ -336,8 +336,8 @@ set_affiliation(Nidx, Owner, Affiliation) ->
|
||||
end.
|
||||
|
||||
get_entity_subscriptions(Host, Owner) ->
|
||||
SubKey = jlib:jid_tolower(Owner),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
SubKey = jid:tolower(Owner),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
H = encode_host(Host),
|
||||
SJ = encode_jid(SubKey),
|
||||
GJ = encode_jid(GenKey),
|
||||
@ -385,8 +385,8 @@ get_entity_subscriptions(Host, Owner) ->
|
||||
}
|
||||
).
|
||||
get_entity_subscriptions_for_send_last(Host, Owner) ->
|
||||
SubKey = jlib:jid_tolower(Owner),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
SubKey = jid:tolower(Owner),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
H = encode_host(Host),
|
||||
SJ = encode_jid(SubKey),
|
||||
GJ = encode_jid(GenKey),
|
||||
@ -449,7 +449,7 @@ get_node_subscriptions(Nidx) ->
|
||||
{result, Reply}.
|
||||
|
||||
get_subscriptions(Nidx, Owner) ->
|
||||
SubKey = jlib:jid_tolower(Owner),
|
||||
SubKey = jid:tolower(Owner),
|
||||
J = encode_jid(SubKey),
|
||||
Reply = case catch
|
||||
ejabberd_odbc:sql_query_t([<<"select subscriptions from pubsub_state where "
|
||||
@ -463,7 +463,7 @@ get_subscriptions(Nidx, Owner) ->
|
||||
{result, Reply}.
|
||||
|
||||
set_subscriptions(Nidx, Owner, Subscription, SubId) ->
|
||||
SubKey = jlib:jid_tolower(Owner),
|
||||
SubKey = jid:tolower(Owner),
|
||||
SubState = get_state_without_itemids(Nidx, SubKey),
|
||||
case {SubId, SubState#pubsub_state.subscriptions} of
|
||||
{_, []} ->
|
||||
@ -514,7 +514,7 @@ unsub_with_subid(Nidx, SubId, SubState) ->
|
||||
end.
|
||||
|
||||
get_pending_nodes(Host, Owner) ->
|
||||
GenKey = jlib:jid_remove_resource(jlib:jid_tolower(Owner)),
|
||||
GenKey = jid:remove_resource(jid:tolower(Owner)),
|
||||
States = mnesia:match_object(#pubsub_state{stateid = {GenKey, '_'},
|
||||
affiliation = owner, _ = '_'}),
|
||||
Nidxxs = [Nidx || #pubsub_state{stateid = {_, Nidx}} <- States],
|
||||
@ -719,8 +719,8 @@ get_items(Nidx, _From,
|
||||
end.
|
||||
|
||||
get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId, RSM) ->
|
||||
SubKey = jlib:jid_tolower(JID),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
SubKey = jid:tolower(JID),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
{Affiliation, Subscriptions} = select_affiliation_subscriptions(Nidx, GenKey, SubKey),
|
||||
Whitelisted = node_flat:can_fetch_item(Affiliation, Subscriptions),
|
||||
if %%SubId == "", ?? ->
|
||||
@ -777,8 +777,8 @@ get_item(Nidx, ItemId) ->
|
||||
end.
|
||||
|
||||
get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId) ->
|
||||
SubKey = jlib:jid_tolower(JID),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
SubKey = jid:tolower(JID),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
{Affiliation, Subscriptions} = select_affiliation_subscriptions(Nidx, GenKey, SubKey),
|
||||
Whitelisted = node_flat:can_fetch_item(Affiliation, Subscriptions),
|
||||
if %%SubId == "", ?? ->
|
||||
@ -939,7 +939,7 @@ update_subscription(Nidx, JID, Subscription) ->
|
||||
-> ljid()
|
||||
).
|
||||
decode_jid(SJID) ->
|
||||
jlib:jid_tolower(jlib:string_to_jid(SJID)).
|
||||
jid:tolower(jid:from_string(SJID)).
|
||||
|
||||
-spec(decode_affiliation/1 ::
|
||||
( Arg :: binary())
|
||||
@ -979,7 +979,7 @@ decode_subscriptions(Subscriptions) ->
|
||||
-> binary()
|
||||
).
|
||||
encode_jid(JID) ->
|
||||
ejabberd_odbc:escape(jlib:jid_to_string(JID)).
|
||||
ejabberd_odbc:escape(jid:to_string(JID)).
|
||||
|
||||
-spec(encode_host/1 ::
|
||||
( Host :: host())
|
||||
|
@ -69,7 +69,7 @@ features() ->
|
||||
%% <p>This function also check that node can be created as a children of its
|
||||
%% parent node</p>
|
||||
create_node_permission(Host, ServerHost, Node, _ParentNode, Owner, Access) ->
|
||||
LOwner = jlib:jid_tolower(Owner),
|
||||
LOwner = jid:tolower(Owner),
|
||||
{User, Server, _Resource} = LOwner,
|
||||
Allowed = case LOwner of
|
||||
{<<"">>, Host, <<"">>} ->
|
||||
|
@ -94,7 +94,7 @@ features() ->
|
||||
<<"subscribe">>].
|
||||
|
||||
create_node_permission(Host, ServerHost, _Node, _ParentNode, Owner, Access) ->
|
||||
LOwner = jlib:jid_tolower(Owner),
|
||||
LOwner = jid:tolower(Owner),
|
||||
{User, Server, _Resource} = LOwner,
|
||||
Allowed = case LOwner of
|
||||
{<<"">>, Host, <<"">>} ->
|
||||
@ -143,9 +143,9 @@ purge_node(Nidx, Owner) ->
|
||||
node_flat:purge_node(Nidx, Owner).
|
||||
|
||||
get_entity_affiliations(Host, Owner) ->
|
||||
{_, D, _} = SubKey = jlib:jid_tolower(Owner),
|
||||
SubKey = jlib:jid_tolower(Owner),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
{_, D, _} = SubKey = jid:tolower(Owner),
|
||||
SubKey = jid:tolower(Owner),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
States = mnesia:match_object(#pubsub_state{stateid = {GenKey, '_'}, _ = '_'}),
|
||||
NodeTree = mod_pubsub:tree(Host),
|
||||
Reply = lists:foldl(fun (#pubsub_state{stateid = {_, N}, affiliation = A}, Acc) ->
|
||||
@ -168,8 +168,8 @@ set_affiliation(Nidx, Owner, Affiliation) ->
|
||||
node_flat:set_affiliation(Nidx, Owner, Affiliation).
|
||||
|
||||
get_entity_subscriptions(Host, Owner) ->
|
||||
{U, D, _} = SubKey = jlib:jid_tolower(Owner),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
{U, D, _} = SubKey = jid:tolower(Owner),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
States = case SubKey of
|
||||
GenKey ->
|
||||
mnesia:match_object(#pubsub_state{stateid = {{U, D, '_'}, '_'}, _ = '_'});
|
||||
|
@ -100,7 +100,7 @@ purge_node(Nidx, Owner) ->
|
||||
node_flat_odbc:purge_node(Nidx, Owner).
|
||||
|
||||
get_entity_affiliations(_Host, Owner) ->
|
||||
OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
||||
OwnerKey = jid:tolower(jid:remove_resource(Owner)),
|
||||
node_flat_odbc:get_entity_affiliations(OwnerKey, Owner).
|
||||
|
||||
get_node_affiliations(Nidx) ->
|
||||
@ -113,8 +113,8 @@ set_affiliation(Nidx, Owner, Affiliation) ->
|
||||
node_flat_odbc:set_affiliation(Nidx, Owner, Affiliation).
|
||||
|
||||
get_entity_subscriptions(_Host, Owner) ->
|
||||
SubKey = jlib:jid_tolower(Owner),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
SubKey = jid:tolower(Owner),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
Host = node_flat_odbc:encode_host(element(2, SubKey)),
|
||||
SJ = node_flat_odbc:encode_jid(SubKey),
|
||||
GJ = node_flat_odbc:encode_jid(GenKey),
|
||||
@ -148,8 +148,8 @@ get_entity_subscriptions(_Host, Owner) ->
|
||||
{result, Reply}.
|
||||
|
||||
get_entity_subscriptions_for_send_last(_Host, Owner) ->
|
||||
SubKey = jlib:jid_tolower(Owner),
|
||||
GenKey = jlib:jid_remove_resource(SubKey),
|
||||
SubKey = jid:tolower(Owner),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
Host = node_flat_odbc:encode_host(element(2, SubKey)),
|
||||
SJ = node_flat_odbc:encode_jid(SubKey),
|
||||
GJ = node_flat_odbc:encode_jid(GenKey),
|
||||
|
@ -51,7 +51,7 @@ set_node(#pubsub_node{nodeid = {Key, _}, owners = Owners, options = Options} = N
|
||||
end.
|
||||
|
||||
create_node(Key, Node, Type, Owner, Options, Parents) ->
|
||||
OwnerJID = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
||||
OwnerJID = jid:tolower(jid:remove_resource(Owner)),
|
||||
case find_node(Key, Node) of
|
||||
false ->
|
||||
Nidx = pubsub_index:new(node),
|
||||
|
@ -148,7 +148,7 @@ get_subnodes_tree(Host, Node) ->
|
||||
end.
|
||||
|
||||
create_node(Host, Node, Type, Owner, Options, Parents) ->
|
||||
BJID = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
||||
BJID = jid:tolower(jid:remove_resource(Owner)),
|
||||
case catch mnesia:read({pubsub_node, {Host, Node}}) of
|
||||
[] ->
|
||||
ParentExists = case Host of
|
||||
|
@ -211,7 +211,7 @@ get_subnodes_tree(Host, Node) ->
|
||||
end.
|
||||
|
||||
create_node(Host, Node, Type, Owner, Options, Parents) ->
|
||||
BJID = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
||||
BJID = jid:tolower(jid:remove_resource(Owner)),
|
||||
case nodeidx(Host, Node) of
|
||||
{error, ?ERR_ITEM_NOT_FOUND} ->
|
||||
ParentExists = case Host of
|
||||
|
@ -36,7 +36,7 @@
|
||||
-spec salted_password(binary(), binary(), non_neg_integer()) -> binary().
|
||||
|
||||
salted_password(Password, Salt, IterationCount) ->
|
||||
hi(jlib:resourceprep(Password), Salt, IterationCount).
|
||||
hi(jid:resourceprep(Password), Salt, IterationCount).
|
||||
|
||||
-spec client_key(binary()) -> binary().
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user