mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Get rid of jid:to_string/1 and jid:from_string/1
This commit is contained in:
parent
603ec9cb19
commit
c1439ddd5b
@ -24,7 +24,7 @@
|
|||||||
{fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.10"}}},
|
{fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.10"}}},
|
||||||
{stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.7"}}},
|
{stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.7"}}},
|
||||||
{fast_xml, ".*", {git, "https://github.com/processone/fast_xml", {tag, "1.1.21"}}},
|
{fast_xml, ".*", {git, "https://github.com/processone/fast_xml", {tag, "1.1.21"}}},
|
||||||
{xmpp, ".*", {git, "https://github.com/processone/xmpp", {tag, "1.1.8"}}},
|
{xmpp, ".*", {git, "https://github.com/processone/xmpp", "f5cbd6dc0f3ec786b33a7e708979ed27dfbbb0ec"}},
|
||||||
{stun, ".*", {git, "https://github.com/processone/stun", {tag, "1.0.9"}}},
|
{stun, ".*", {git, "https://github.com/processone/stun", {tag, "1.0.9"}}},
|
||||||
{esip, ".*", {git, "https://github.com/processone/esip", {tag, "1.0.10"}}},
|
{esip, ".*", {git, "https://github.com/processone/esip", {tag, "1.0.10"}}},
|
||||||
{fast_yaml, ".*", {git, "https://github.com/processone/fast_yaml", {tag, "1.0.8"}}},
|
{fast_yaml, ".*", {git, "https://github.com/processone/fast_yaml", {tag, "1.0.8"}}},
|
||||||
|
@ -262,7 +262,7 @@ process_terminated(#{sockmod := SockMod, socket := Socket, jid := JID} = State,
|
|||||||
Reason) ->
|
Reason) ->
|
||||||
Status = format_reason(State, Reason),
|
Status = format_reason(State, Reason),
|
||||||
?INFO_MSG("(~s) Closing c2s session for ~s: ~s",
|
?INFO_MSG("(~s) Closing c2s session for ~s: ~s",
|
||||||
[SockMod:pp(Socket), jid:to_string(JID), Status]),
|
[SockMod:pp(Socket), jid:encode(JID), Status]),
|
||||||
State1 = case maps:is_key(pres_last, State) of
|
State1 = case maps:is_key(pres_last, State) of
|
||||||
true ->
|
true ->
|
||||||
Pres = #presence{type = unavailable,
|
Pres = #presence{type = unavailable,
|
||||||
@ -402,12 +402,12 @@ bind(R, #{user := U, server := S, access := Access, lang := Lang,
|
|||||||
State3 = ejabberd_hooks:run_fold(
|
State3 = ejabberd_hooks:run_fold(
|
||||||
c2s_session_opened, LServer, State2, []),
|
c2s_session_opened, LServer, State2, []),
|
||||||
?INFO_MSG("(~s) Opened c2s session for ~s",
|
?INFO_MSG("(~s) Opened c2s session for ~s",
|
||||||
[SockMod:pp(Socket), jid:to_string(JID)]),
|
[SockMod:pp(Socket), jid:encode(JID)]),
|
||||||
{ok, State3};
|
{ok, State3};
|
||||||
deny ->
|
deny ->
|
||||||
ejabberd_hooks:run(forbidden_session_hook, LServer, [JID]),
|
ejabberd_hooks:run(forbidden_session_hook, LServer, [JID]),
|
||||||
?INFO_MSG("(~s) Forbidden c2s session for ~s",
|
?INFO_MSG("(~s) Forbidden c2s session for ~s",
|
||||||
[SockMod:pp(Socket), jid:to_string(JID)]),
|
[SockMod:pp(Socket), jid:encode(JID)]),
|
||||||
Txt = <<"Denied by ACL">>,
|
Txt = <<"Denied by ACL">>,
|
||||||
{error, xmpp:err_not_allowed(Txt, Lang), State}
|
{error, xmpp:err_not_allowed(Txt, Lang), State}
|
||||||
end
|
end
|
||||||
|
@ -89,12 +89,12 @@ create_captcha(SID, From, To, Lang, Limiter, Args) ->
|
|||||||
case create_image(Limiter) of
|
case create_image(Limiter) of
|
||||||
{ok, Type, Key, Image} ->
|
{ok, Type, Key, Image} ->
|
||||||
Id = <<(randoms:get_string())/binary>>,
|
Id = <<(randoms:get_string())/binary>>,
|
||||||
JID = jid:to_string(From),
|
JID = jid:encode(From),
|
||||||
CID = <<"sha1+", (p1_sha:sha(Image))/binary, "@bob.xmpp.org">>,
|
CID = <<"sha1+", (p1_sha:sha(Image))/binary, "@bob.xmpp.org">>,
|
||||||
Data = #bob_data{cid = CID, 'max-age' = 0, type = Type,
|
Data = #bob_data{cid = CID, 'max-age' = 0, type = Type,
|
||||||
data = Image},
|
data = Image},
|
||||||
Fs = [mk_field(hidden, <<"FORM_TYPE">>, ?NS_CAPTCHA),
|
Fs = [mk_field(hidden, <<"FORM_TYPE">>, ?NS_CAPTCHA),
|
||||||
mk_field(hidden, <<"from">>, jid:to_string(To)),
|
mk_field(hidden, <<"from">>, jid:encode(To)),
|
||||||
mk_field(hidden, <<"challenge">>, Id),
|
mk_field(hidden, <<"challenge">>, Id),
|
||||||
mk_field(hidden, <<"sid">>, SID),
|
mk_field(hidden, <<"sid">>, SID),
|
||||||
mk_ocr_field(Lang, CID, Type)],
|
mk_ocr_field(Lang, CID, Type)],
|
||||||
@ -134,7 +134,7 @@ create_captcha_x(SID, To, Lang, Limiter, #xdata{fields = Fs} = X) ->
|
|||||||
label = translate:translate(
|
label = translate:translate(
|
||||||
Lang, <<"CAPTCHA web page">>),
|
Lang, <<"CAPTCHA web page">>),
|
||||||
values = [Imageurl]},
|
values = [Imageurl]},
|
||||||
mk_field(hidden, <<"from">>, jid:to_string(To)),
|
mk_field(hidden, <<"from">>, jid:encode(To)),
|
||||||
mk_field(hidden, <<"challenge">>, Id),
|
mk_field(hidden, <<"challenge">>, Id),
|
||||||
mk_field(hidden, <<"sid">>, SID),
|
mk_field(hidden, <<"sid">>, SID),
|
||||||
mk_ocr_field(Lang, CID, Type)],
|
mk_ocr_field(Lang, CID, Type)],
|
||||||
|
@ -108,18 +108,18 @@ get_commands_spec() ->
|
|||||||
|
|
||||||
oauth_issue_token(Jid, TTLSeconds, ScopesString) ->
|
oauth_issue_token(Jid, TTLSeconds, ScopesString) ->
|
||||||
Scopes = [list_to_binary(Scope) || Scope <- string:tokens(ScopesString, ";")],
|
Scopes = [list_to_binary(Scope) || Scope <- string:tokens(ScopesString, ";")],
|
||||||
case jid:from_string(list_to_binary(Jid)) of
|
try jid:decode(list_to_binary(Jid)) of
|
||||||
#jid{luser =Username, lserver = Server} ->
|
#jid{luser =Username, lserver = Server} ->
|
||||||
case oauth2:authorize_password({Username, Server}, Scopes, admin_generated) of
|
case oauth2:authorize_password({Username, Server}, Scopes, admin_generated) of
|
||||||
{ok, {_Ctx,Authorization}} ->
|
{ok, {_Ctx,Authorization}} ->
|
||||||
{ok, {_AppCtx2, Response}} = oauth2:issue_token(Authorization, [{expiry_time, TTLSeconds}]),
|
{ok, {_AppCtx2, Response}} = oauth2:issue_token(Authorization, [{expiry_time, TTLSeconds}]),
|
||||||
{ok, AccessToken} = oauth2_response:access_token(Response),
|
{ok, AccessToken} = oauth2_response:access_token(Response),
|
||||||
{ok, VerifiedScope} = oauth2_response:scope(Response),
|
{ok, VerifiedScope} = oauth2_response:scope(Response),
|
||||||
{AccessToken, VerifiedScope, integer_to_list(TTLSeconds) ++ " seconds"};
|
{AccessToken, VerifiedScope, integer_to_list(TTLSeconds) ++ " seconds"};
|
||||||
{error, Error} ->
|
{error, Error} ->
|
||||||
{error, Error}
|
{error, Error}
|
||||||
end;
|
end
|
||||||
error ->
|
catch _:{bad_jid, _} ->
|
||||||
{error, "Invalid JID: " ++ Jid}
|
{error, "Invalid JID: " ++ Jid}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ oauth_list_tokens() ->
|
|||||||
Tokens = mnesia:dirty_match_object(#oauth_token{_ = '_'}),
|
Tokens = mnesia:dirty_match_object(#oauth_token{_ = '_'}),
|
||||||
{MegaSecs, Secs, _MiniSecs} = os:timestamp(),
|
{MegaSecs, Secs, _MiniSecs} = os:timestamp(),
|
||||||
TS = 1000000 * MegaSecs + Secs,
|
TS = 1000000 * MegaSecs + Secs,
|
||||||
[{Token, jid:to_string(jid:make(U,S)), Scope, integer_to_list(Expires - TS) ++ " seconds"} ||
|
[{Token, jid:encode(jid:make(U,S)), Scope, integer_to_list(Expires - TS) ++ " seconds"} ||
|
||||||
#oauth_token{token=Token, scope=Scope, us= {U,S},expire=Expires} <- Tokens].
|
#oauth_token{token=Token, scope=Scope, us= {U,S},expire=Expires} <- Tokens].
|
||||||
|
|
||||||
|
|
||||||
@ -479,7 +479,7 @@ process(_Handlers,
|
|||||||
RedirectURI = proplists:get_value(<<"redirect_uri">>, Q, <<"">>),
|
RedirectURI = proplists:get_value(<<"redirect_uri">>, Q, <<"">>),
|
||||||
SScope = proplists:get_value(<<"scope">>, Q, <<"">>),
|
SScope = proplists:get_value(<<"scope">>, Q, <<"">>),
|
||||||
StringJID = proplists:get_value(<<"username">>, Q, <<"">>),
|
StringJID = proplists:get_value(<<"username">>, Q, <<"">>),
|
||||||
#jid{user = Username, server = Server} = jid:from_string(StringJID),
|
#jid{user = Username, server = Server} = jid:decode(StringJID),
|
||||||
Password = proplists:get_value(<<"password">>, Q, <<"">>),
|
Password = proplists:get_value(<<"password">>, Q, <<"">>),
|
||||||
State = proplists:get_value(<<"state">>, Q, <<"">>),
|
State = proplists:get_value(<<"state">>, Q, <<"">>),
|
||||||
Scope = str:tokens(SScope, <<" ">>),
|
Scope = str:tokens(SScope, <<" ">>),
|
||||||
@ -542,7 +542,7 @@ process(_Handlers,
|
|||||||
<<"password">> ->
|
<<"password">> ->
|
||||||
SScope = proplists:get_value(<<"scope">>, Q, <<"">>),
|
SScope = proplists:get_value(<<"scope">>, Q, <<"">>),
|
||||||
StringJID = proplists:get_value(<<"username">>, Q, <<"">>),
|
StringJID = proplists:get_value(<<"username">>, Q, <<"">>),
|
||||||
#jid{user = Username, server = Server} = jid:from_string(StringJID),
|
#jid{user = Username, server = Server} = jid:decode(StringJID),
|
||||||
Password = proplists:get_value(<<"password">>, Q, <<"">>),
|
Password = proplists:get_value(<<"password">>, Q, <<"">>),
|
||||||
Scope = str:tokens(SScope, <<" ">>),
|
Scope = str:tokens(SScope, <<" ">>),
|
||||||
TTL = proplists:get_value(<<"ttl">>, Q, <<"">>),
|
TTL = proplists:get_value(<<"ttl">>, Q, <<"">>),
|
||||||
|
@ -45,7 +45,7 @@ store(R) ->
|
|||||||
Path = path(<<"store">>),
|
Path = path(<<"store">>),
|
||||||
%% Retry 2 times, with a backoff of 500millisec
|
%% Retry 2 times, with a backoff of 500millisec
|
||||||
{User, Server} = R#oauth_token.us,
|
{User, Server} = R#oauth_token.us,
|
||||||
SJID = jid:to_string({User, Server, <<"">>}),
|
SJID = jid:encode({User, Server, <<"">>}),
|
||||||
case rest:with_retry(
|
case rest:with_retry(
|
||||||
post,
|
post,
|
||||||
[?MYNAME, Path, [],
|
[?MYNAME, Path, [],
|
||||||
@ -68,7 +68,7 @@ lookup(Token) ->
|
|||||||
2, 500) of
|
2, 500) of
|
||||||
{ok, 200, {Data}} ->
|
{ok, 200, {Data}} ->
|
||||||
SJID = proplists:get_value(<<"user">>, Data, <<>>),
|
SJID = proplists:get_value(<<"user">>, Data, <<>>),
|
||||||
JID = jid:from_string(SJID),
|
JID = jid:decode(SJID),
|
||||||
US = {JID#jid.luser, JID#jid.lserver},
|
US = {JID#jid.luser, JID#jid.lserver},
|
||||||
Scope = proplists:get_value(<<"scope">>, Data, []),
|
Scope = proplists:get_value(<<"scope">>, Data, []),
|
||||||
Expire = proplists:get_value(<<"expire">>, Data, 0),
|
Expire = proplists:get_value(<<"expire">>, Data, 0),
|
||||||
|
@ -44,7 +44,7 @@ init() ->
|
|||||||
store(R) ->
|
store(R) ->
|
||||||
Token = R#oauth_token.token,
|
Token = R#oauth_token.token,
|
||||||
{User, Server} = R#oauth_token.us,
|
{User, Server} = R#oauth_token.us,
|
||||||
SJID = jid:to_string({User, Server, <<"">>}),
|
SJID = jid:encode({User, Server, <<"">>}),
|
||||||
Scope = str:join(R#oauth_token.scope, <<" ">>),
|
Scope = str:join(R#oauth_token.scope, <<" ">>),
|
||||||
Expire = R#oauth_token.expire,
|
Expire = R#oauth_token.expire,
|
||||||
?SQL_UPSERT(
|
?SQL_UPSERT(
|
||||||
@ -61,7 +61,7 @@ lookup(Token) ->
|
|||||||
?SQL("select @(jid)s, @(scope)s, @(expire)d"
|
?SQL("select @(jid)s, @(scope)s, @(expire)d"
|
||||||
" from oauth_token where token=%(Token)s")) of
|
" from oauth_token where token=%(Token)s")) of
|
||||||
{selected, [{SJID, Scope, Expire}]} ->
|
{selected, [{SJID, Scope, Expire}]} ->
|
||||||
JID = jid:from_string(SJID),
|
JID = jid:decode(SJID),
|
||||||
US = {JID#jid.luser, JID#jid.lserver},
|
US = {JID#jid.luser, JID#jid.lserver},
|
||||||
#oauth_token{token = Token,
|
#oauth_token{token = Token,
|
||||||
us = US,
|
us = US,
|
||||||
|
@ -345,15 +345,15 @@ process_el({xmlstreamelement, #xmlel{name = <<"host">>,
|
|||||||
attrs = Attrs,
|
attrs = Attrs,
|
||||||
children = Els}}, State) ->
|
children = Els}}, State) ->
|
||||||
JIDS = fxml:get_attr_s(<<"jid">>, Attrs),
|
JIDS = fxml:get_attr_s(<<"jid">>, Attrs),
|
||||||
case jid:from_string(JIDS) of
|
try jid:decode(JIDS) of
|
||||||
#jid{lserver = S} ->
|
#jid{lserver = S} ->
|
||||||
case ejabberd_router:is_my_host(S) of
|
case ejabberd_router:is_my_host(S) of
|
||||||
true ->
|
true ->
|
||||||
process_users(Els, State#state{server = S});
|
process_users(Els, State#state{server = S});
|
||||||
false ->
|
false ->
|
||||||
stop("Unknown host: ~s", [S])
|
stop("Unknown host: ~s", [S])
|
||||||
end;
|
end
|
||||||
error ->
|
catch _:{bad_jid, _} ->
|
||||||
stop("Invalid 'jid': ~s", [JIDS])
|
stop("Invalid 'jid': ~s", [JIDS])
|
||||||
end;
|
end;
|
||||||
process_el({xmlstreamstart, <<"user">>, Attrs}, State = #state{server = S})
|
process_el({xmlstreamstart, <<"user">>, Attrs}, State = #state{server = S})
|
||||||
|
@ -96,7 +96,7 @@ route(#jid{} = From, #jid{} = To, #xmlel{} = El) ->
|
|||||||
catch _:{xmpp_codec, Why} ->
|
catch _:{xmpp_codec, Why} ->
|
||||||
?ERROR_MSG("failed to decode xml element ~p when "
|
?ERROR_MSG("failed to decode xml element ~p when "
|
||||||
"routing from ~s to ~s: ~s",
|
"routing from ~s to ~s: ~s",
|
||||||
[El, jid:to_string(From), jid:to_string(To),
|
[El, jid:encode(From), jid:encode(To),
|
||||||
xmpp:format_error(Why)])
|
xmpp:format_error(Why)])
|
||||||
end;
|
end;
|
||||||
route(#jid{} = From, #jid{} = To, Packet) ->
|
route(#jid{} = From, #jid{} = To, Packet) ->
|
||||||
|
@ -213,7 +213,7 @@ code_change(_OldVsn, State, _Extra) ->
|
|||||||
do_route(Domain, Destinations, Packet) ->
|
do_route(Domain, Destinations, Packet) ->
|
||||||
?DEBUG("route multicast:~n~s~nDomain: ~s~nDestinations: ~s~n",
|
?DEBUG("route multicast:~n~s~nDomain: ~s~nDestinations: ~s~n",
|
||||||
[xmpp:pp(Packet), Domain,
|
[xmpp:pp(Packet), Domain,
|
||||||
str:join([jid:to_string(To) || To <- Destinations], <<", ">>)]),
|
str:join([jid:encode(To) || To <- Destinations], <<", ">>)]),
|
||||||
%% Try to find an appropriate multicast service
|
%% Try to find an appropriate multicast service
|
||||||
case mnesia:dirty_read(route_multicast, Domain) of
|
case mnesia:dirty_read(route_multicast, Domain) of
|
||||||
|
|
||||||
|
@ -501,7 +501,7 @@ do_route(#jid{lresource = <<"">>} = To, Term) ->
|
|||||||
do_route(jid:replace_resource(To, R), Term)
|
do_route(jid:replace_resource(To, R), Term)
|
||||||
end, get_user_resources(To#jid.user, To#jid.server));
|
end, get_user_resources(To#jid.user, To#jid.server));
|
||||||
do_route(To, Term) ->
|
do_route(To, Term) ->
|
||||||
?DEBUG("broadcasting ~p to ~s", [Term, jid:to_string(To)]),
|
?DEBUG("broadcasting ~p to ~s", [Term, jid:encode(To)]),
|
||||||
{U, S, R} = jid:tolower(To),
|
{U, S, R} = jid:tolower(To),
|
||||||
Mod = get_sm_backend(S),
|
Mod = get_sm_backend(S),
|
||||||
case online(Mod:get_sessions(U, S, R)) of
|
case online(Mod:get_sessions(U, S, R)) of
|
||||||
|
@ -209,7 +209,7 @@ get_admin_jids() ->
|
|||||||
watchdog_admins,
|
watchdog_admins,
|
||||||
fun(JIDs) ->
|
fun(JIDs) ->
|
||||||
[jid:tolower(
|
[jid:tolower(
|
||||||
jid:from_string(
|
jid:decode(
|
||||||
iolist_to_binary(S))) || S <- JIDs]
|
iolist_to_binary(S))) || S <- JIDs]
|
||||||
end, []).
|
end, []).
|
||||||
|
|
||||||
@ -341,7 +341,7 @@ process_remote_command(_) -> throw(unknown_command).
|
|||||||
|
|
||||||
opt_type(watchdog_admins) ->
|
opt_type(watchdog_admins) ->
|
||||||
fun (JIDs) ->
|
fun (JIDs) ->
|
||||||
[jid:tolower(jid:from_string(iolist_to_binary(S)))
|
[jid:tolower(jid:decode(iolist_to_binary(S)))
|
||||||
|| S <- JIDs]
|
|| S <- JIDs]
|
||||||
end;
|
end;
|
||||||
opt_type(watchdog_large_heap) ->
|
opt_type(watchdog_large_heap) ->
|
||||||
|
@ -257,15 +257,16 @@ get_auth_admin(Auth, HostHTTP, RPath, Method) ->
|
|||||||
case Auth of
|
case Auth of
|
||||||
{SJID, Pass} ->
|
{SJID, Pass} ->
|
||||||
{HostOfRule, AccessRule} = get_acl_rule(RPath, Method),
|
{HostOfRule, AccessRule} = get_acl_rule(RPath, Method),
|
||||||
case jid:from_string(SJID) of
|
try jid:decode(SJID) of
|
||||||
error -> {unauthorized, <<"badformed-jid">>};
|
#jid{user = <<"">>, server = User} ->
|
||||||
#jid{user = <<"">>, server = User} ->
|
get_auth_account(HostOfRule, AccessRule, User, HostHTTP,
|
||||||
get_auth_account(HostOfRule, AccessRule, User, HostHTTP,
|
Pass);
|
||||||
Pass);
|
#jid{user = User, server = Server} ->
|
||||||
#jid{user = User, server = Server} ->
|
get_auth_account(HostOfRule, AccessRule, User, Server,
|
||||||
get_auth_account(HostOfRule, AccessRule, User, Server,
|
Pass)
|
||||||
Pass)
|
catch _:{bad_jid, _} ->
|
||||||
end;
|
{unauthorized, <<"badformed-jid">>}
|
||||||
|
end;
|
||||||
undefined -> {unauthorized, <<"no-auth-provided">>}
|
undefined -> {unauthorized, <<"no-auth-provided">>}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -1213,7 +1214,7 @@ string_to_spec(<<"server_regexp">>, Val) ->
|
|||||||
{server_regexp, Val};
|
{server_regexp, Val};
|
||||||
string_to_spec(<<"node_regexp">>, Val) ->
|
string_to_spec(<<"node_regexp">>, Val) ->
|
||||||
#jid{luser = U, lserver = S, resource = <<"">>} =
|
#jid{luser = U, lserver = S, resource = <<"">>} =
|
||||||
jid:from_string(Val),
|
jid:decode(Val),
|
||||||
{node_regexp, U, S};
|
{node_regexp, U, S};
|
||||||
string_to_spec(<<"user_glob">>, Val) ->
|
string_to_spec(<<"user_glob">>, Val) ->
|
||||||
string_to_spec2(user_glob, Val);
|
string_to_spec2(user_glob, Val);
|
||||||
@ -1221,7 +1222,7 @@ string_to_spec(<<"server_glob">>, Val) ->
|
|||||||
{server_glob, Val};
|
{server_glob, Val};
|
||||||
string_to_spec(<<"node_glob">>, Val) ->
|
string_to_spec(<<"node_glob">>, Val) ->
|
||||||
#jid{luser = U, lserver = S, resource = <<"">>} =
|
#jid{luser = U, lserver = S, resource = <<"">>} =
|
||||||
jid:from_string(Val),
|
jid:decode(Val),
|
||||||
{node_glob, U, S};
|
{node_glob, U, S};
|
||||||
string_to_spec(<<"all">>, _) -> all;
|
string_to_spec(<<"all">>, _) -> all;
|
||||||
string_to_spec(<<"raw">>, Val) ->
|
string_to_spec(<<"raw">>, Val) ->
|
||||||
@ -1231,7 +1232,7 @@ string_to_spec(<<"raw">>, Val) ->
|
|||||||
|
|
||||||
string_to_spec2(ACLName, Val) ->
|
string_to_spec2(ACLName, Val) ->
|
||||||
#jid{luser = U, lserver = S, resource = <<"">>} =
|
#jid{luser = U, lserver = S, resource = <<"">>} =
|
||||||
jid:from_string(Val),
|
jid:decode(Val),
|
||||||
case U of
|
case U of
|
||||||
<<"">> -> {ACLName, S};
|
<<"">> -> {ACLName, S};
|
||||||
_ -> {ACLName, {U, S}}
|
_ -> {ACLName, {U, S}}
|
||||||
@ -1447,16 +1448,17 @@ list_users_parse_query(Query, Host) ->
|
|||||||
lists:keysearch(<<"newusername">>, 1, Query),
|
lists:keysearch(<<"newusername">>, 1, Query),
|
||||||
{value, {_, Password}} =
|
{value, {_, Password}} =
|
||||||
lists:keysearch(<<"newuserpassword">>, 1, Query),
|
lists:keysearch(<<"newuserpassword">>, 1, Query),
|
||||||
case jid:from_string(<<Username/binary, "@",
|
try jid:decode(<<Username/binary, "@",
|
||||||
Host/binary>>)
|
Host/binary>>)
|
||||||
of
|
of
|
||||||
error -> error;
|
|
||||||
#jid{user = User, server = Server} ->
|
#jid{user = User, server = Server} ->
|
||||||
case ejabberd_auth:try_register(User, Server, Password)
|
case ejabberd_auth:try_register(User, Server, Password)
|
||||||
of
|
of
|
||||||
{error, _Reason} -> error;
|
{error, _Reason} -> error;
|
||||||
_ -> ok
|
_ -> ok
|
||||||
end
|
end
|
||||||
|
catch _:{bad_jid, _} ->
|
||||||
|
error
|
||||||
end;
|
end;
|
||||||
false -> nothing
|
false -> nothing
|
||||||
end.
|
end.
|
||||||
@ -1547,10 +1549,10 @@ get_lastactivity_menuitem_list(Server) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
us_to_list({User, Server}) ->
|
us_to_list({User, Server}) ->
|
||||||
jid:to_string({User, Server, <<"">>}).
|
jid:encode({User, Server, <<"">>}).
|
||||||
|
|
||||||
su_to_list({Server, User}) ->
|
su_to_list({Server, User}) ->
|
||||||
jid:to_string({User, Server, <<"">>}).
|
jid:encode({User, Server, <<"">>}).
|
||||||
|
|
||||||
%%%==================================
|
%%%==================================
|
||||||
%%%% get_stats
|
%%%% get_stats
|
||||||
|
13
src/jlib.erl
13
src/jlib.erl
@ -218,8 +218,8 @@ replace_from_to_attrs(From, To, Attrs) ->
|
|||||||
replace_from_to(From, To,
|
replace_from_to(From, To,
|
||||||
#xmlel{name = Name, attrs = Attrs, children = Els}) ->
|
#xmlel{name = Name, attrs = Attrs, children = Els}) ->
|
||||||
NewAttrs =
|
NewAttrs =
|
||||||
replace_from_to_attrs(jid:to_string(From),
|
replace_from_to_attrs(jid:encode(From),
|
||||||
jid:to_string(To), Attrs),
|
jid:encode(To), Attrs),
|
||||||
#xmlel{name = Name, attrs = NewAttrs, children = Els}.
|
#xmlel{name = Name, attrs = NewAttrs, children = Els}.
|
||||||
|
|
||||||
-spec replace_from_attrs(binary(), [attr()]) -> [attr()].
|
-spec replace_from_attrs(binary(), [attr()]) -> [attr()].
|
||||||
@ -232,7 +232,7 @@ replace_from_attrs(From, Attrs) ->
|
|||||||
|
|
||||||
replace_from(From,
|
replace_from(From,
|
||||||
#xmlel{name = Name, attrs = Attrs, children = Els}) ->
|
#xmlel{name = Name, attrs = Attrs, children = Els}) ->
|
||||||
NewAttrs = replace_from_attrs(jid:to_string(From),
|
NewAttrs = replace_from_attrs(jid:encode(From),
|
||||||
Attrs),
|
Attrs),
|
||||||
#xmlel{name = Name, attrs = NewAttrs, children = Els}.
|
#xmlel{name = Name, attrs = NewAttrs, children = Els}.
|
||||||
|
|
||||||
@ -261,12 +261,13 @@ split_jid(J) ->
|
|||||||
-spec string_to_jid(binary()) -> jid() | error.
|
-spec string_to_jid(binary()) -> jid() | error.
|
||||||
|
|
||||||
string_to_jid(S) ->
|
string_to_jid(S) ->
|
||||||
jid:from_string(S).
|
try jid:decode(S)
|
||||||
|
catch _:_ -> error end.
|
||||||
|
|
||||||
-spec jid_to_string(jid() | ljid()) -> binary().
|
-spec jid_to_string(jid() | ljid()) -> binary().
|
||||||
|
|
||||||
jid_to_string(J) ->
|
jid_to_string(J) ->
|
||||||
jid:to_string(J).
|
jid:encode(J).
|
||||||
|
|
||||||
-spec is_nodename(binary()) -> boolean().
|
-spec is_nodename(binary()) -> boolean().
|
||||||
|
|
||||||
@ -626,7 +627,7 @@ add_delay_info(El, From, Time, Desc) ->
|
|||||||
-> xmlel() | error.
|
-> xmlel() | error.
|
||||||
|
|
||||||
create_delay_tag(TimeStamp, FromJID, Desc) when is_tuple(FromJID) ->
|
create_delay_tag(TimeStamp, FromJID, Desc) when is_tuple(FromJID) ->
|
||||||
From = jid:to_string(FromJID),
|
From = jid:encode(FromJID),
|
||||||
Stamp = now_to_utc_string(TimeStamp, 3),
|
Stamp = now_to_utc_string(TimeStamp, 3),
|
||||||
Children = case Desc of
|
Children = case Desc of
|
||||||
<<"">> -> [];
|
<<"">> -> [];
|
||||||
|
@ -1009,10 +1009,10 @@ get_presence(U, S) ->
|
|||||||
OnlinePids = [Pid || Pid <- Pids, Pid=/=none],
|
OnlinePids = [Pid || Pid <- Pids, Pid=/=none],
|
||||||
case OnlinePids of
|
case OnlinePids of
|
||||||
[] ->
|
[] ->
|
||||||
{jid:to_string({U, S, <<>>}), <<"unavailable">>, <<"">>};
|
{jid:encode({U, S, <<>>}), <<"unavailable">>, <<"">>};
|
||||||
[SessionPid|_] ->
|
[SessionPid|_] ->
|
||||||
{_User, Resource, Show, Status} = get_presence(SessionPid),
|
{_User, Resource, Show, Status} = get_presence(SessionPid),
|
||||||
FullJID = jid:to_string({U, S, Resource}),
|
FullJID = jid:encode({U, S, Resource}),
|
||||||
{FullJID, Show, Status}
|
{FullJID, Show, Status}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -1238,7 +1238,7 @@ get_roster(User, Server) ->
|
|||||||
make_roster_xmlrpc(Roster) ->
|
make_roster_xmlrpc(Roster) ->
|
||||||
lists:foldl(
|
lists:foldl(
|
||||||
fun(Item, Res) ->
|
fun(Item, Res) ->
|
||||||
JIDS = jid:to_string(Item#roster.jid),
|
JIDS = jid:encode(Item#roster.jid),
|
||||||
Nick = Item#roster.name,
|
Nick = Item#roster.name,
|
||||||
Subs = atom_to_list(Item#roster.subscription),
|
Subs = atom_to_list(Item#roster.subscription),
|
||||||
Ask = atom_to_list(Item#roster.ask),
|
Ask = atom_to_list(Item#roster.ask),
|
||||||
@ -1418,7 +1418,7 @@ btl(B) -> binary_to_list(B).
|
|||||||
|
|
||||||
srg_get_members(Group, Host) ->
|
srg_get_members(Group, Host) ->
|
||||||
Members = mod_shared_roster:get_group_explicit_users(Host,Group),
|
Members = mod_shared_roster:get_group_explicit_users(Host,Group),
|
||||||
[jid:to_string(jid:make(MUser, MServer))
|
[jid:encode(jid:make(MUser, MServer))
|
||||||
|| {MUser, MServer} <- Members].
|
|| {MUser, MServer} <- Members].
|
||||||
|
|
||||||
srg_user_add(User, Host, Group, GroupHost) ->
|
srg_user_add(User, Host, Group, GroupHost) ->
|
||||||
@ -1437,8 +1437,8 @@ srg_user_del(User, Host, Group, GroupHost) ->
|
|||||||
%% @doc Send a message to a Jabber account.
|
%% @doc Send a message to a Jabber account.
|
||||||
%% @spec (Type::binary(), From::binary(), To::binary(), Subject::binary(), Body::binary()) -> ok
|
%% @spec (Type::binary(), From::binary(), To::binary(), Subject::binary(), Body::binary()) -> ok
|
||||||
send_message(Type, From, To, Subject, Body) ->
|
send_message(Type, From, To, Subject, Body) ->
|
||||||
FromJID = jid:from_string(From),
|
FromJID = jid:decode(From),
|
||||||
ToJID = jid:from_string(To),
|
ToJID = jid:decode(To),
|
||||||
Packet = build_packet(Type, Subject, Body),
|
Packet = build_packet(Type, Subject, Body),
|
||||||
ejabberd_router:route(xmpp:set_from_to(Packet, FromJID, ToJID)).
|
ejabberd_router:route(xmpp:set_from_to(Packet, FromJID, ToJID)).
|
||||||
|
|
||||||
@ -1450,8 +1450,8 @@ build_packet(Type, Subject, Body) ->
|
|||||||
send_stanza(FromString, ToString, Stanza) ->
|
send_stanza(FromString, ToString, Stanza) ->
|
||||||
try
|
try
|
||||||
#xmlel{} = El = fxml_stream:parse_element(Stanza),
|
#xmlel{} = El = fxml_stream:parse_element(Stanza),
|
||||||
#jid{} = From = jid:from_string(FromString),
|
From = jid:decode(FromString),
|
||||||
#jid{} = To = jid:from_string(ToString),
|
To = jid:decode(ToString),
|
||||||
Pkt = xmpp:decode(El, ?NS_CLIENT, [ignore_els]),
|
Pkt = xmpp:decode(El, ?NS_CLIENT, [ignore_els]),
|
||||||
ejabberd_router:route(xmpp:set_from_to(Pkt, From, To))
|
ejabberd_router:route(xmpp:set_from_to(Pkt, From, To))
|
||||||
catch _:{xmpp_codec, Why} ->
|
catch _:{xmpp_codec, Why} ->
|
||||||
@ -1460,7 +1460,8 @@ send_stanza(FromString, ToString, Stanza) ->
|
|||||||
_:{badmatch, {error, Why}} ->
|
_:{badmatch, {error, Why}} ->
|
||||||
io:format("invalid xml: ~p~n", [Why]),
|
io:format("invalid xml: ~p~n", [Why]),
|
||||||
{error, Why};
|
{error, Why};
|
||||||
_:{badmatch, error} ->
|
_:{bad_jid, S} ->
|
||||||
|
io:format("malformed JID: ~s~n", [S]),
|
||||||
{error, "JID malformed"}
|
{error, "JID malformed"}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -1619,7 +1620,7 @@ decide_rip_jid({UName, UServer, _UResource}, Match_list) ->
|
|||||||
decide_rip_jid({UName, UServer}, Match_list) ->
|
decide_rip_jid({UName, UServer}, Match_list) ->
|
||||||
lists:any(
|
lists:any(
|
||||||
fun(Match_string) ->
|
fun(Match_string) ->
|
||||||
MJID = jid:from_string(list_to_binary(Match_string)),
|
MJID = jid:decode(list_to_binary(Match_string)),
|
||||||
MName = MJID#jid.luser,
|
MName = MJID#jid.luser,
|
||||||
MServer = MJID#jid.lserver,
|
MServer = MJID#jid.lserver,
|
||||||
Is_server = is_glob_match(UServer, MServer),
|
Is_server = is_glob_match(UServer, MServer),
|
||||||
|
@ -241,7 +241,7 @@ filter_presence({#presence{meta = #{csi_resend := true}}, _} = Acc) ->
|
|||||||
filter_presence({#presence{to = To, type = Type} = Pres,
|
filter_presence({#presence{to = To, type = Type} = Pres,
|
||||||
#{csi_state := inactive} = C2SState})
|
#{csi_state := inactive} = C2SState})
|
||||||
when Type == available; Type == unavailable ->
|
when Type == available; Type == unavailable ->
|
||||||
?DEBUG("Got availability presence stanza for ~s", [jid:to_string(To)]),
|
?DEBUG("Got availability presence stanza for ~s", [jid:encode(To)]),
|
||||||
enqueue_stanza(presence, Pres, C2SState);
|
enqueue_stanza(presence, Pres, C2SState);
|
||||||
filter_presence(Acc) ->
|
filter_presence(Acc) ->
|
||||||
Acc.
|
Acc.
|
||||||
@ -261,7 +261,7 @@ filter_chat_states({#message{from = From, to = To} = Msg,
|
|||||||
Acc;
|
Acc;
|
||||||
_ ->
|
_ ->
|
||||||
?DEBUG("Got standalone chat state notification for ~s",
|
?DEBUG("Got standalone chat state notification for ~s",
|
||||||
[jid:to_string(To)]),
|
[jid:encode(To)]),
|
||||||
enqueue_stanza(chatstate, Msg, C2SState)
|
enqueue_stanza(chatstate, Msg, C2SState)
|
||||||
end;
|
end;
|
||||||
false ->
|
false ->
|
||||||
@ -279,7 +279,7 @@ filter_pep({#message{to = To} = Msg,
|
|||||||
undefined ->
|
undefined ->
|
||||||
Acc;
|
Acc;
|
||||||
Node ->
|
Node ->
|
||||||
?DEBUG("Got PEP notification for ~s", [jid:to_string(To)]),
|
?DEBUG("Got PEP notification for ~s", [jid:encode(To)]),
|
||||||
enqueue_stanza({pep, Node}, Msg, C2SState)
|
enqueue_stanza({pep, Node}, Msg, C2SState)
|
||||||
end;
|
end;
|
||||||
filter_pep(Acc) ->
|
filter_pep(Acc) ->
|
||||||
@ -291,7 +291,7 @@ filter_other({Stanza, #{jid := JID} = C2SState} = Acc) when ?is_stanza(Stanza) -
|
|||||||
#{csi_resend := true} ->
|
#{csi_resend := true} ->
|
||||||
Acc;
|
Acc;
|
||||||
_ ->
|
_ ->
|
||||||
?DEBUG("Won't add stanza for ~s to CSI queue", [jid:to_string(JID)]),
|
?DEBUG("Won't add stanza for ~s to CSI queue", [jid:encode(JID)]),
|
||||||
From = xmpp:get_from(Stanza),
|
From = xmpp:get_from(Stanza),
|
||||||
C2SState1 = dequeue_sender(From, C2SState),
|
C2SState1 = dequeue_sender(From, C2SState),
|
||||||
{Stanza, C2SState1}
|
{Stanza, C2SState1}
|
||||||
@ -331,7 +331,7 @@ enqueue_stanza(_Type, Stanza, State) ->
|
|||||||
dequeue_sender(#jid{luser = U, lserver = S},
|
dequeue_sender(#jid{luser = U, lserver = S},
|
||||||
#{csi_queue := Q, jid := JID} = C2SState) ->
|
#{csi_queue := Q, jid := JID} = C2SState) ->
|
||||||
?DEBUG("Flushing packets of ~s@~s from CSI queue of ~s",
|
?DEBUG("Flushing packets of ~s@~s from CSI queue of ~s",
|
||||||
[U, S, jid:to_string(JID)]),
|
[U, S, jid:encode(JID)]),
|
||||||
case queue_take({U, S}, Q) of
|
case queue_take({U, S}, Q) of
|
||||||
{Stanzas, Q1} ->
|
{Stanzas, Q1} ->
|
||||||
C2SState1 = flush_stanzas(C2SState, Stanzas),
|
C2SState1 = flush_stanzas(C2SState, Stanzas),
|
||||||
@ -342,7 +342,7 @@ dequeue_sender(#jid{luser = U, lserver = S},
|
|||||||
|
|
||||||
-spec flush_queue(c2s_state()) -> c2s_state().
|
-spec flush_queue(c2s_state()) -> c2s_state().
|
||||||
flush_queue(#{csi_queue := Q, jid := JID} = C2SState) ->
|
flush_queue(#{csi_queue := Q, jid := JID} = C2SState) ->
|
||||||
?DEBUG("Flushing CSI queue of ~s", [jid:to_string(JID)]),
|
?DEBUG("Flushing CSI queue of ~s", [jid:encode(JID)]),
|
||||||
C2SState1 = flush_stanzas(C2SState, queue_to_list(Q)),
|
C2SState1 = flush_stanzas(C2SState, queue_to_list(Q)),
|
||||||
C2SState1#{csi_queue => queue_new()}.
|
C2SState1#{csi_queue => queue_new()}.
|
||||||
|
|
||||||
|
@ -396,7 +396,7 @@ get_permission_level(JID) ->
|
|||||||
allow ->
|
allow ->
|
||||||
PermLev = get_permission_level(From),
|
PermLev = get_permission_level(From),
|
||||||
case get_local_items({PermLev, LServer}, LNode,
|
case get_local_items({PermLev, LServer}, LNode,
|
||||||
jid:to_string(To), Lang)
|
jid:encode(To), Lang)
|
||||||
of
|
of
|
||||||
{result, Res} -> {result, Res};
|
{result, Res} -> {result, Res};
|
||||||
{error, Error} -> {error, Error}
|
{error, Error} -> {error, Error}
|
||||||
@ -418,7 +418,7 @@ get_local_items(Acc, From, #jid{lserver = LServer} = To,
|
|||||||
allow ->
|
allow ->
|
||||||
PermLev = get_permission_level(From),
|
PermLev = get_permission_level(From),
|
||||||
case get_local_items({PermLev, LServer}, [],
|
case get_local_items({PermLev, LServer}, [],
|
||||||
jid:to_string(To), Lang)
|
jid:encode(To), Lang)
|
||||||
of
|
of
|
||||||
{result, Res} -> {result, Items ++ Res};
|
{result, Res} -> {result, Items ++ Res};
|
||||||
{error, _Error} -> {result, Items}
|
{error, _Error} -> {result, Items}
|
||||||
@ -1522,7 +1522,7 @@ set_form(From, Host, ?NS_ADMINL(<<"add-user">>), _Lang,
|
|||||||
AccountString = get_value(<<"accountjid">>, XData),
|
AccountString = get_value(<<"accountjid">>, XData),
|
||||||
Password = get_value(<<"password">>, XData),
|
Password = get_value(<<"password">>, XData),
|
||||||
Password = get_value(<<"password-verify">>, XData),
|
Password = get_value(<<"password-verify">>, XData),
|
||||||
AccountJID = jid:from_string(AccountString),
|
AccountJID = jid:decode(AccountString),
|
||||||
User = AccountJID#jid.luser,
|
User = AccountJID#jid.luser,
|
||||||
Server = AccountJID#jid.lserver,
|
Server = AccountJID#jid.lserver,
|
||||||
true = lists:member(Server, ?MYHOSTS),
|
true = lists:member(Server, ?MYHOSTS),
|
||||||
@ -1536,7 +1536,7 @@ set_form(From, Host, ?NS_ADMINL(<<"delete-user">>),
|
|||||||
XData),
|
XData),
|
||||||
[_ | _] = AccountStringList,
|
[_ | _] = AccountStringList,
|
||||||
ASL2 = lists:map(fun (AccountString) ->
|
ASL2 = lists:map(fun (AccountString) ->
|
||||||
JID = jid:from_string(AccountString),
|
JID = jid:decode(AccountString),
|
||||||
User = JID#jid.luser,
|
User = JID#jid.luser,
|
||||||
Server = JID#jid.lserver,
|
Server = JID#jid.lserver,
|
||||||
true = Server == Host orelse
|
true = Server == Host orelse
|
||||||
@ -1551,7 +1551,7 @@ set_form(From, Host, ?NS_ADMINL(<<"delete-user">>),
|
|||||||
set_form(From, Host, ?NS_ADMINL(<<"end-user-session">>),
|
set_form(From, Host, ?NS_ADMINL(<<"end-user-session">>),
|
||||||
Lang, XData) ->
|
Lang, XData) ->
|
||||||
AccountString = get_value(<<"accountjid">>, XData),
|
AccountString = get_value(<<"accountjid">>, XData),
|
||||||
JID = jid:from_string(AccountString),
|
JID = jid:decode(AccountString),
|
||||||
LUser = JID#jid.luser,
|
LUser = JID#jid.luser,
|
||||||
LServer = JID#jid.lserver,
|
LServer = JID#jid.lserver,
|
||||||
true = LServer == Host orelse
|
true = LServer == Host orelse
|
||||||
@ -1587,7 +1587,7 @@ set_form(From, Host, ?NS_ADMINL(<<"end-user-session">>),
|
|||||||
set_form(From, Host,
|
set_form(From, Host,
|
||||||
?NS_ADMINL(<<"get-user-password">>), Lang, XData) ->
|
?NS_ADMINL(<<"get-user-password">>), Lang, XData) ->
|
||||||
AccountString = get_value(<<"accountjid">>, XData),
|
AccountString = get_value(<<"accountjid">>, XData),
|
||||||
JID = jid:from_string(AccountString),
|
JID = jid:decode(AccountString),
|
||||||
User = JID#jid.luser,
|
User = JID#jid.luser,
|
||||||
Server = JID#jid.lserver,
|
Server = JID#jid.lserver,
|
||||||
true = Server == Host orelse
|
true = Server == Host orelse
|
||||||
@ -1605,7 +1605,7 @@ set_form(From, Host,
|
|||||||
?NS_ADMINL(<<"change-user-password">>), _Lang, XData) ->
|
?NS_ADMINL(<<"change-user-password">>), _Lang, XData) ->
|
||||||
AccountString = get_value(<<"accountjid">>, XData),
|
AccountString = get_value(<<"accountjid">>, XData),
|
||||||
Password = get_value(<<"password">>, XData),
|
Password = get_value(<<"password">>, XData),
|
||||||
JID = jid:from_string(AccountString),
|
JID = jid:decode(AccountString),
|
||||||
User = JID#jid.luser,
|
User = JID#jid.luser,
|
||||||
Server = JID#jid.lserver,
|
Server = JID#jid.lserver,
|
||||||
true = Server == Host orelse
|
true = Server == Host orelse
|
||||||
@ -1616,7 +1616,7 @@ set_form(From, Host,
|
|||||||
set_form(From, Host,
|
set_form(From, Host,
|
||||||
?NS_ADMINL(<<"get-user-lastlogin">>), Lang, XData) ->
|
?NS_ADMINL(<<"get-user-lastlogin">>), Lang, XData) ->
|
||||||
AccountString = get_value(<<"accountjid">>, XData),
|
AccountString = get_value(<<"accountjid">>, XData),
|
||||||
JID = jid:from_string(AccountString),
|
JID = jid:decode(AccountString),
|
||||||
User = JID#jid.luser,
|
User = JID#jid.luser,
|
||||||
Server = JID#jid.lserver,
|
Server = JID#jid.lserver,
|
||||||
true = Server == Host orelse
|
true = Server == Host orelse
|
||||||
@ -1648,7 +1648,7 @@ set_form(From, Host,
|
|||||||
set_form(From, Host, ?NS_ADMINL(<<"user-stats">>), Lang,
|
set_form(From, Host, ?NS_ADMINL(<<"user-stats">>), Lang,
|
||||||
XData) ->
|
XData) ->
|
||||||
AccountString = get_value(<<"accountjid">>, XData),
|
AccountString = get_value(<<"accountjid">>, XData),
|
||||||
JID = jid:from_string(AccountString),
|
JID = jid:decode(AccountString),
|
||||||
User = JID#jid.luser,
|
User = JID#jid.luser,
|
||||||
Server = JID#jid.lserver,
|
Server = JID#jid.lserver,
|
||||||
true = Server == Host orelse
|
true = Server == Host orelse
|
||||||
|
@ -196,7 +196,7 @@ do_client_version(enabled, From, To) ->
|
|||||||
#iq{to = To, from = From2,
|
#iq{to = To, from = From2,
|
||||||
id = ID, type = result, sub_els = [#version{} = V]}} ->
|
id = ID, type = result, sub_els = [#version{} = V]}} ->
|
||||||
?INFO_MSG("Version of the client ~s:~n~s",
|
?INFO_MSG("Version of the client ~s:~n~s",
|
||||||
[jid:to_string(To), xmpp:pp(V)])
|
[jid:encode(To), xmpp:pp(V)])
|
||||||
after 5000 -> % Timeout in miliseconds: 5 seconds
|
after 5000 -> % Timeout in miliseconds: 5 seconds
|
||||||
[]
|
[]
|
||||||
end.
|
end.
|
||||||
|
@ -139,16 +139,16 @@ depends(_Host, _Opts) ->
|
|||||||
extract_auth(#request{auth = HTTPAuth, ip = {IP, _}}) ->
|
extract_auth(#request{auth = HTTPAuth, ip = {IP, _}}) ->
|
||||||
Info = case HTTPAuth of
|
Info = case HTTPAuth of
|
||||||
{SJID, Pass} ->
|
{SJID, Pass} ->
|
||||||
case jid:from_string(SJID) of
|
try jid:decode(SJID) of
|
||||||
#jid{luser = User, lserver = Server} ->
|
#jid{luser = User, lserver = Server} ->
|
||||||
case ejabberd_auth:check_password(User, <<"">>, Server, Pass) of
|
case ejabberd_auth:check_password(User, <<"">>, Server, Pass) of
|
||||||
true ->
|
true ->
|
||||||
#{usr => {User, Server, <<"">>}, caller_server => Server};
|
#{usr => {User, Server, <<"">>}, caller_server => Server};
|
||||||
false ->
|
false ->
|
||||||
{error, invalid_auth}
|
{error, invalid_auth}
|
||||||
end;
|
end
|
||||||
_ ->
|
catch _:{bad_jid, _} ->
|
||||||
{error, invalid_auth}
|
{error, invalid_auth}
|
||||||
end;
|
end;
|
||||||
{oauth, Token, _} ->
|
{oauth, Token, _} ->
|
||||||
case ejabberd_oauth:check_token(Token) of
|
case ejabberd_oauth:check_token(Token) of
|
||||||
|
@ -542,7 +542,7 @@ process_iq(#iq{type = get, lang = Lang, from = From,
|
|||||||
end;
|
end;
|
||||||
deny ->
|
deny ->
|
||||||
?DEBUG("Denying HTTP upload slot request from ~s",
|
?DEBUG("Denying HTTP upload slot request from ~s",
|
||||||
[jid:to_string(From)]),
|
[jid:encode(From)]),
|
||||||
Txt = <<"Denied by ACL">>,
|
Txt = <<"Denied by ACL">>,
|
||||||
xmpp:make_error(IQ, xmpp:err_forbidden(Txt, Lang))
|
xmpp:make_error(IQ, xmpp:err_forbidden(Txt, Lang))
|
||||||
end;
|
end;
|
||||||
@ -559,7 +559,7 @@ create_slot(#state{service_url = undefined, max_size = MaxSize},
|
|||||||
Size > MaxSize ->
|
Size > MaxSize ->
|
||||||
Text = {<<"File larger than ~w bytes">>, [MaxSize]},
|
Text = {<<"File larger than ~w bytes">>, [MaxSize]},
|
||||||
?INFO_MSG("Rejecting file ~s from ~s (too large: ~B bytes)",
|
?INFO_MSG("Rejecting file ~s from ~s (too large: ~B bytes)",
|
||||||
[File, jid:to_string(JID), Size]),
|
[File, jid:encode(JID), Size]),
|
||||||
{error, xmpp:err_not_acceptable(Text, Lang)};
|
{error, xmpp:err_not_acceptable(Text, Lang)};
|
||||||
create_slot(#state{service_url = undefined,
|
create_slot(#state{service_url = undefined,
|
||||||
jid_in_url = JIDinURL,
|
jid_in_url = JIDinURL,
|
||||||
@ -575,7 +575,7 @@ create_slot(#state{service_url = undefined,
|
|||||||
RandStr = make_rand_string(SecretLength),
|
RandStr = make_rand_string(SecretLength),
|
||||||
FileStr = make_file_string(File),
|
FileStr = make_file_string(File),
|
||||||
?INFO_MSG("Got HTTP upload slot for ~s (file: ~s)",
|
?INFO_MSG("Got HTTP upload slot for ~s (file: ~s)",
|
||||||
[jid:to_string(JID), File]),
|
[jid:encode(JID), File]),
|
||||||
{ok, [UserStr, RandStr, FileStr]};
|
{ok, [UserStr, RandStr, FileStr]};
|
||||||
deny ->
|
deny ->
|
||||||
{error, xmpp:err_service_unavailable()};
|
{error, xmpp:err_service_unavailable()};
|
||||||
@ -589,7 +589,7 @@ create_slot(#state{service_url = ServiceURL},
|
|||||||
HttpOptions = [{timeout, ?SERVICE_REQUEST_TIMEOUT}],
|
HttpOptions = [{timeout, ?SERVICE_REQUEST_TIMEOUT}],
|
||||||
SizeStr = integer_to_binary(Size),
|
SizeStr = integer_to_binary(Size),
|
||||||
GetRequest = binary_to_list(ServiceURL) ++
|
GetRequest = binary_to_list(ServiceURL) ++
|
||||||
"?jid=" ++ ?URL_ENC(jid:to_string({U, S, <<"">>})) ++
|
"?jid=" ++ ?URL_ENC(jid:encode({U, S, <<"">>})) ++
|
||||||
"&name=" ++ ?URL_ENC(File) ++
|
"&name=" ++ ?URL_ENC(File) ++
|
||||||
"&size=" ++ ?URL_ENC(SizeStr) ++
|
"&size=" ++ ?URL_ENC(SizeStr) ++
|
||||||
"&content_type=" ++ ?URL_ENC(ContentType),
|
"&content_type=" ++ ?URL_ENC(ContentType),
|
||||||
@ -599,33 +599,33 @@ create_slot(#state{service_url = ServiceURL},
|
|||||||
[<<"http", _/binary>> = PutURL,
|
[<<"http", _/binary>> = PutURL,
|
||||||
<<"http", _/binary>> = GetURL] ->
|
<<"http", _/binary>> = GetURL] ->
|
||||||
?INFO_MSG("Got HTTP upload slot for ~s (file: ~s)",
|
?INFO_MSG("Got HTTP upload slot for ~s (file: ~s)",
|
||||||
[jid:to_string(JID), File]),
|
[jid:encode(JID), File]),
|
||||||
{ok, PutURL, GetURL};
|
{ok, PutURL, GetURL};
|
||||||
Lines ->
|
Lines ->
|
||||||
?ERROR_MSG("Can't parse data received for ~s from <~s>: ~p",
|
?ERROR_MSG("Can't parse data received for ~s from <~s>: ~p",
|
||||||
[jid:to_string(JID), ServiceURL, Lines]),
|
[jid:encode(JID), ServiceURL, Lines]),
|
||||||
Txt = <<"Failed to parse HTTP response">>,
|
Txt = <<"Failed to parse HTTP response">>,
|
||||||
{error, xmpp:err_service_unavailable(Txt, Lang)}
|
{error, xmpp:err_service_unavailable(Txt, Lang)}
|
||||||
end;
|
end;
|
||||||
{ok, {402, _Body}} ->
|
{ok, {402, _Body}} ->
|
||||||
?INFO_MSG("Got status code 402 for ~s from <~s>",
|
?INFO_MSG("Got status code 402 for ~s from <~s>",
|
||||||
[jid:to_string(JID), ServiceURL]),
|
[jid:encode(JID), ServiceURL]),
|
||||||
{error, xmpp:err_resource_constraint()};
|
{error, xmpp:err_resource_constraint()};
|
||||||
{ok, {403, _Body}} ->
|
{ok, {403, _Body}} ->
|
||||||
?INFO_MSG("Got status code 403 for ~s from <~s>",
|
?INFO_MSG("Got status code 403 for ~s from <~s>",
|
||||||
[jid:to_string(JID), ServiceURL]),
|
[jid:encode(JID), ServiceURL]),
|
||||||
{error, xmpp:err_not_allowed()};
|
{error, xmpp:err_not_allowed()};
|
||||||
{ok, {413, _Body}} ->
|
{ok, {413, _Body}} ->
|
||||||
?INFO_MSG("Got status code 413 for ~s from <~s>",
|
?INFO_MSG("Got status code 413 for ~s from <~s>",
|
||||||
[jid:to_string(JID), ServiceURL]),
|
[jid:encode(JID), ServiceURL]),
|
||||||
{error, xmpp:err_not_acceptable()};
|
{error, xmpp:err_not_acceptable()};
|
||||||
{ok, {Code, _Body}} ->
|
{ok, {Code, _Body}} ->
|
||||||
?ERROR_MSG("Got unexpected status code for ~s from <~s>: ~B",
|
?ERROR_MSG("Got unexpected status code for ~s from <~s>: ~B",
|
||||||
[jid:to_string(JID), ServiceURL, Code]),
|
[jid:encode(JID), ServiceURL, Code]),
|
||||||
{error, xmpp:err_service_unavailable()};
|
{error, xmpp:err_service_unavailable()};
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
?ERROR_MSG("Error requesting upload slot for ~s from <~s>: ~p",
|
?ERROR_MSG("Error requesting upload slot for ~s from <~s>: ~p",
|
||||||
[jid:to_string(JID), ServiceURL, Reason]),
|
[jid:encode(JID), ServiceURL, Reason]),
|
||||||
{error, xmpp:err_service_unavailable()}
|
{error, xmpp:err_service_unavailable()}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -169,24 +169,24 @@ handle_cast({handle_slot_request, #jid{user = U, server = S} = JID, Path, Size},
|
|||||||
NewSize = case {HardQuota, SoftQuota} of
|
NewSize = case {HardQuota, SoftQuota} of
|
||||||
{0, 0} ->
|
{0, 0} ->
|
||||||
?DEBUG("No quota specified for ~s",
|
?DEBUG("No quota specified for ~s",
|
||||||
[jid:to_string(JID)]),
|
[jid:encode(JID)]),
|
||||||
undefined;
|
undefined;
|
||||||
{0, _} ->
|
{0, _} ->
|
||||||
?WARNING_MSG("No hard quota specified for ~s",
|
?WARNING_MSG("No hard quota specified for ~s",
|
||||||
[jid:to_string(JID)]),
|
[jid:encode(JID)]),
|
||||||
enforce_quota(Path, Size, OldSize, SoftQuota, SoftQuota);
|
enforce_quota(Path, Size, OldSize, SoftQuota, SoftQuota);
|
||||||
{_, 0} ->
|
{_, 0} ->
|
||||||
?WARNING_MSG("No soft quota specified for ~s",
|
?WARNING_MSG("No soft quota specified for ~s",
|
||||||
[jid:to_string(JID)]),
|
[jid:encode(JID)]),
|
||||||
enforce_quota(Path, Size, OldSize, HardQuota, HardQuota);
|
enforce_quota(Path, Size, OldSize, HardQuota, HardQuota);
|
||||||
_ when SoftQuota > HardQuota ->
|
_ when SoftQuota > HardQuota ->
|
||||||
?WARNING_MSG("Bad quota for ~s (soft: ~p, hard: ~p)",
|
?WARNING_MSG("Bad quota for ~s (soft: ~p, hard: ~p)",
|
||||||
[jid:to_string(JID),
|
[jid:encode(JID),
|
||||||
SoftQuota, HardQuota]),
|
SoftQuota, HardQuota]),
|
||||||
enforce_quota(Path, Size, OldSize, SoftQuota, SoftQuota);
|
enforce_quota(Path, Size, OldSize, SoftQuota, SoftQuota);
|
||||||
_ ->
|
_ ->
|
||||||
?DEBUG("Enforcing quota for ~s",
|
?DEBUG("Enforcing quota for ~s",
|
||||||
[jid:to_string(JID)]),
|
[jid:encode(JID)]),
|
||||||
enforce_quota(Path, Size, OldSize, SoftQuota, HardQuota)
|
enforce_quota(Path, Size, OldSize, SoftQuota, HardQuota)
|
||||||
end,
|
end,
|
||||||
NewDiskUsage = if is_integer(NewSize) ->
|
NewDiskUsage = if is_integer(NewSize) ->
|
||||||
|
@ -688,7 +688,7 @@ adhoc_join(From, To, #adhoc_command{lang = Lang, xdata = X} = Request) ->
|
|||||||
To#jid.server),
|
To#jid.server),
|
||||||
Reason = translate:translate(Lang, <<"Join the IRC channel here.">>),
|
Reason = translate:translate(Lang, <<"Join the IRC channel here.">>),
|
||||||
BodyTxt = {<<"Join the IRC channel in this Jabber ID: ~s">>,
|
BodyTxt = {<<"Join the IRC channel in this Jabber ID: ~s">>,
|
||||||
[jid:to_string(RoomJID)]},
|
[jid:encode(RoomJID)]},
|
||||||
Invite = #message{
|
Invite = #message{
|
||||||
from = RoomJID, to = From,
|
from = RoomJID, to = From,
|
||||||
body = xmpp:mk_text(BodyTxt, Lang),
|
body = xmpp:mk_text(BodyTxt, Lang),
|
||||||
@ -934,7 +934,7 @@ data_to_binary(JID, Data) ->
|
|||||||
?ERROR_MSG("failed to convert "
|
?ERROR_MSG("failed to convert "
|
||||||
"parameter ~p for user ~s",
|
"parameter ~p for user ~s",
|
||||||
[Param,
|
[Param,
|
||||||
jid:to_string(JID)]);
|
jid:encode(JID)]);
|
||||||
true ->
|
true ->
|
||||||
?ERROR_MSG("failed to convert "
|
?ERROR_MSG("failed to convert "
|
||||||
"parameter ~p",
|
"parameter ~p",
|
||||||
|
@ -971,7 +971,7 @@ process_userinfo(StateData, _Nick, From) ->
|
|||||||
send_text(StateData,
|
send_text(StateData,
|
||||||
io_lib:format("NOTICE ~s :\001USERINFO xmpp:~s\001\r\n",
|
io_lib:format("NOTICE ~s :\001USERINFO xmpp:~s\001\r\n",
|
||||||
[FromUser,
|
[FromUser,
|
||||||
jid:to_string(StateData#state.user)])).
|
jid:encode(StateData#state.user)])).
|
||||||
|
|
||||||
process_topic(StateData, Chan, From, String) ->
|
process_topic(StateData, Chan, From, String) ->
|
||||||
[FromUser | _] = str:tokens(From, <<"!">>),
|
[FromUser | _] = str:tokens(From, <<"!">>),
|
||||||
@ -1162,7 +1162,7 @@ iq_admin(StateData, Channel, From, _To,
|
|||||||
ejabberd_router:route_error(IQ, Error)
|
ejabberd_router:route_error(IQ, Error)
|
||||||
catch E:R ->
|
catch E:R ->
|
||||||
?ERROR_MSG("failed to process admin query from ~s: ~p",
|
?ERROR_MSG("failed to process admin query from ~s: ~p",
|
||||||
[jid:to_string(From), {E, {R, erlang:get_stacktrace()}}]),
|
[jid:encode(From), {E, {R, erlang:get_stacktrace()}}]),
|
||||||
ejabberd_router:route_error(
|
ejabberd_router:route_error(
|
||||||
IQ, xmpp:err_internal_server_error())
|
IQ, xmpp:err_internal_server_error())
|
||||||
end.
|
end.
|
||||||
|
@ -42,7 +42,7 @@ init(_Host, _Opts) ->
|
|||||||
ok.
|
ok.
|
||||||
|
|
||||||
get_data(LServer, Host, From) ->
|
get_data(LServer, Host, From) ->
|
||||||
SJID = jid:to_string(jid:tolower(jid:remove_resource(From))),
|
SJID = jid:encode(jid:tolower(jid:remove_resource(From))),
|
||||||
case catch ejabberd_sql:sql_query(
|
case catch ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(data)s from irc_custom"
|
?SQL("select @(data)s from irc_custom"
|
||||||
@ -54,7 +54,7 @@ get_data(LServer, Host, From) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
set_data(LServer, Host, From, Data) ->
|
set_data(LServer, Host, From, Data) ->
|
||||||
SJID = jid:to_string(jid:tolower(jid:remove_resource(From))),
|
SJID = jid:encode(jid:tolower(jid:remove_resource(From))),
|
||||||
SData = jlib:term_to_expr(Data),
|
SData = jlib:term_to_expr(Data),
|
||||||
F = fun () ->
|
F = fun () ->
|
||||||
?SQL_UPSERT_T(
|
?SQL_UPSERT_T(
|
||||||
@ -72,7 +72,7 @@ export(_Server) ->
|
|||||||
data = Data}) ->
|
data = Data}) ->
|
||||||
case str:suffix(Host, IRCHost) of
|
case str:suffix(Host, IRCHost) of
|
||||||
true ->
|
true ->
|
||||||
SJID = jid:to_string(jid:make(U, S)),
|
SJID = jid:encode(jid:make(U, S)),
|
||||||
SData = jlib:term_to_expr(Data),
|
SData = jlib:term_to_expr(Data),
|
||||||
[?SQL("delete from irc_custom"
|
[?SQL("delete from irc_custom"
|
||||||
" where jid=%(SJID)s and host=%(IRCHost)s;"),
|
" where jid=%(SJID)s and host=%(IRCHost)s;"),
|
||||||
@ -86,7 +86,7 @@ export(_Server) ->
|
|||||||
import(_LServer) ->
|
import(_LServer) ->
|
||||||
[{<<"select jid, host, data from irc_custom;">>,
|
[{<<"select jid, host, data from irc_custom;">>,
|
||||||
fun([SJID, IRCHost, SData]) ->
|
fun([SJID, IRCHost, SData]) ->
|
||||||
#jid{luser = U, lserver = S} = jid:from_string(SJID),
|
#jid{luser = U, lserver = S} = jid:decode(SJID),
|
||||||
Data = ejabberd_sql:decode_term(SData),
|
Data = ejabberd_sql:decode_term(SData),
|
||||||
#irc_custom{us_host = {{U, S}, IRCHost},
|
#irc_custom{us_host = {{U, S}, IRCHost},
|
||||||
data = Data}
|
data = Data}
|
||||||
|
@ -889,7 +889,7 @@ msg_to_el(#archive_msg{timestamp = TS, packet = El, nick = Nick,
|
|||||||
catch _:{xmpp_codec, Why} ->
|
catch _:{xmpp_codec, Why} ->
|
||||||
?ERROR_MSG("Failed to decode raw element ~p from message "
|
?ERROR_MSG("Failed to decode raw element ~p from message "
|
||||||
"archive of user ~s: ~s",
|
"archive of user ~s: ~s",
|
||||||
[El, jid:to_string(JidArchive), xmpp:format_error(Why)]),
|
[El, jid:encode(JidArchive), xmpp:format_error(Why)]),
|
||||||
{error, invalid_xml}
|
{error, invalid_xml}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ remove_user(LUser, LServer) ->
|
|||||||
?SQL("delete from archive_prefs where username=%(LUser)s")).
|
?SQL("delete from archive_prefs where username=%(LUser)s")).
|
||||||
|
|
||||||
remove_room(LServer, LName, LHost) ->
|
remove_room(LServer, LName, LHost) ->
|
||||||
LUser = jid:to_string({LName, LHost, <<>>}),
|
LUser = jid:encode({LName, LHost, <<>>}),
|
||||||
remove_user(LUser, LServer).
|
remove_user(LUser, LServer).
|
||||||
|
|
||||||
delete_old_messages(ServerHost, TimeStamp, Type) ->
|
delete_old_messages(ServerHost, TimeStamp, Type) ->
|
||||||
@ -74,12 +74,12 @@ store(Pkt, LServer, {LUser, LHost}, Type, Peer, Nick, _Dir) ->
|
|||||||
ID = integer_to_binary(TSinteger),
|
ID = integer_to_binary(TSinteger),
|
||||||
SUser = case Type of
|
SUser = case Type of
|
||||||
chat -> LUser;
|
chat -> LUser;
|
||||||
groupchat -> jid:to_string({LUser, LHost, <<>>})
|
groupchat -> jid:encode({LUser, LHost, <<>>})
|
||||||
end,
|
end,
|
||||||
BarePeer = jid:to_string(
|
BarePeer = jid:encode(
|
||||||
jid:tolower(
|
jid:tolower(
|
||||||
jid:remove_resource(Peer))),
|
jid:remove_resource(Peer))),
|
||||||
LPeer = jid:to_string(
|
LPeer = jid:encode(
|
||||||
jid:tolower(Peer)),
|
jid:tolower(Peer)),
|
||||||
XML = fxml:element_to_binary(Pkt),
|
XML = fxml:element_to_binary(Pkt),
|
||||||
Body = fxml:get_subtag_cdata(Pkt, <<"body">>),
|
Body = fxml:get_subtag_cdata(Pkt, <<"body">>),
|
||||||
@ -143,7 +143,7 @@ select(LServer, JidRequestor, #jid{luser = LUser} = JidArchive,
|
|||||||
MAMQuery, RSM, MsgType) ->
|
MAMQuery, RSM, MsgType) ->
|
||||||
User = case MsgType of
|
User = case MsgType of
|
||||||
chat -> LUser;
|
chat -> LUser;
|
||||||
{groupchat, _Role, _MUCState} -> jid:to_string(JidArchive)
|
{groupchat, _Role, _MUCState} -> jid:encode(JidArchive)
|
||||||
end,
|
end,
|
||||||
{Query, CountQuery} = make_sql_query(User, LServer, MAMQuery, RSM),
|
{Query, CountQuery} = make_sql_query(User, LServer, MAMQuery, RSM),
|
||||||
% TODO from XEP-0313 v0.2: "To conserve resources, a server MAY place a
|
% TODO from XEP-0313 v0.2: "To conserve resources, a server MAY place a
|
||||||
@ -228,11 +228,11 @@ make_sql_query(User, LServer, MAMQuery, RSM) ->
|
|||||||
WithClause = case catch jid:tolower(With) of
|
WithClause = case catch jid:tolower(With) of
|
||||||
{_, _, <<>>} ->
|
{_, _, <<>>} ->
|
||||||
[<<" and bare_peer='">>,
|
[<<" and bare_peer='">>,
|
||||||
Escape(jid:to_string(With)),
|
Escape(jid:encode(With)),
|
||||||
<<"'">>];
|
<<"'">>];
|
||||||
{_, _, _} ->
|
{_, _, _} ->
|
||||||
[<<" and peer='">>,
|
[<<" and peer='">>,
|
||||||
Escape(jid:to_string(With)),
|
Escape(jid:encode(With)),
|
||||||
<<"'">>];
|
<<"'">>];
|
||||||
_ ->
|
_ ->
|
||||||
[]
|
[]
|
||||||
@ -314,8 +314,8 @@ make_archive_el(TS, XML, Peer, Kind, Nick, MsgType, JidRequestor, JidArchive) ->
|
|||||||
#xmlel{} = El ->
|
#xmlel{} = El ->
|
||||||
try binary_to_integer(TS) of
|
try binary_to_integer(TS) of
|
||||||
TSInt ->
|
TSInt ->
|
||||||
case jid:from_string(Peer) of
|
try jid:decode(Peer) of
|
||||||
#jid{} = PeerJID ->
|
PeerJID ->
|
||||||
Now = usec_to_now(TSInt),
|
Now = usec_to_now(TSInt),
|
||||||
PeerLJID = jid:tolower(PeerJID),
|
PeerLJID = jid:tolower(PeerJID),
|
||||||
T = case Kind of
|
T = case Kind of
|
||||||
@ -330,24 +330,24 @@ make_archive_el(TS, XML, Peer, Kind, Nick, MsgType, JidRequestor, JidArchive) ->
|
|||||||
type = T,
|
type = T,
|
||||||
nick = Nick,
|
nick = Nick,
|
||||||
peer = PeerLJID},
|
peer = PeerLJID},
|
||||||
MsgType, JidRequestor, JidArchive);
|
MsgType, JidRequestor, JidArchive)
|
||||||
error ->
|
catch _:{bad_jid, _} ->
|
||||||
?ERROR_MSG("Malformed 'peer' field with value "
|
?ERROR_MSG("Malformed 'peer' field with value "
|
||||||
"'~s' detected for user ~s in table "
|
"'~s' detected for user ~s in table "
|
||||||
"'archive': invalid JID",
|
"'archive': invalid JID",
|
||||||
[Peer, jid:to_string(JidArchive)]),
|
[Peer, jid:encode(JidArchive)]),
|
||||||
{error, invalid_jid}
|
{error, invalid_jid}
|
||||||
end
|
end
|
||||||
catch _:_ ->
|
catch _:_ ->
|
||||||
?ERROR_MSG("Malformed 'timestamp' field with value '~s' "
|
?ERROR_MSG("Malformed 'timestamp' field with value '~s' "
|
||||||
"detected for user ~s in table 'archive': "
|
"detected for user ~s in table 'archive': "
|
||||||
"not an integer",
|
"not an integer",
|
||||||
[TS, jid:to_string(JidArchive)]),
|
[TS, jid:encode(JidArchive)]),
|
||||||
{error, invalid_timestamp}
|
{error, invalid_timestamp}
|
||||||
end;
|
end;
|
||||||
{error, {_, Reason}} ->
|
{error, {_, Reason}} ->
|
||||||
?ERROR_MSG("Malformed 'xml' field with value '~s' detected "
|
?ERROR_MSG("Malformed 'xml' field with value '~s' detected "
|
||||||
"for user ~s in table 'archive': ~s",
|
"for user ~s in table 'archive': ~s",
|
||||||
[XML, jid:to_string(JidArchive), Reason]),
|
[XML, jid:encode(JidArchive), Reason]),
|
||||||
{error, invalid_xml}
|
{error, invalid_xml}
|
||||||
end.
|
end.
|
||||||
|
@ -261,7 +261,7 @@ publish_participant(From, To) ->
|
|||||||
LFrom = jid:tolower(BareFrom),
|
LFrom = jid:tolower(BareFrom),
|
||||||
LTo = jid:tolower(jid:remove_resource(To)),
|
LTo = jid:tolower(jid:remove_resource(To)),
|
||||||
Participant = #mix_participant{jid = BareFrom},
|
Participant = #mix_participant{jid = BareFrom},
|
||||||
ItemID = p1_sha:sha(jid:to_string(LFrom)),
|
ItemID = p1_sha:sha(jid:encode(LFrom)),
|
||||||
mod_pubsub:publish_item(
|
mod_pubsub:publish_item(
|
||||||
LTo, To#jid.lserver, ?NS_MIX_NODES_PARTICIPANTS,
|
LTo, To#jid.lserver, ?NS_MIX_NODES_PARTICIPANTS,
|
||||||
From, ItemID, [xmpp:encode(Participant)]).
|
From, ItemID, [xmpp:encode(Participant)]).
|
||||||
@ -284,7 +284,7 @@ delete_presence(From, To) ->
|
|||||||
|
|
||||||
delete_participant(From, To) ->
|
delete_participant(From, To) ->
|
||||||
LFrom = jid:tolower(jid:remove_resource(From)),
|
LFrom = jid:tolower(jid:remove_resource(From)),
|
||||||
ItemID = p1_sha:sha(jid:to_string(LFrom)),
|
ItemID = p1_sha:sha(jid:encode(LFrom)),
|
||||||
delete_presence(From, To),
|
delete_presence(From, To),
|
||||||
delete_item(From, To, ?NS_MIX_NODES_PARTICIPANTS, ItemID).
|
delete_item(From, To, ?NS_MIX_NODES_PARTICIPANTS, ItemID).
|
||||||
|
|
||||||
|
@ -717,7 +717,7 @@ get_room_occupants(Pid) ->
|
|||||||
S = get_room_state(Pid),
|
S = get_room_state(Pid),
|
||||||
lists:map(
|
lists:map(
|
||||||
fun({_LJID, Info}) ->
|
fun({_LJID, Info}) ->
|
||||||
{jid:to_string(Info#user.jid),
|
{jid:encode(Info#user.jid),
|
||||||
Info#user.nick,
|
Info#user.nick,
|
||||||
atom_to_list(Info#user.role)}
|
atom_to_list(Info#user.role)}
|
||||||
end,
|
end,
|
||||||
@ -744,11 +744,11 @@ get_users_to_invite(RoomJid, UsersString) ->
|
|||||||
UsersStrings = binary:split(UsersString, <<":">>, [global]),
|
UsersStrings = binary:split(UsersString, <<":">>, [global]),
|
||||||
OccupantsTuples = get_room_occupants(RoomJid#jid.luser,
|
OccupantsTuples = get_room_occupants(RoomJid#jid.luser,
|
||||||
RoomJid#jid.lserver),
|
RoomJid#jid.lserver),
|
||||||
OccupantsJids = [jid:from_string(JidString)
|
OccupantsJids = [jid:decode(JidString)
|
||||||
|| {JidString, _Nick, _} <- OccupantsTuples],
|
|| {JidString, _Nick, _} <- OccupantsTuples],
|
||||||
lists:filtermap(
|
lists:filtermap(
|
||||||
fun(UserString) ->
|
fun(UserString) ->
|
||||||
UserJid = jid:from_string(UserString),
|
UserJid = jid:decode(UserString),
|
||||||
Val = lists:all(fun(OccupantJid) ->
|
Val = lists:all(fun(OccupantJid) ->
|
||||||
UserJid#jid.luser /= OccupantJid#jid.luser
|
UserJid#jid.luser /= OccupantJid#jid.luser
|
||||||
orelse UserJid#jid.lserver /= OccupantJid#jid.lserver
|
orelse UserJid#jid.lserver /= OccupantJid#jid.lserver
|
||||||
@ -918,7 +918,7 @@ set_room_affiliation(Name, Service, JID, AffiliationString) ->
|
|||||||
case mod_muc:find_online_room(Name, Service) of
|
case mod_muc:find_online_room(Name, Service) of
|
||||||
{ok, Pid} ->
|
{ok, Pid} ->
|
||||||
%% Get the PID for the online room so we can get the state of the room
|
%% Get the PID for the online room so we can get the state of the room
|
||||||
{ok, StateData} = gen_fsm:sync_send_all_state_event(Pid, {process_item_change, {jid:from_string(JID), affiliation, Affiliation, <<"">>}, <<"">>}),
|
{ok, StateData} = gen_fsm:sync_send_all_state_event(Pid, {process_item_change, {jid:decode(JID), affiliation, Affiliation, <<"">>}, <<"">>}),
|
||||||
mod_muc:store_room(StateData#state.server_host, StateData#state.host, StateData#state.room, make_opts(StateData)),
|
mod_muc:store_room(StateData#state.server_host, StateData#state.host, StateData#state.room, make_opts(StateData)),
|
||||||
ok;
|
ok;
|
||||||
error ->
|
error ->
|
||||||
@ -933,11 +933,9 @@ subscribe_room(_User, Nick, _Room, _Nodes) when Nick == <<"">> ->
|
|||||||
throw({error, "Nickname must be set"});
|
throw({error, "Nickname must be set"});
|
||||||
subscribe_room(User, Nick, Room, Nodes) ->
|
subscribe_room(User, Nick, Room, Nodes) ->
|
||||||
NodeList = re:split(Nodes, "\\h*,\\h*"),
|
NodeList = re:split(Nodes, "\\h*,\\h*"),
|
||||||
case jid:from_string(Room) of
|
try jid:decode(Room) of
|
||||||
#jid{luser = Name, lserver = Host} when Name /= <<"">> ->
|
#jid{luser = Name, lserver = Host} when Name /= <<"">> ->
|
||||||
case jid:from_string(User) of
|
try jid:decode(User) of
|
||||||
error ->
|
|
||||||
throw({error, "Malformed user JID"});
|
|
||||||
#jid{lresource = <<"">>} ->
|
#jid{lresource = <<"">>} ->
|
||||||
throw({error, "User's JID should have a resource"});
|
throw({error, "User's JID should have a resource"});
|
||||||
UserJID ->
|
UserJID ->
|
||||||
@ -954,17 +952,19 @@ subscribe_room(User, Nick, Room, Nodes) ->
|
|||||||
_ ->
|
_ ->
|
||||||
throw({error, "The room does not exist"})
|
throw({error, "The room does not exist"})
|
||||||
end
|
end
|
||||||
|
catch _:{bad_jid, _} ->
|
||||||
|
throw({error, "Malformed user JID"})
|
||||||
end;
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
throw({error, "Malformed room JID"})
|
throw({error, "Malformed room JID"})
|
||||||
|
catch _:{bad_jid, _} ->
|
||||||
|
throw({error, "Malformed room JID"})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
unsubscribe_room(User, Room) ->
|
unsubscribe_room(User, Room) ->
|
||||||
case jid:from_string(Room) of
|
try jid:decode(Room) of
|
||||||
#jid{luser = Name, lserver = Host} when Name /= <<"">> ->
|
#jid{luser = Name, lserver = Host} when Name /= <<"">> ->
|
||||||
case jid:from_string(User) of
|
try jid:decode(User) of
|
||||||
error ->
|
|
||||||
throw({error, "Malformed user JID"});
|
|
||||||
UserJID ->
|
UserJID ->
|
||||||
case get_room_pid(Name, Host) of
|
case get_room_pid(Name, Host) of
|
||||||
Pid when is_pid(Pid) ->
|
Pid when is_pid(Pid) ->
|
||||||
@ -979,16 +979,20 @@ unsubscribe_room(User, Room) ->
|
|||||||
_ ->
|
_ ->
|
||||||
throw({error, "The room does not exist"})
|
throw({error, "The room does not exist"})
|
||||||
end
|
end
|
||||||
|
catch _:{bad_jid, _} ->
|
||||||
|
throw({error, "Malformed user JID"})
|
||||||
end;
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
throw({error, "Malformed room JID"})
|
throw({error, "Malformed room JID"})
|
||||||
|
catch _:{bad_jid, _} ->
|
||||||
|
throw({error, "Malformed room JID"})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
get_subscribers(Name, Host) ->
|
get_subscribers(Name, Host) ->
|
||||||
case get_room_pid(Name, Host) of
|
case get_room_pid(Name, Host) of
|
||||||
Pid when is_pid(Pid) ->
|
Pid when is_pid(Pid) ->
|
||||||
{ok, JIDList} = gen_fsm:sync_send_all_state_event(Pid, get_subscribers),
|
{ok, JIDList} = gen_fsm:sync_send_all_state_event(Pid, get_subscribers),
|
||||||
[jid:to_string(jid:remove_resource(J)) || J <- JIDList];
|
[jid:encode(jid:remove_resource(J)) || J <- JIDList];
|
||||||
_ ->
|
_ ->
|
||||||
throw({error, "The room does not exist"})
|
throw({error, "The room does not exist"})
|
||||||
end.
|
end.
|
||||||
|
@ -278,7 +278,7 @@ build_filename_string(TimeStamp, OutDir, RoomJID,
|
|||||||
{Fd, Fn, Fnrel}.
|
{Fd, Fn, Fnrel}.
|
||||||
|
|
||||||
get_room_name(RoomJID) ->
|
get_room_name(RoomJID) ->
|
||||||
JID = jid:from_string(RoomJID), JID#jid.user.
|
JID = jid:decode(RoomJID), JID#jid.user.
|
||||||
|
|
||||||
%% calculate day before
|
%% calculate day before
|
||||||
get_timestamp_daydiff(TimeStamp, Daydiff) ->
|
get_timestamp_daydiff(TimeStamp, Daydiff) ->
|
||||||
@ -998,7 +998,7 @@ get_room_info(RoomJID, Opts) ->
|
|||||||
{value, {_, SA}} -> SA;
|
{value, {_, SA}} -> SA;
|
||||||
false -> <<"">>
|
false -> <<"">>
|
||||||
end,
|
end,
|
||||||
#room{jid = jid:to_string(RoomJID), title = Title,
|
#room{jid = jid:encode(RoomJID), title = Title,
|
||||||
subject = Subject, subject_author = SubjectAuthor,
|
subject = Subject, subject_author = SubjectAuthor,
|
||||||
config = Opts}.
|
config = Opts}.
|
||||||
|
|
||||||
@ -1159,7 +1159,7 @@ role_users_to_string(RoleS, Users) ->
|
|||||||
<<RoleS/binary, ": ", UsersString/binary>>.
|
<<RoleS/binary, ": ", UsersString/binary>>.
|
||||||
|
|
||||||
get_room_occupants(RoomJIDString) ->
|
get_room_occupants(RoomJIDString) ->
|
||||||
RoomJID = jid:from_string(RoomJIDString),
|
RoomJID = jid:decode(RoomJIDString),
|
||||||
RoomName = RoomJID#jid.luser,
|
RoomName = RoomJID#jid.luser,
|
||||||
MucService = RoomJID#jid.lserver,
|
MucService = RoomJID#jid.lserver,
|
||||||
StateData = get_room_state(RoomName, MucService),
|
StateData = get_room_state(RoomName, MucService),
|
||||||
|
@ -279,7 +279,7 @@ import(_LServer, <<"muc_room">>,
|
|||||||
opts = Opts});
|
opts = Opts});
|
||||||
import(_LServer, <<"muc_registered">>,
|
import(_LServer, <<"muc_registered">>,
|
||||||
[J, RoomHost, Nick, _TimeStamp]) ->
|
[J, RoomHost, Nick, _TimeStamp]) ->
|
||||||
#jid{user = U, server = S} = jid:from_string(J),
|
#jid{user = U, server = S} = jid:decode(J),
|
||||||
mnesia:dirty_write(
|
mnesia:dirty_write(
|
||||||
#muc_registered{us_host = {{U, S}, RoomHost},
|
#muc_registered{us_host = {{U, S}, RoomHost},
|
||||||
nick = Nick}).
|
nick = Nick}).
|
||||||
|
@ -178,7 +178,7 @@ import(_LServer, <<"muc_room">>,
|
|||||||
muc_room_schema());
|
muc_room_schema());
|
||||||
import(_LServer, <<"muc_registered">>,
|
import(_LServer, <<"muc_registered">>,
|
||||||
[J, RoomHost, Nick, _TimeStamp]) ->
|
[J, RoomHost, Nick, _TimeStamp]) ->
|
||||||
#jid{user = U, server = S} = jid:from_string(J),
|
#jid{user = U, server = S} = jid:decode(J),
|
||||||
R = #muc_registered{us_host = {{U, S}, RoomHost}, nick = Nick},
|
R = #muc_registered{us_host = {{U, S}, RoomHost}, nick = Nick},
|
||||||
ejabberd_riak:put(R, muc_registered_schema(),
|
ejabberd_riak:put(R, muc_registered_schema(),
|
||||||
[{'2i', [{<<"nick_host">>, {Nick, RoomHost}}]}]).
|
[{'2i', [{<<"nick_host">>, {Nick, RoomHost}}]}]).
|
||||||
|
@ -132,7 +132,7 @@ init([Host, ServerHost, Access, Room, HistorySize,
|
|||||||
State1 = set_opts(DefRoomOpts, State),
|
State1 = set_opts(DefRoomOpts, State),
|
||||||
store_room(State1),
|
store_room(State1),
|
||||||
?INFO_MSG("Created MUC room ~s@~s by ~s",
|
?INFO_MSG("Created MUC room ~s@~s by ~s",
|
||||||
[Room, Host, jid:to_string(Creator)]),
|
[Room, Host, jid:encode(Creator)]),
|
||||||
add_to_log(room_existence, created, State1),
|
add_to_log(room_existence, created, State1),
|
||||||
add_to_log(room_existence, started, State1),
|
add_to_log(room_existence, started, State1),
|
||||||
{ok, normal_state, State1};
|
{ok, normal_state, State1};
|
||||||
@ -483,12 +483,12 @@ handle_event({destroy, Reason}, _StateName,
|
|||||||
destroy_room(#muc_destroy{xmlns = ?NS_MUC_OWNER, reason = Reason},
|
destroy_room(#muc_destroy{xmlns = ?NS_MUC_OWNER, reason = Reason},
|
||||||
StateData),
|
StateData),
|
||||||
?INFO_MSG("Destroyed MUC room ~s with reason: ~p",
|
?INFO_MSG("Destroyed MUC room ~s with reason: ~p",
|
||||||
[jid:to_string(StateData#state.jid), Reason]),
|
[jid:encode(StateData#state.jid), Reason]),
|
||||||
add_to_log(room_existence, destroyed, StateData),
|
add_to_log(room_existence, destroyed, StateData),
|
||||||
{stop, shutdown, StateData};
|
{stop, shutdown, StateData};
|
||||||
handle_event(destroy, StateName, StateData) ->
|
handle_event(destroy, StateName, StateData) ->
|
||||||
?INFO_MSG("Destroyed MUC room ~s",
|
?INFO_MSG("Destroyed MUC room ~s",
|
||||||
[jid:to_string(StateData#state.jid)]),
|
[jid:encode(StateData#state.jid)]),
|
||||||
handle_event({destroy, undefined}, StateName, StateData);
|
handle_event({destroy, undefined}, StateName, StateData);
|
||||||
handle_event({set_affiliations, Affiliations},
|
handle_event({set_affiliations, Affiliations},
|
||||||
StateName, StateData) ->
|
StateName, StateData) ->
|
||||||
@ -1056,7 +1056,7 @@ close_room_if_temporary_and_empty(StateData1) ->
|
|||||||
true ->
|
true ->
|
||||||
?INFO_MSG("Destroyed MUC room ~s because it's temporary "
|
?INFO_MSG("Destroyed MUC room ~s because it's temporary "
|
||||||
"and empty",
|
"and empty",
|
||||||
[jid:to_string(StateData1#state.jid)]),
|
[jid:encode(StateData1#state.jid)]),
|
||||||
add_to_log(room_existence, destroyed, StateData1),
|
add_to_log(room_existence, destroyed, StateData1),
|
||||||
{stop, normal, StateData1};
|
{stop, normal, StateData1};
|
||||||
_ -> {next_state, normal_state, StateData1}
|
_ -> {next_state, normal_state, StateData1}
|
||||||
@ -1178,7 +1178,7 @@ decide_fate_message(#message{type = error} = Msg,
|
|||||||
true ->
|
true ->
|
||||||
Reason = str:format("This participant is considered a ghost "
|
Reason = str:format("This participant is considered a ghost "
|
||||||
"and is expulsed: ~s",
|
"and is expulsed: ~s",
|
||||||
[jid:to_string(From)]),
|
[jid:encode(From)]),
|
||||||
{expulse_sender, Reason};
|
{expulse_sender, Reason};
|
||||||
false -> continue_delivery
|
false -> continue_delivery
|
||||||
end,
|
end,
|
||||||
@ -2575,8 +2575,8 @@ process_admin_items_set(UJID, Items, Lang, StateData) ->
|
|||||||
{result, Res} ->
|
{result, Res} ->
|
||||||
?INFO_MSG("Processing MUC admin query from ~s in "
|
?INFO_MSG("Processing MUC admin query from ~s in "
|
||||||
"room ~s:~n ~p",
|
"room ~s:~n ~p",
|
||||||
[jid:to_string(UJID),
|
[jid:encode(UJID),
|
||||||
jid:to_string(StateData#state.jid), Res]),
|
jid:encode(StateData#state.jid), Res]),
|
||||||
case lists:foldl(process_item_change(UJID),
|
case lists:foldl(process_item_change(UJID),
|
||||||
StateData, lists:flatten(Res)) of
|
StateData, lists:flatten(Res)) of
|
||||||
{error, _} = Err ->
|
{error, _} = Err ->
|
||||||
@ -2650,7 +2650,7 @@ process_item_change(Item, SD, UJID) ->
|
|||||||
end
|
end
|
||||||
catch E:R ->
|
catch E:R ->
|
||||||
?ERROR_MSG("failed to set item ~p from ~s: ~p",
|
?ERROR_MSG("failed to set item ~p from ~s: ~p",
|
||||||
[Item, jid:to_string(UJID),
|
[Item, jid:encode(UJID),
|
||||||
{E, {R, erlang:get_stacktrace()}}]),
|
{E, {R, erlang:get_stacktrace()}}]),
|
||||||
{error, xmpp:err_internal_server_error()}
|
{error, xmpp:err_internal_server_error()}
|
||||||
end.
|
end.
|
||||||
@ -2995,7 +2995,7 @@ process_iq_owner(From, #iq{type = set, lang = Lang,
|
|||||||
{error, xmpp:err_forbidden(ErrText, Lang)};
|
{error, xmpp:err_forbidden(ErrText, Lang)};
|
||||||
Destroy /= undefined, Config == undefined, Items == [] ->
|
Destroy /= undefined, Config == undefined, Items == [] ->
|
||||||
?INFO_MSG("Destroyed MUC room ~s by the owner ~s",
|
?INFO_MSG("Destroyed MUC room ~s by the owner ~s",
|
||||||
[jid:to_string(StateData#state.jid), jid:to_string(From)]),
|
[jid:encode(StateData#state.jid), jid:encode(From)]),
|
||||||
add_to_log(room_existence, destroyed, StateData),
|
add_to_log(room_existence, destroyed, StateData),
|
||||||
destroy_room(Destroy, StateData);
|
destroy_room(Destroy, StateData);
|
||||||
Config /= undefined, Destroy == undefined, Items == [] ->
|
Config /= undefined, Destroy == undefined, Items == [] ->
|
||||||
@ -3140,7 +3140,7 @@ get_config(Lang, StateData, From) ->
|
|||||||
MaxUsersRoom = get_max_users(StateData),
|
MaxUsersRoom = get_max_users(StateData),
|
||||||
Title = str:format(
|
Title = str:format(
|
||||||
translate:translate(Lang, <<"Configuration of room ~s">>),
|
translate:translate(Lang, <<"Configuration of room ~s">>),
|
||||||
[jid:to_string(StateData#state.jid)]),
|
[jid:encode(StateData#state.jid)]),
|
||||||
Fs = [{roomname, Config#config.title},
|
Fs = [{roomname, Config#config.title},
|
||||||
{roomdesc, Config#config.description}] ++
|
{roomdesc, Config#config.description}] ++
|
||||||
case acl:match_rule(StateData#state.server_host, AccessPersistent, From) of
|
case acl:match_rule(StateData#state.server_host, AccessPersistent, From) of
|
||||||
@ -3898,8 +3898,8 @@ route_invitation(From, Invitation, Lang, StateData) ->
|
|||||||
translate:translate(
|
translate:translate(
|
||||||
Lang,
|
Lang,
|
||||||
<<"~s invites you to the room ~s">>),
|
<<"~s invites you to the room ~s">>),
|
||||||
[jid:to_string(From),
|
[jid:encode(From),
|
||||||
jid:to_string({StateData#state.room, StateData#state.host, <<"">>})]),
|
jid:encode({StateData#state.room, StateData#state.host, <<"">>})]),
|
||||||
case (StateData#state.config)#config.password_protected of
|
case (StateData#state.config)#config.password_protected of
|
||||||
true ->
|
true ->
|
||||||
<<", ",
|
<<", ",
|
||||||
|
@ -82,7 +82,7 @@ forget_room(LServer, Host, Name) ->
|
|||||||
ejabberd_sql:sql_transaction(LServer, F).
|
ejabberd_sql:sql_transaction(LServer, F).
|
||||||
|
|
||||||
can_use_nick(LServer, Host, JID, Nick) ->
|
can_use_nick(LServer, Host, JID, Nick) ->
|
||||||
SJID = jid:to_string(jid:tolower(jid:remove_resource(JID))),
|
SJID = jid:encode(jid:tolower(jid:remove_resource(JID))),
|
||||||
case catch ejabberd_sql:sql_query(
|
case catch ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(jid)s from muc_registered "
|
?SQL("select @(jid)s from muc_registered "
|
||||||
@ -110,7 +110,7 @@ get_rooms(LServer, Host) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
get_nick(LServer, Host, From) ->
|
get_nick(LServer, Host, From) ->
|
||||||
SJID = jid:to_string(jid:tolower(jid:remove_resource(From))),
|
SJID = jid:encode(jid:tolower(jid:remove_resource(From))),
|
||||||
case catch ejabberd_sql:sql_query(
|
case catch ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("select @(nick)s from muc_registered where"
|
?SQL("select @(nick)s from muc_registered where"
|
||||||
@ -120,7 +120,7 @@ get_nick(LServer, Host, From) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
set_nick(LServer, Host, From, Nick) ->
|
set_nick(LServer, Host, From, Nick) ->
|
||||||
JID = jid:to_string(jid:tolower(jid:remove_resource(From))),
|
JID = jid:encode(jid:tolower(jid:remove_resource(From))),
|
||||||
F = fun () ->
|
F = fun () ->
|
||||||
case Nick of
|
case Nick of
|
||||||
<<"">> ->
|
<<"">> ->
|
||||||
@ -215,7 +215,7 @@ export(_Server) ->
|
|||||||
nick = Nick}) ->
|
nick = Nick}) ->
|
||||||
case str:suffix(Host, RoomHost) of
|
case str:suffix(Host, RoomHost) of
|
||||||
true ->
|
true ->
|
||||||
SJID = jid:to_string(jid:make(U, S)),
|
SJID = jid:encode(jid:make(U, S)),
|
||||||
[?SQL("delete from muc_registered where"
|
[?SQL("delete from muc_registered where"
|
||||||
" jid=%(SJID)s and host=%(RoomHost)s;"),
|
" jid=%(SJID)s and host=%(RoomHost)s;"),
|
||||||
?SQL("insert into muc_registered(jid, host, "
|
?SQL("insert into muc_registered(jid, host, "
|
||||||
|
@ -242,7 +242,7 @@ handle_iq(Packet, State) ->
|
|||||||
ejabberd_router:route_error(Packet, Error);
|
ejabberd_router:route_error(Packet, Error);
|
||||||
reply ->
|
reply ->
|
||||||
To = xmpp:get_to(IQ),
|
To = xmpp:get_to(IQ),
|
||||||
LServiceS = jid:to_string(To),
|
LServiceS = jid:encode(To),
|
||||||
case Packet#iq.type of
|
case Packet#iq.type of
|
||||||
result ->
|
result ->
|
||||||
process_iqreply_result(LServiceS, IQ);
|
process_iqreply_result(LServiceS, IQ);
|
||||||
@ -297,7 +297,7 @@ route_trusted(LServiceS, LServerS, FromJID,
|
|||||||
Delivereds = [],
|
Delivereds = [],
|
||||||
Dests2 = lists:map(
|
Dests2 = lists:map(
|
||||||
fun(D) ->
|
fun(D) ->
|
||||||
#dest{jid_string = jid:to_string(D),
|
#dest{jid_string = jid:encode(D),
|
||||||
jid_jid = D, type = bcc,
|
jid_jid = D, type = bcc,
|
||||||
full_xml = #address{type = bcc, jid = D}}
|
full_xml = #address{type = bcc, jid = D}}
|
||||||
end, Destinations),
|
end, Destinations),
|
||||||
@ -463,7 +463,7 @@ convert_dest_record(Addrs) ->
|
|||||||
fun(#address{jid = undefined} = Addr) ->
|
fun(#address{jid = undefined} = Addr) ->
|
||||||
#dest{jid_string = none, full_xml = Addr};
|
#dest{jid_string = none, full_xml = Addr};
|
||||||
(#address{jid = JID, type = Type} = Addr) ->
|
(#address{jid = JID, type = Type} = Addr) ->
|
||||||
#dest{jid_string = jid:to_string(JID), jid_jid = JID,
|
#dest{jid_string = jid:encode(JID), jid_jid = JID,
|
||||||
type = Type, full_xml = Addr}
|
type = Type, full_xml = Addr}
|
||||||
end, Addrs).
|
end, Addrs).
|
||||||
|
|
||||||
@ -1120,9 +1120,9 @@ make_reply(internal_server_error, Lang, ErrText) ->
|
|||||||
make_reply(forbidden, Lang, ErrText) ->
|
make_reply(forbidden, Lang, ErrText) ->
|
||||||
xmpp:err_forbidden(ErrText, Lang).
|
xmpp:err_forbidden(ErrText, Lang).
|
||||||
|
|
||||||
stj(String) -> jid:from_string(String).
|
stj(String) -> jid:decode(String).
|
||||||
|
|
||||||
jts(String) -> jid:to_string(String).
|
jts(String) -> jid:encode(String).
|
||||||
|
|
||||||
depends(_Host, _Opts) ->
|
depends(_Host, _Opts) ->
|
||||||
[].
|
[].
|
||||||
|
@ -306,7 +306,7 @@ get_sm_items(_Acc, #jid{luser = U, lserver = S} = JID,
|
|||||||
Node = integer_to_binary(Seq),
|
Node = integer_to_binary(Seq),
|
||||||
#disco_item{jid = BareJID,
|
#disco_item{jid = BareJID,
|
||||||
node = Node,
|
node = Node,
|
||||||
name = jid:to_string(From)}
|
name = jid:encode(From)}
|
||||||
end, Hdrs)};
|
end, Hdrs)};
|
||||||
get_sm_items(Acc, _From, _To, _Node, _Lang) ->
|
get_sm_items(Acc, _From, _To, _Node, _Lang) ->
|
||||||
Acc.
|
Acc.
|
||||||
@ -673,7 +673,7 @@ offline_msg_to_route(LServer, #offline_msg{from = From, to = To} = R) ->
|
|||||||
{route, Pkt2}
|
{route, Pkt2}
|
||||||
catch _:{xmpp_codec, Why} ->
|
catch _:{xmpp_codec, Why} ->
|
||||||
?ERROR_MSG("failed to decode packet ~p of user ~s: ~s",
|
?ERROR_MSG("failed to decode packet ~p of user ~s: ~s",
|
||||||
[R#offline_msg.packet, jid:to_string(To),
|
[R#offline_msg.packet, jid:encode(To),
|
||||||
xmpp:format_error(Why)]),
|
xmpp:format_error(Why)]),
|
||||||
error
|
error
|
||||||
end.
|
end.
|
||||||
@ -693,7 +693,7 @@ read_messages(LUser, LServer) ->
|
|||||||
catch _:{xmpp_codec, Why} ->
|
catch _:{xmpp_codec, Why} ->
|
||||||
?ERROR_MSG("failed to decode packet ~p "
|
?ERROR_MSG("failed to decode packet ~p "
|
||||||
"of user ~s: ~s",
|
"of user ~s: ~s",
|
||||||
[El, jid:to_string(To),
|
[El, jid:encode(To),
|
||||||
xmpp:format_error(Why)]),
|
xmpp:format_error(Why)]),
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
@ -704,8 +704,8 @@ format_user_queue(Hdrs) ->
|
|||||||
fun({Seq, From, To, TS, El}) ->
|
fun({Seq, From, To, TS, El}) ->
|
||||||
ID = integer_to_binary(Seq),
|
ID = integer_to_binary(Seq),
|
||||||
FPacket = ejabberd_web_admin:pretty_print_xml(El),
|
FPacket = ejabberd_web_admin:pretty_print_xml(El),
|
||||||
SFrom = jid:to_string(From),
|
SFrom = jid:encode(From),
|
||||||
STo = jid:to_string(To),
|
STo = jid:encode(To),
|
||||||
Time = case TS of
|
Time = case TS of
|
||||||
undefined ->
|
undefined ->
|
||||||
Stamp = fxml:get_path_s(El, [{elem, <<"delay">>},
|
Stamp = fxml:get_path_s(El, [{elem, <<"delay">>},
|
||||||
@ -792,7 +792,7 @@ user_queue_parse_query(LUser, LServer, Query) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
us_to_list({User, Server}) ->
|
us_to_list({User, Server}) ->
|
||||||
jid:to_string({User, Server, <<"">>}).
|
jid:encode({User, Server, <<"">>}).
|
||||||
|
|
||||||
get_queue_length(LUser, LServer) ->
|
get_queue_length(LUser, LServer) ->
|
||||||
count_offline_messages(LUser, LServer).
|
count_offline_messages(LUser, LServer).
|
||||||
|
@ -227,17 +227,17 @@ xml_to_offline_msg(XML) ->
|
|||||||
el_to_offline_msg(El) ->
|
el_to_offline_msg(El) ->
|
||||||
To_s = fxml:get_tag_attr_s(<<"to">>, El),
|
To_s = fxml:get_tag_attr_s(<<"to">>, El),
|
||||||
From_s = fxml:get_tag_attr_s(<<"from">>, El),
|
From_s = fxml:get_tag_attr_s(<<"from">>, El),
|
||||||
To = jid:from_string(To_s),
|
try
|
||||||
From = jid:from_string(From_s),
|
To = jid:decode(To_s),
|
||||||
if To == error ->
|
From = jid:decode(From_s),
|
||||||
|
{ok, #offline_msg{us = {To#jid.luser, To#jid.lserver},
|
||||||
|
from = From,
|
||||||
|
to = To,
|
||||||
|
packet = El}}
|
||||||
|
catch _:{bad_jid, To_s} ->
|
||||||
?ERROR_MSG("failed to get 'to' JID from offline XML ~p", [El]),
|
?ERROR_MSG("failed to get 'to' JID from offline XML ~p", [El]),
|
||||||
{error, bad_jid_to};
|
{error, bad_jid_to};
|
||||||
From == error ->
|
_:{bad_jid, From_s} ->
|
||||||
?ERROR_MSG("failed to get 'from' JID from offline XML ~p", [El]),
|
?ERROR_MSG("failed to get 'from' JID from offline XML ~p", [El]),
|
||||||
{error, bad_jid_from};
|
{error, bad_jid_from}
|
||||||
true ->
|
|
||||||
{ok, #offline_msg{us = {To#jid.luser, To#jid.lserver},
|
|
||||||
from = From,
|
|
||||||
to = To,
|
|
||||||
packet = El}}
|
|
||||||
end.
|
end.
|
||||||
|
@ -105,14 +105,14 @@ update(Server, JID, Dir) ->
|
|||||||
in ->
|
in ->
|
||||||
?WARNING_MSG("User ~s is being flooded, ignoring received "
|
?WARNING_MSG("User ~s is being flooded, ignoring received "
|
||||||
"presence subscriptions",
|
"presence subscriptions",
|
||||||
[jid:to_string(JID)]);
|
[jid:encode(JID)]);
|
||||||
out ->
|
out ->
|
||||||
IP = ejabberd_sm:get_user_ip(JID#jid.luser,
|
IP = ejabberd_sm:get_user_ip(JID#jid.luser,
|
||||||
JID#jid.lserver,
|
JID#jid.lserver,
|
||||||
JID#jid.lresource),
|
JID#jid.lresource),
|
||||||
?WARNING_MSG("Flooder detected: ~s, on IP: ~s ignoring "
|
?WARNING_MSG("Flooder detected: ~s, on IP: ~s ignoring "
|
||||||
"sent presence subscriptions~n",
|
"sent presence subscriptions~n",
|
||||||
[jid:to_string(JID),
|
[jid:encode(JID),
|
||||||
jlib:ip_to_list(IP)])
|
jlib:ip_to_list(IP)])
|
||||||
end,
|
end,
|
||||||
{stop, deny};
|
{stop, deny};
|
||||||
|
@ -236,7 +236,7 @@ encode_list_item(#listitem{action = Action,
|
|||||||
-spec encode_value(listitem_type(), listitem_value()) -> binary().
|
-spec encode_value(listitem_type(), listitem_value()) -> binary().
|
||||||
encode_value(Type, Val) ->
|
encode_value(Type, Val) ->
|
||||||
case Type of
|
case Type of
|
||||||
jid -> jid:to_string(Val);
|
jid -> jid:encode(Val);
|
||||||
group -> Val;
|
group -> Val;
|
||||||
subscription ->
|
subscription ->
|
||||||
case Val of
|
case Val of
|
||||||
@ -252,7 +252,7 @@ encode_value(Type, Val) ->
|
|||||||
listitem_value().
|
listitem_value().
|
||||||
decode_value(Type, Value) ->
|
decode_value(Type, Value) ->
|
||||||
case Type of
|
case Type of
|
||||||
jid -> jid:tolower(jid:from_string(Value));
|
jid -> jid:tolower(jid:decode(Value));
|
||||||
subscription ->
|
subscription ->
|
||||||
case Value of
|
case Value of
|
||||||
<<"from">> -> from;
|
<<"from">> -> from;
|
||||||
|
@ -278,10 +278,8 @@ raw_to_item({SType, SValue, SAction, Order, MatchAll,
|
|||||||
{Type, Value} = case SType of
|
{Type, Value} = case SType of
|
||||||
<<"n">> -> {none, none};
|
<<"n">> -> {none, none};
|
||||||
<<"j">> ->
|
<<"j">> ->
|
||||||
case jid:from_string(SValue) of
|
JID = jid:decode(SValue),
|
||||||
#jid{} = JID ->
|
{jid, jid:tolower(JID)};
|
||||||
{jid, jid:tolower(JID)}
|
|
||||||
end;
|
|
||||||
<<"g">> -> {group, SValue};
|
<<"g">> -> {group, SValue};
|
||||||
<<"s">> ->
|
<<"s">> ->
|
||||||
case SValue of
|
case SValue of
|
||||||
@ -312,7 +310,7 @@ item_to_raw(#listitem{type = Type, value = Value,
|
|||||||
match_presence_out = MatchPresenceOut}) ->
|
match_presence_out = MatchPresenceOut}) ->
|
||||||
{SType, SValue} = case Type of
|
{SType, SValue} = case Type of
|
||||||
none -> {<<"n">>, <<"">>};
|
none -> {<<"n">>, <<"">>};
|
||||||
jid -> {<<"j">>, jid:to_string(Value)};
|
jid -> {<<"j">>, jid:encode(Value)};
|
||||||
group -> {<<"g">>, Value};
|
group -> {<<"g">>, Value};
|
||||||
subscription ->
|
subscription ->
|
||||||
case Value of
|
case Value of
|
||||||
|
@ -215,8 +215,8 @@ process_bytestreams(#iq{type = set, lang = Lang, from = InitiatorJID, to = To,
|
|||||||
case acl:match_rule(ServerHost, ACL, InitiatorJID) of
|
case acl:match_rule(ServerHost, ACL, InitiatorJID) of
|
||||||
allow ->
|
allow ->
|
||||||
Node = ejabberd_cluster:get_node_by_id(To#jid.lresource),
|
Node = ejabberd_cluster:get_node_by_id(To#jid.lresource),
|
||||||
Target = jid:to_string(jid:tolower(TargetJID)),
|
Target = jid:encode(jid:tolower(TargetJID)),
|
||||||
Initiator = jid:to_string(jid:tolower(InitiatorJID)),
|
Initiator = jid:encode(jid:tolower(InitiatorJID)),
|
||||||
SHA1 = p1_sha:sha(<<SID/binary, Initiator/binary, Target/binary>>),
|
SHA1 = p1_sha:sha(<<SID/binary, Initiator/binary, Target/binary>>),
|
||||||
Mod = gen_mod:ram_db_mod(global, mod_proxy65),
|
Mod = gen_mod:ram_db_mod(global, mod_proxy65),
|
||||||
MaxConnections = max_connections(ServerHost),
|
MaxConnections = max_connections(ServerHost),
|
||||||
|
@ -121,8 +121,8 @@ activate({P1, J1}, {P2, J2}) ->
|
|||||||
{S1, S2} when is_port(S1), is_port(S2) ->
|
{S1, S2} when is_port(S1), is_port(S2) ->
|
||||||
P1 ! {activate, P2, S2, J1, J2},
|
P1 ! {activate, P2, S2, J1, J2},
|
||||||
P2 ! {activate, P1, S1, J1, J2},
|
P2 ! {activate, P1, S1, J1, J2},
|
||||||
JID1 = jid:to_string(J1),
|
JID1 = jid:encode(J1),
|
||||||
JID2 = jid:to_string(J2),
|
JID2 = jid:encode(J2),
|
||||||
?INFO_MSG("(~w:~w) Activated bytestream for ~s "
|
?INFO_MSG("(~w:~w) Activated bytestream for ~s "
|
||||||
"-> ~s",
|
"-> ~s",
|
||||||
[P1, P2, JID1, JID2]),
|
[P1, P2, JID1, JID2]),
|
||||||
|
@ -1414,7 +1414,7 @@ get_pending_nodes(Host, Owner, Plugins) ->
|
|||||||
binary()) -> adhoc_command() | {error, stanza_error()}.
|
binary()) -> adhoc_command() | {error, stanza_error()}.
|
||||||
send_pending_auth_events(Host, Node, Owner, Lang) ->
|
send_pending_auth_events(Host, Node, Owner, Lang) ->
|
||||||
?DEBUG("Sending pending auth events for ~s on ~s:~s",
|
?DEBUG("Sending pending auth events for ~s on ~s:~s",
|
||||||
[jid:to_string(Owner), Host, Node]),
|
[jid:encode(Owner), Host, Node]),
|
||||||
Action =
|
Action =
|
||||||
fun(#pubsub_node{id = Nidx, type = Type}) ->
|
fun(#pubsub_node{id = Nidx, type = Type}) ->
|
||||||
case lists:member(<<"get-pending">>, plugin_features(Host, Type)) of
|
case lists:member(<<"get-pending">>, plugin_features(Host, Type)) of
|
||||||
@ -2819,7 +2819,7 @@ broadcast_publish_item(Host, Node, Nidx, Type, NodeOptions, ItemId, From, Payloa
|
|||||||
EventItem0;
|
EventItem0;
|
||||||
publisher ->
|
publisher ->
|
||||||
EventItem0#ps_item{
|
EventItem0#ps_item{
|
||||||
publisher = jid:to_string(From)};
|
publisher = jid:encode(From)};
|
||||||
none ->
|
none ->
|
||||||
EventItem0
|
EventItem0
|
||||||
end,
|
end,
|
||||||
|
@ -287,7 +287,7 @@ try_set_password(User, Server, Password, #iq{lang = Lang, meta = M} = IQ) ->
|
|||||||
case ejabberd_auth:set_password(User, Server, Password) of
|
case ejabberd_auth:set_password(User, Server, Password) of
|
||||||
ok ->
|
ok ->
|
||||||
?INFO_MSG("~s has changed password from ~s",
|
?INFO_MSG("~s has changed password from ~s",
|
||||||
[jid:to_string({User, Server, <<"">>}),
|
[jid:encode({User, Server, <<"">>}),
|
||||||
ejabberd_config:may_hide_data(
|
ejabberd_config:may_hide_data(
|
||||||
jlib:ip_to_list(maps:get(ip, M, {0,0,0,0})))]),
|
jlib:ip_to_list(maps:get(ip, M, {0,0,0,0})))]),
|
||||||
xmpp:make_iq_result(IQ);
|
xmpp:make_iq_result(IQ);
|
||||||
@ -405,8 +405,7 @@ send_registration_notifications(Mod, UJID, Source) ->
|
|||||||
case gen_mod:get_module_opt(
|
case gen_mod:get_module_opt(
|
||||||
Host, Mod, registration_watchers,
|
Host, Mod, registration_watchers,
|
||||||
fun(Ss) ->
|
fun(Ss) ->
|
||||||
[#jid{} = jid:from_string(iolist_to_binary(S))
|
[jid:decode(iolist_to_binary(S)) || S <- Ss]
|
||||||
|| S <- Ss]
|
|
||||||
end, []) of
|
end, []) of
|
||||||
[] -> ok;
|
[] -> ok;
|
||||||
JIDs when is_list(JIDs) ->
|
JIDs when is_list(JIDs) ->
|
||||||
@ -414,7 +413,7 @@ send_registration_notifications(Mod, UJID, Source) ->
|
|||||||
(str:format("[~s] The account ~s was registered from "
|
(str:format("[~s] The account ~s was registered from "
|
||||||
"IP address ~s on node ~w using ~p.",
|
"IP address ~s on node ~w using ~p.",
|
||||||
[get_time_string(),
|
[get_time_string(),
|
||||||
jid:to_string(UJID),
|
jid:encode(UJID),
|
||||||
ip_to_string(Source), node(),
|
ip_to_string(Source), node(),
|
||||||
Mod])),
|
Mod])),
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
@ -643,8 +642,7 @@ mod_opt_type(password_strength) ->
|
|||||||
fun (N) when is_number(N), N >= 0 -> N end;
|
fun (N) when is_number(N), N >= 0 -> N end;
|
||||||
mod_opt_type(registration_watchers) ->
|
mod_opt_type(registration_watchers) ->
|
||||||
fun (Ss) ->
|
fun (Ss) ->
|
||||||
[#jid{} = jid:from_string(iolist_to_binary(S))
|
[jid:decode(iolist_to_binary(S)) || S <- Ss]
|
||||||
|| S <- Ss]
|
|
||||||
end;
|
end;
|
||||||
mod_opt_type(welcome_message) ->
|
mod_opt_type(welcome_message) ->
|
||||||
fun (Opts) ->
|
fun (Opts) ->
|
||||||
|
@ -333,7 +333,7 @@ process_iq_get(#iq{to = To, lang = Lang,
|
|||||||
end)
|
end)
|
||||||
catch E:R ->
|
catch E:R ->
|
||||||
?ERROR_MSG("failed to process roster get for ~s: ~p",
|
?ERROR_MSG("failed to process roster get for ~s: ~p",
|
||||||
[jid:to_string(To), {E, {R, erlang:get_stacktrace()}}]),
|
[jid:encode(To), {E, {R, erlang:get_stacktrace()}}]),
|
||||||
Txt = <<"Roster module has failed">>,
|
Txt = <<"Roster module has failed">>,
|
||||||
xmpp:make_error(IQ, xmpp:err_internal_server_error(Txt, Lang))
|
xmpp:make_error(IQ, xmpp:err_internal_server_error(Txt, Lang))
|
||||||
end.
|
end.
|
||||||
@ -1038,10 +1038,10 @@ build_contact_jid_td(RosterJID) ->
|
|||||||
case JIDURI of
|
case JIDURI of
|
||||||
<<>> ->
|
<<>> ->
|
||||||
?XAC(<<"td">>, [{<<"class">>, <<"valign">>}],
|
?XAC(<<"td">>, [{<<"class">>, <<"valign">>}],
|
||||||
(jid:to_string(RosterJID)));
|
(jid:encode(RosterJID)));
|
||||||
URI when is_binary(URI) ->
|
URI when is_binary(URI) ->
|
||||||
?XAE(<<"td">>, [{<<"class">>, <<"valign">>}],
|
?XAE(<<"td">>, [{<<"class">>, <<"valign">>}],
|
||||||
[?AC(JIDURI, (jid:to_string(RosterJID)))])
|
[?AC(JIDURI, (jid:encode(RosterJID)))])
|
||||||
end.
|
end.
|
||||||
|
|
||||||
user_roster_parse_query(User, Server, Items, Query) ->
|
user_roster_parse_query(User, Server, Items, Query) ->
|
||||||
@ -1049,10 +1049,11 @@ user_roster_parse_query(User, Server, Items, Query) ->
|
|||||||
{value, _} ->
|
{value, _} ->
|
||||||
case lists:keysearch(<<"newjid">>, 1, Query) of
|
case lists:keysearch(<<"newjid">>, 1, Query) of
|
||||||
{value, {_, SJID}} ->
|
{value, {_, SJID}} ->
|
||||||
case jid:from_string(SJID) of
|
try jid:decode(SJID) of
|
||||||
JID when is_record(JID, jid) ->
|
JID ->
|
||||||
user_roster_subscribe_jid(User, Server, JID), ok;
|
user_roster_subscribe_jid(User, Server, JID), ok
|
||||||
error -> error
|
catch _:{bad_jid, _} ->
|
||||||
|
error
|
||||||
end;
|
end;
|
||||||
false -> error
|
false -> error
|
||||||
end;
|
end;
|
||||||
@ -1114,7 +1115,7 @@ user_roster_item_parse_query(User, Server, Items,
|
|||||||
nothing.
|
nothing.
|
||||||
|
|
||||||
us_to_list({User, Server}) ->
|
us_to_list({User, Server}) ->
|
||||||
jid:to_string({User, Server, <<"">>}).
|
jid:encode({User, Server, <<"">>}).
|
||||||
|
|
||||||
webadmin_user(Acc, _User, _Server, Lang) ->
|
webadmin_user(Acc, _User, _Server, Lang) ->
|
||||||
Acc ++
|
Acc ++
|
||||||
@ -1145,7 +1146,7 @@ import_stop(_LServer, _DBType) ->
|
|||||||
ok.
|
ok.
|
||||||
|
|
||||||
import(LServer, {sql, _}, _DBType, <<"rostergroups">>, [LUser, SJID, Group]) ->
|
import(LServer, {sql, _}, _DBType, <<"rostergroups">>, [LUser, SJID, Group]) ->
|
||||||
LJID = jid:tolower(jid:from_string(SJID)),
|
LJID = jid:tolower(jid:decode(SJID)),
|
||||||
ets:insert(rostergroups_tmp, {{LUser, LServer, LJID}, Group}),
|
ets:insert(rostergroups_tmp, {{LUser, LServer, LJID}, Group}),
|
||||||
ok;
|
ok;
|
||||||
import(LServer, {sql, _}, DBType, <<"rosterusers">>, Row) ->
|
import(LServer, {sql, _}, DBType, <<"rosterusers">>, Row) ->
|
||||||
|
@ -83,7 +83,7 @@ get_roster(LUser, LServer) ->
|
|||||||
%% Bad JID in database:
|
%% Bad JID in database:
|
||||||
error -> [];
|
error -> [];
|
||||||
R ->
|
R ->
|
||||||
SJID = jid:to_string(R#roster.jid),
|
SJID = jid:encode(R#roster.jid),
|
||||||
Groups = case dict:find(SJID, GroupsDict) of
|
Groups = case dict:find(SJID, GroupsDict) of
|
||||||
{ok, Gs} -> Gs;
|
{ok, Gs} -> Gs;
|
||||||
error -> []
|
error -> []
|
||||||
@ -97,7 +97,7 @@ get_roster(LUser, LServer) ->
|
|||||||
|
|
||||||
get_roster_by_jid(LUser, LServer, LJID) ->
|
get_roster_by_jid(LUser, LServer, LJID) ->
|
||||||
{selected, Res} =
|
{selected, Res} =
|
||||||
sql_queries:get_roster_by_jid(LServer, LUser, jid:to_string(LJID)),
|
sql_queries:get_roster_by_jid(LServer, LUser, jid:encode(LJID)),
|
||||||
case Res of
|
case Res of
|
||||||
[] ->
|
[] ->
|
||||||
#roster{usj = {LUser, LServer, LJID},
|
#roster{usj = {LUser, LServer, LJID},
|
||||||
@ -136,7 +136,7 @@ transaction(LServer, F) ->
|
|||||||
ejabberd_sql:sql_transaction(LServer, F).
|
ejabberd_sql:sql_transaction(LServer, F).
|
||||||
|
|
||||||
get_roster_by_jid_with_groups(LUser, LServer, LJID) ->
|
get_roster_by_jid_with_groups(LUser, LServer, LJID) ->
|
||||||
SJID = jid:to_string(LJID),
|
SJID = jid:encode(LJID),
|
||||||
case sql_queries:get_roster_by_jid(LServer, LUser, SJID) of
|
case sql_queries:get_roster_by_jid(LServer, LUser, SJID) of
|
||||||
{selected, [I]} ->
|
{selected, [I]} ->
|
||||||
case raw_to_record(LServer, I) of
|
case raw_to_record(LServer, I) of
|
||||||
@ -162,18 +162,18 @@ remove_user(LUser, LServer) ->
|
|||||||
{atomic, ok}.
|
{atomic, ok}.
|
||||||
|
|
||||||
update_roster(LUser, LServer, LJID, Item) ->
|
update_roster(LUser, LServer, LJID, Item) ->
|
||||||
SJID = jid:to_string(LJID),
|
SJID = jid:encode(LJID),
|
||||||
ItemVals = record_to_row(Item),
|
ItemVals = record_to_row(Item),
|
||||||
ItemGroups = Item#roster.groups,
|
ItemGroups = Item#roster.groups,
|
||||||
sql_queries:update_roster(LServer, LUser, SJID, ItemVals,
|
sql_queries:update_roster(LServer, LUser, SJID, ItemVals,
|
||||||
ItemGroups).
|
ItemGroups).
|
||||||
|
|
||||||
del_roster(LUser, LServer, LJID) ->
|
del_roster(LUser, LServer, LJID) ->
|
||||||
SJID = jid:to_string(LJID),
|
SJID = jid:encode(LJID),
|
||||||
sql_queries:del_roster(LServer, LUser, SJID).
|
sql_queries:del_roster(LServer, LUser, SJID).
|
||||||
|
|
||||||
read_subscription_and_groups(LUser, LServer, LJID) ->
|
read_subscription_and_groups(LUser, LServer, LJID) ->
|
||||||
SJID = jid:to_string(LJID),
|
SJID = jid:encode(LJID),
|
||||||
case catch sql_queries:get_subscription(LServer, LUser, SJID) of
|
case catch sql_queries:get_subscription(LServer, LUser, SJID) of
|
||||||
{selected, [{SSubscription}]} ->
|
{selected, [{SSubscription}]} ->
|
||||||
Subscription = case SSubscription of
|
Subscription = case SSubscription of
|
||||||
@ -234,10 +234,7 @@ raw_to_record(LServer,
|
|||||||
raw_to_record(LServer,
|
raw_to_record(LServer,
|
||||||
{User, SJID, Nick, SSubscription, SAsk, SAskMessage,
|
{User, SJID, Nick, SSubscription, SAsk, SAskMessage,
|
||||||
_SServer, _SSubscribe, _SType}) ->
|
_SServer, _SSubscribe, _SType}) ->
|
||||||
case jid:from_string(SJID) of
|
try jid:decode(SJID) of
|
||||||
error ->
|
|
||||||
?ERROR_MSG("~s", [format_row_error(User, LServer, {jid, SJID})]),
|
|
||||||
error;
|
|
||||||
JID ->
|
JID ->
|
||||||
LJID = jid:tolower(JID),
|
LJID = jid:tolower(JID),
|
||||||
Subscription = case SSubscription of
|
Subscription = case SSubscription of
|
||||||
@ -268,13 +265,16 @@ raw_to_record(LServer,
|
|||||||
us = {User, LServer}, jid = LJID, name = Nick,
|
us = {User, LServer}, jid = LJID, name = Nick,
|
||||||
subscription = Subscription, ask = Ask,
|
subscription = Subscription, ask = Ask,
|
||||||
askmessage = SAskMessage}
|
askmessage = SAskMessage}
|
||||||
|
catch _:{bad_jid, _} ->
|
||||||
|
?ERROR_MSG("~s", [format_row_error(User, LServer, {jid, SJID})]),
|
||||||
|
error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
record_to_row(
|
record_to_row(
|
||||||
#roster{us = {LUser, _LServer},
|
#roster{us = {LUser, _LServer},
|
||||||
jid = JID, name = Name, subscription = Subscription,
|
jid = JID, name = Name, subscription = Subscription,
|
||||||
ask = Ask, askmessage = AskMessage}) ->
|
ask = Ask, askmessage = AskMessage}) ->
|
||||||
SJID = jid:to_string(jid:tolower(JID)),
|
SJID = jid:encode(jid:tolower(JID)),
|
||||||
SSubscription = case Subscription of
|
SSubscription = case Subscription of
|
||||||
both -> <<"B">>;
|
both -> <<"B">>;
|
||||||
to -> <<"T">>;
|
to -> <<"T">>;
|
||||||
|
@ -983,15 +983,13 @@ shared_roster_group_parse_query(Host, Group, Query) ->
|
|||||||
<<"@all@">> -> USs;
|
<<"@all@">> -> USs;
|
||||||
<<"@online@">> -> USs;
|
<<"@online@">> -> USs;
|
||||||
_ ->
|
_ ->
|
||||||
case jid:from_string(SJID)
|
try jid:decode(SJID) of
|
||||||
of
|
JID ->
|
||||||
JID
|
|
||||||
when is_record(JID,
|
|
||||||
jid) ->
|
|
||||||
[{JID#jid.luser,
|
[{JID#jid.luser,
|
||||||
JID#jid.lserver}
|
JID#jid.lserver}
|
||||||
| USs];
|
| USs]
|
||||||
error -> error
|
catch _:{bad_jid, _} ->
|
||||||
|
error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@ -1043,7 +1041,7 @@ get_opt(Opts, Opt, Default) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
us_to_list({User, Server}) ->
|
us_to_list({User, Server}) ->
|
||||||
jid:to_string({User, Server, <<"">>}).
|
jid:encode({User, Server, <<"">>}).
|
||||||
|
|
||||||
split_grouphost(Host, Group) ->
|
split_grouphost(Host, Group) ->
|
||||||
case str:tokens(Group, <<"@">>) of
|
case str:tokens(Group, <<"@">>) of
|
||||||
|
@ -140,7 +140,7 @@ import(LServer, <<"sr_group">>, [Group, SOpts, _TimeStamp]) ->
|
|||||||
opts = ejabberd_sql:decode_term(SOpts)},
|
opts = ejabberd_sql:decode_term(SOpts)},
|
||||||
mnesia:dirty_write(G);
|
mnesia:dirty_write(G);
|
||||||
import(LServer, <<"sr_user">>, [SJID, Group, _TimeStamp]) ->
|
import(LServer, <<"sr_user">>, [SJID, Group, _TimeStamp]) ->
|
||||||
#jid{luser = U, lserver = S} = jid:from_string(SJID),
|
#jid{luser = U, lserver = S} = jid:decode(SJID),
|
||||||
User = #sr_user{us = {U, S}, group_host = {Group, LServer}},
|
User = #sr_user{us = {U, S}, group_host = {Group, LServer}},
|
||||||
mnesia:dirty_write(User).
|
mnesia:dirty_write(User).
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ import(LServer, <<"sr_group">>, [Group, SOpts, _TimeStamp]) ->
|
|||||||
opts = ejabberd_sql:decode_term(SOpts)},
|
opts = ejabberd_sql:decode_term(SOpts)},
|
||||||
ejabberd_riak:put(G, sr_group_schema(), [{'2i', [{<<"host">>, LServer}]}]);
|
ejabberd_riak:put(G, sr_group_schema(), [{'2i', [{<<"host">>, LServer}]}]);
|
||||||
import(LServer, <<"sr_user">>, [SJID, Group|_]) ->
|
import(LServer, <<"sr_user">>, [SJID, Group|_]) ->
|
||||||
#jid{luser = U, lserver = S} = jid:from_string(SJID),
|
#jid{luser = U, lserver = S} = jid:decode(SJID),
|
||||||
User = #sr_user{us = {U, S}, group_host = {Group, LServer}},
|
User = #sr_user{us = {U, S}, group_host = {Group, LServer}},
|
||||||
ejabberd_riak:put(User, sr_user_schema(),
|
ejabberd_riak:put(User, sr_user_schema(),
|
||||||
[{i, {{U, S}, {Group, LServer}}},
|
[{i, {{U, S}, {Group, LServer}}},
|
||||||
|
@ -123,7 +123,7 @@ get_group_explicit_users(Host, Group) ->
|
|||||||
{selected, Rs} ->
|
{selected, Rs} ->
|
||||||
lists:map(
|
lists:map(
|
||||||
fun({JID}) ->
|
fun({JID}) ->
|
||||||
{U, S, _} = jid:tolower(jid:from_string(JID)),
|
{U, S, _} = jid:tolower(jid:decode(JID)),
|
||||||
{U, S}
|
{U, S}
|
||||||
end, Rs);
|
end, Rs);
|
||||||
_ ->
|
_ ->
|
||||||
@ -198,6 +198,6 @@ import(_, _, _) ->
|
|||||||
%%% Internal functions
|
%%% Internal functions
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
make_jid_s(U, S) ->
|
make_jid_s(U, S) ->
|
||||||
jid:to_string(jid:tolower(jid:make(U, S))).
|
jid:encode(jid:tolower(jid:make(U, S))).
|
||||||
|
|
||||||
make_jid_s({U, S}) -> make_jid_s(U, S).
|
make_jid_s({U, S}) -> make_jid_s(U, S).
|
||||||
|
@ -229,20 +229,20 @@ c2s_handle_call(State, _Call, _From) ->
|
|||||||
c2s_handle_info(#{mgmt_ack_timer := TRef, jid := JID, mod := Mod} = State,
|
c2s_handle_info(#{mgmt_ack_timer := TRef, jid := JID, mod := Mod} = State,
|
||||||
{timeout, TRef, ack_timeout}) ->
|
{timeout, TRef, ack_timeout}) ->
|
||||||
?DEBUG("Timed out waiting for stream management acknowledgement of ~s",
|
?DEBUG("Timed out waiting for stream management acknowledgement of ~s",
|
||||||
[jid:to_string(JID)]),
|
[jid:encode(JID)]),
|
||||||
State1 = State#{stop_reason => {socket, timeout}},
|
State1 = State#{stop_reason => {socket, timeout}},
|
||||||
State2 = Mod:close(State1, _SendTrailer = false),
|
State2 = Mod:close(State1, _SendTrailer = false),
|
||||||
{stop, transition_to_pending(State2)};
|
{stop, transition_to_pending(State2)};
|
||||||
c2s_handle_info(#{mgmt_state := pending, jid := JID, mod := Mod} = State,
|
c2s_handle_info(#{mgmt_state := pending, jid := JID, mod := Mod} = State,
|
||||||
{timeout, _, pending_timeout}) ->
|
{timeout, _, pending_timeout}) ->
|
||||||
?DEBUG("Timed out waiting for resumption of stream for ~s",
|
?DEBUG("Timed out waiting for resumption of stream for ~s",
|
||||||
[jid:to_string(JID)]),
|
[jid:encode(JID)]),
|
||||||
Mod:stop(State#{mgmt_state => timeout});
|
Mod:stop(State#{mgmt_state => timeout});
|
||||||
c2s_handle_info(#{jid := JID} = State, {_Ref, {resume, OldState}}) ->
|
c2s_handle_info(#{jid := JID} = State, {_Ref, {resume, OldState}}) ->
|
||||||
%% This happens if the resume_session/1 request timed out; the new session
|
%% This happens if the resume_session/1 request timed out; the new session
|
||||||
%% now receives the late response.
|
%% now receives the late response.
|
||||||
?DEBUG("Received old session state for ~s after failed resumption",
|
?DEBUG("Received old session state for ~s after failed resumption",
|
||||||
[jid:to_string(JID)]),
|
[jid:encode(JID)]),
|
||||||
route_unacked_stanzas(OldState#{mgmt_resend => false}),
|
route_unacked_stanzas(OldState#{mgmt_resend => false}),
|
||||||
State;
|
State;
|
||||||
c2s_handle_info(State, _) ->
|
c2s_handle_info(State, _) ->
|
||||||
@ -257,7 +257,7 @@ c2s_closed(State, _Reason) ->
|
|||||||
|
|
||||||
c2s_terminated(#{mgmt_state := resumed, jid := JID} = State, _Reason) ->
|
c2s_terminated(#{mgmt_state := resumed, jid := JID} = State, _Reason) ->
|
||||||
?INFO_MSG("Closing former stream of resumed session for ~s",
|
?INFO_MSG("Closing former stream of resumed session for ~s",
|
||||||
[jid:to_string(JID)]),
|
[jid:encode(JID)]),
|
||||||
bounce_message_queue(),
|
bounce_message_queue(),
|
||||||
{stop, State};
|
{stop, State};
|
||||||
c2s_terminated(#{mgmt_state := MgmtState, mgmt_stanzas_in := In, sid := SID,
|
c2s_terminated(#{mgmt_state := MgmtState, mgmt_stanzas_in := In, sid := SID,
|
||||||
@ -328,14 +328,14 @@ handle_enable(#{mgmt_timeout := DefaultTimeout,
|
|||||||
end,
|
end,
|
||||||
Res = if Timeout > 0 ->
|
Res = if Timeout > 0 ->
|
||||||
?INFO_MSG("Stream management with resumption enabled for ~s",
|
?INFO_MSG("Stream management with resumption enabled for ~s",
|
||||||
[jid:to_string(JID)]),
|
[jid:encode(JID)]),
|
||||||
#sm_enabled{xmlns = Xmlns,
|
#sm_enabled{xmlns = Xmlns,
|
||||||
id = make_resume_id(State),
|
id = make_resume_id(State),
|
||||||
resume = true,
|
resume = true,
|
||||||
max = Timeout};
|
max = Timeout};
|
||||||
true ->
|
true ->
|
||||||
?INFO_MSG("Stream management without resumption enabled for ~s",
|
?INFO_MSG("Stream management without resumption enabled for ~s",
|
||||||
[jid:to_string(JID)]),
|
[jid:encode(JID)]),
|
||||||
#sm_enabled{xmlns = Xmlns}
|
#sm_enabled{xmlns = Xmlns}
|
||||||
end,
|
end,
|
||||||
State1 = State#{mgmt_state => active,
|
State1 = State#{mgmt_state => active,
|
||||||
@ -383,7 +383,7 @@ handle_resume(#{user := User, lserver := LServer, sockmod := SockMod,
|
|||||||
%% csi_flush_queue(State4),
|
%% csi_flush_queue(State4),
|
||||||
State5 = ejabberd_hooks:run_fold(c2s_session_resumed, LServer, State4, []),
|
State5 = ejabberd_hooks:run_fold(c2s_session_resumed, LServer, State4, []),
|
||||||
?INFO_MSG("(~s) Resumed session for ~s",
|
?INFO_MSG("(~s) Resumed session for ~s",
|
||||||
[SockMod:pp(Socket), jid:to_string(JID)]),
|
[SockMod:pp(Socket), jid:encode(JID)]),
|
||||||
{ok, State5};
|
{ok, State5};
|
||||||
{error, El, Msg} ->
|
{error, El, Msg} ->
|
||||||
?INFO_MSG("Cannot resume session for ~s@~s: ~s",
|
?INFO_MSG("Cannot resume session for ~s@~s: ~s",
|
||||||
@ -398,7 +398,7 @@ transition_to_pending(#{mgmt_state := active, mod := Mod,
|
|||||||
transition_to_pending(#{mgmt_state := active, jid := JID,
|
transition_to_pending(#{mgmt_state := active, jid := JID,
|
||||||
lserver := LServer, mgmt_timeout := Timeout} = State) ->
|
lserver := LServer, mgmt_timeout := Timeout} = State) ->
|
||||||
State1 = cancel_ack_timer(State),
|
State1 = cancel_ack_timer(State),
|
||||||
?INFO_MSG("Waiting for resumption of stream for ~s", [jid:to_string(JID)]),
|
?INFO_MSG("Waiting for resumption of stream for ~s", [jid:encode(JID)]),
|
||||||
erlang:start_timer(timer:seconds(Timeout), self(), pending_timeout),
|
erlang:start_timer(timer:seconds(Timeout), self(), pending_timeout),
|
||||||
State2 = State1#{mgmt_state => pending},
|
State2 = State1#{mgmt_state => pending},
|
||||||
ejabberd_hooks:run_fold(c2s_session_pending, LServer, State2, []);
|
ejabberd_hooks:run_fold(c2s_session_pending, LServer, State2, []);
|
||||||
@ -409,11 +409,11 @@ transition_to_pending(State) ->
|
|||||||
check_h_attribute(#{mgmt_stanzas_out := NumStanzasOut, jid := JID} = State, H)
|
check_h_attribute(#{mgmt_stanzas_out := NumStanzasOut, jid := JID} = State, H)
|
||||||
when H > NumStanzasOut ->
|
when H > NumStanzasOut ->
|
||||||
?DEBUG("~s acknowledged ~B stanzas, but only ~B were sent",
|
?DEBUG("~s acknowledged ~B stanzas, but only ~B were sent",
|
||||||
[jid:to_string(JID), H, NumStanzasOut]),
|
[jid:encode(JID), H, NumStanzasOut]),
|
||||||
mgmt_queue_drop(State#{mgmt_stanzas_out => H}, NumStanzasOut);
|
mgmt_queue_drop(State#{mgmt_stanzas_out => H}, NumStanzasOut);
|
||||||
check_h_attribute(#{mgmt_stanzas_out := NumStanzasOut, jid := JID} = State, H) ->
|
check_h_attribute(#{mgmt_stanzas_out := NumStanzasOut, jid := JID} = State, H) ->
|
||||||
?DEBUG("~s acknowledged ~B of ~B stanzas",
|
?DEBUG("~s acknowledged ~B of ~B stanzas",
|
||||||
[jid:to_string(JID), H, NumStanzasOut]),
|
[jid:encode(JID), H, NumStanzasOut]),
|
||||||
mgmt_queue_drop(State, H).
|
mgmt_queue_drop(State, H).
|
||||||
|
|
||||||
-spec update_num_stanzas_in(state(), xmpp_element()) -> state().
|
-spec update_num_stanzas_in(state(), xmpp_element()) -> state().
|
||||||
@ -490,7 +490,7 @@ resend_unacked_stanzas(#{mgmt_state := MgmtState,
|
|||||||
MgmtState == pending orelse
|
MgmtState == pending orelse
|
||||||
MgmtState == timeout) andalso QueueLen > 0 ->
|
MgmtState == timeout) andalso QueueLen > 0 ->
|
||||||
?DEBUG("Resending ~B unacknowledged stanza(s) to ~s",
|
?DEBUG("Resending ~B unacknowledged stanza(s) to ~s",
|
||||||
[QueueLen, jid:to_string(JID)]),
|
[QueueLen, jid:encode(JID)]),
|
||||||
queue_foldl(
|
queue_foldl(
|
||||||
fun({_, Time, Pkt}, AccState) ->
|
fun({_, Time, Pkt}, AccState) ->
|
||||||
NewPkt = add_resent_delay_info(AccState, Pkt, Time),
|
NewPkt = add_resent_delay_info(AccState, Pkt, Time),
|
||||||
@ -522,10 +522,10 @@ route_unacked_stanzas(#{mgmt_state := MgmtState,
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
?DEBUG("Re-routing ~B unacknowledged stanza(s) to ~s",
|
?DEBUG("Re-routing ~B unacknowledged stanza(s) to ~s",
|
||||||
[QueueLen, jid:to_string(JID)]),
|
[QueueLen, jid:encode(JID)]),
|
||||||
queue_foreach(
|
queue_foreach(
|
||||||
fun({_, _Time, #presence{from = From}}) ->
|
fun({_, _Time, #presence{from = From}}) ->
|
||||||
?DEBUG("Dropping presence stanza from ~s", [jid:to_string(From)]);
|
?DEBUG("Dropping presence stanza from ~s", [jid:encode(From)]);
|
||||||
({_, _Time, #iq{} = El}) ->
|
({_, _Time, #iq{} = El}) ->
|
||||||
Txt = <<"User session terminated">>,
|
Txt = <<"User session terminated">>,
|
||||||
ejabberd_router:route_error(
|
ejabberd_router:route_error(
|
||||||
@ -537,14 +537,14 @@ route_unacked_stanzas(#{mgmt_state := MgmtState,
|
|||||||
%% back to the original sender." Resending such a stanza could
|
%% back to the original sender." Resending such a stanza could
|
||||||
%% easily lead to unexpected results as well.
|
%% easily lead to unexpected results as well.
|
||||||
?DEBUG("Dropping forwarded message stanza from ~s",
|
?DEBUG("Dropping forwarded message stanza from ~s",
|
||||||
[jid:to_string(From)]);
|
[jid:encode(From)]);
|
||||||
({_, Time, #message{} = Msg}) ->
|
({_, Time, #message{} = Msg}) ->
|
||||||
case ejabberd_hooks:run_fold(message_is_archived,
|
case ejabberd_hooks:run_fold(message_is_archived,
|
||||||
LServer, false,
|
LServer, false,
|
||||||
[State, Msg]) of
|
[State, Msg]) of
|
||||||
true ->
|
true ->
|
||||||
?DEBUG("Dropping archived message stanza from ~s",
|
?DEBUG("Dropping archived message stanza from ~s",
|
||||||
[jid:to_string(xmpp:get_from(Msg))]);
|
[jid:encode(xmpp:get_from(Msg))]);
|
||||||
false when ResendOnTimeout ->
|
false when ResendOnTimeout ->
|
||||||
NewEl = add_resent_delay_info(State, Msg, Time),
|
NewEl = add_resent_delay_info(State, Msg, Time),
|
||||||
ejabberd_router:route(NewEl);
|
ejabberd_router:route(NewEl);
|
||||||
|
@ -393,7 +393,7 @@ mk_field(Var, Val) ->
|
|||||||
-spec mk_search_form(jid(), binary(), binary()) -> search().
|
-spec mk_search_form(jid(), binary(), binary()) -> search().
|
||||||
mk_search_form(JID, ServerHost, Lang) ->
|
mk_search_form(JID, ServerHost, Lang) ->
|
||||||
Title = <<(translate:translate(Lang, <<"Search users in ">>))/binary,
|
Title = <<(translate:translate(Lang, <<"Search users in ">>))/binary,
|
||||||
(jid:to_string(JID))/binary>>,
|
(jid:encode(JID))/binary>>,
|
||||||
Mod = gen_mod:db_mod(ServerHost, ?MODULE),
|
Mod = gen_mod:db_mod(ServerHost, ?MODULE),
|
||||||
SearchFields = Mod:search_fields(ServerHost),
|
SearchFields = Mod:search_fields(ServerHost),
|
||||||
Fs = [mk_tfield(Label, Var, Lang) || {Label, Var} <- SearchFields],
|
Fs = [mk_tfield(Label, Var, Lang) || {Label, Var} <- SearchFields],
|
||||||
@ -419,7 +419,7 @@ search_result(Lang, JID, ServerHost, XFields) ->
|
|||||||
#xdata{type = result,
|
#xdata{type = result,
|
||||||
title = <<(translate:translate(Lang,
|
title = <<(translate:translate(Lang,
|
||||||
<<"Search Results for ">>))/binary,
|
<<"Search Results for ">>))/binary,
|
||||||
(jid:to_string(JID))/binary>>,
|
(jid:encode(JID))/binary>>,
|
||||||
reported = Reported,
|
reported = Reported,
|
||||||
items = lists:map(fun (Item) -> item_to_field(Item) end,
|
items = lists:map(fun (Item) -> item_to_field(Item) end,
|
||||||
search(ServerHost, XFields))}.
|
search(ServerHost, XFields))}.
|
||||||
|
@ -960,7 +960,7 @@ update_subscription(Nidx, JID, Subscription) ->
|
|||||||
|
|
||||||
-spec decode_jid(SJID :: binary()) -> ljid().
|
-spec decode_jid(SJID :: binary()) -> ljid().
|
||||||
decode_jid(SJID) ->
|
decode_jid(SJID) ->
|
||||||
jid:tolower(jid:from_string(SJID)).
|
jid:tolower(jid:decode(SJID)).
|
||||||
|
|
||||||
-spec decode_affiliation(Arg :: binary()) -> atom().
|
-spec decode_affiliation(Arg :: binary()) -> atom().
|
||||||
decode_affiliation(<<"o">>) -> owner;
|
decode_affiliation(<<"o">>) -> owner;
|
||||||
@ -988,11 +988,11 @@ decode_subscriptions(Subscriptions) ->
|
|||||||
|
|
||||||
-spec encode_jid(JID :: ljid()) -> binary().
|
-spec encode_jid(JID :: ljid()) -> binary().
|
||||||
encode_jid(JID) ->
|
encode_jid(JID) ->
|
||||||
jid:to_string(JID).
|
jid:encode(JID).
|
||||||
|
|
||||||
-spec encode_jid_like(JID :: ljid()) -> binary().
|
-spec encode_jid_like(JID :: ljid()) -> binary().
|
||||||
encode_jid_like(JID) ->
|
encode_jid_like(JID) ->
|
||||||
ejabberd_sql:escape_like_arg_circumflex(jid:to_string(JID)).
|
ejabberd_sql:escape_like_arg_circumflex(jid:encode(JID)).
|
||||||
|
|
||||||
-spec encode_host(Host :: host()) -> binary().
|
-spec encode_host(Host :: host()) -> binary().
|
||||||
encode_host({_U, _S, _R} = LJID) -> encode_jid(LJID);
|
encode_host({_U, _S, _R} = LJID) -> encode_jid(LJID);
|
||||||
|
@ -112,13 +112,13 @@ node_record(Host, Node, Nidx) ->
|
|||||||
options = Module:options()}.
|
options = Module:options()}.
|
||||||
|
|
||||||
nodeidx({U,S,R}, Node) ->
|
nodeidx({U,S,R}, Node) ->
|
||||||
JID = jid:to_string(jid:make(U,S,R)),
|
JID = jid:encode(jid:make(U,S,R)),
|
||||||
<<JID/binary, ":", Node/binary>>;
|
<<JID/binary, ":", Node/binary>>;
|
||||||
nodeidx(Host, Node) ->
|
nodeidx(Host, Node) ->
|
||||||
<<Host/binary, ":", Node/binary>>.
|
<<Host/binary, ":", Node/binary>>.
|
||||||
nodeid(Nidx) ->
|
nodeid(Nidx) ->
|
||||||
[Head, Node] = binary:split(Nidx, <<":">>),
|
[Head, Node] = binary:split(Nidx, <<":">>),
|
||||||
case jid:from_string(Head) of
|
case jid:decode(Head) of
|
||||||
{jid,<<>>,Host,<<>>,_,_,_} -> {Host, Node};
|
{jid,<<>>,Host,<<>>,_,_,_} -> {Host, Node};
|
||||||
{jid,U,S,R,_,_,_} -> {{U,S,R}, Node}
|
{jid,U,S,R,_,_,_} -> {{U,S,R}, Node}
|
||||||
end.
|
end.
|
||||||
|
@ -172,7 +172,7 @@ convert_data(Host, "vcard", User, [Data]) ->
|
|||||||
ok
|
ok
|
||||||
end;
|
end;
|
||||||
convert_data(_Host, "config", _User, [Data]) ->
|
convert_data(_Host, "config", _User, [Data]) ->
|
||||||
RoomJID = jid:from_string(proplists:get_value(<<"jid">>, Data, <<"">>)),
|
RoomJID = jid:decode(proplists:get_value(<<"jid">>, Data, <<"">>)),
|
||||||
Config = proplists:get_value(<<"_data">>, Data, []),
|
Config = proplists:get_value(<<"_data">>, Data, []),
|
||||||
RoomCfg = convert_room_config(Data),
|
RoomCfg = convert_room_config(Data),
|
||||||
case proplists:get_bool(<<"persistent">>, Config) of
|
case proplists:get_bool(<<"persistent">>, Config) of
|
||||||
@ -217,14 +217,14 @@ convert_data(_Host, _Type, _User, _Data) ->
|
|||||||
convert_pending_item(LUser, LServer, LuaList) ->
|
convert_pending_item(LUser, LServer, LuaList) ->
|
||||||
lists:flatmap(
|
lists:flatmap(
|
||||||
fun({S, true}) ->
|
fun({S, true}) ->
|
||||||
case jid:from_string(S) of
|
try jid:decode(S) of
|
||||||
#jid{} = J ->
|
J ->
|
||||||
LJID = jid:tolower(J),
|
LJID = jid:tolower(J),
|
||||||
[#roster{usj = {LUser, LServer, LJID},
|
[#roster{usj = {LUser, LServer, LJID},
|
||||||
us = {LUser, LServer},
|
us = {LUser, LServer},
|
||||||
jid = LJID,
|
jid = LJID,
|
||||||
ask = in}];
|
ask = in}]
|
||||||
error ->
|
catch _:{bad_jid, _} ->
|
||||||
[]
|
[]
|
||||||
end;
|
end;
|
||||||
(_) ->
|
(_) ->
|
||||||
@ -232,8 +232,8 @@ convert_pending_item(LUser, LServer, LuaList) ->
|
|||||||
end, LuaList).
|
end, LuaList).
|
||||||
|
|
||||||
convert_roster_item(LUser, LServer, JIDstring, LuaList) ->
|
convert_roster_item(LUser, LServer, JIDstring, LuaList) ->
|
||||||
case jid:from_string(JIDstring) of
|
try jid:decode(JIDstring) of
|
||||||
#jid{} = JID ->
|
JID ->
|
||||||
LJID = jid:tolower(JID),
|
LJID = jid:tolower(JID),
|
||||||
InitR = #roster{usj = {LUser, LServer, LJID},
|
InitR = #roster{usj = {LUser, LServer, LJID},
|
||||||
us = {LUser, LServer},
|
us = {LUser, LServer},
|
||||||
@ -253,18 +253,18 @@ convert_roster_item(LUser, LServer, JIDstring, LuaList) ->
|
|||||||
({<<"name">>, Name}, R) ->
|
({<<"name">>, Name}, R) ->
|
||||||
R#roster{name = Name}
|
R#roster{name = Name}
|
||||||
end, InitR, LuaList),
|
end, InitR, LuaList),
|
||||||
[Roster];
|
[Roster]
|
||||||
error ->
|
catch _:{bad_jid, _} ->
|
||||||
[]
|
[]
|
||||||
end.
|
end.
|
||||||
|
|
||||||
convert_room_affiliations(Data) ->
|
convert_room_affiliations(Data) ->
|
||||||
lists:flatmap(
|
lists:flatmap(
|
||||||
fun({J, Aff}) ->
|
fun({J, Aff}) ->
|
||||||
case jid:from_string(J) of
|
try jid:decode(J) of
|
||||||
#jid{luser = U, lserver = S} ->
|
#jid{luser = U, lserver = S} ->
|
||||||
[{{U, S, <<>>}, jlib:binary_to_atom(Aff)}];
|
[{{U, S, <<>>}, jlib:binary_to_atom(Aff)}]
|
||||||
error ->
|
catch _:{bad_jid, _} ->
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
end, proplists:get_value(<<"_affiliations">>, Data, [])).
|
end, proplists:get_value(<<"_affiliations">>, Data, [])).
|
||||||
@ -278,13 +278,13 @@ convert_room_config(Data) ->
|
|||||||
[{password_protected, true},
|
[{password_protected, true},
|
||||||
{password, Password}]
|
{password, Password}]
|
||||||
end,
|
end,
|
||||||
Subj = case jid:from_string(
|
Subj = try jid:decode(
|
||||||
proplists:get_value(
|
proplists:get_value(
|
||||||
<<"subject_from">>, Config, <<"">>)) of
|
<<"subject_from">>, Config, <<"">>)) of
|
||||||
#jid{lresource = Nick} when Nick /= <<"">> ->
|
#jid{lresource = Nick} when Nick /= <<"">> ->
|
||||||
[{subject, proplists:get_value(<<"subject">>, Config, <<"">>)},
|
[{subject, proplists:get_value(<<"subject">>, Config, <<"">>)},
|
||||||
{subject_author, Nick}];
|
{subject_author, Nick}]
|
||||||
_ ->
|
catch _:{bad_jid, _} ->
|
||||||
[]
|
[]
|
||||||
end,
|
end,
|
||||||
Anonymous = case proplists:get_value(<<"whois">>, Config, <<"moderators">>) of
|
Anonymous = case proplists:get_value(<<"whois">>, Config, <<"moderators">>) of
|
||||||
@ -316,7 +316,7 @@ convert_privacy_item({_, Item}) ->
|
|||||||
{Type, Value} = try case T of
|
{Type, Value} = try case T of
|
||||||
none -> {T, none};
|
none -> {T, none};
|
||||||
group -> {T, V};
|
group -> {T, V};
|
||||||
jid -> {T, jid:tolower(jid:from_string(V))};
|
jid -> {T, jid:tolower(jid:decode(V))};
|
||||||
subscription -> {T, jlib:binary_to_atom(V)}
|
subscription -> {T, jlib:binary_to_atom(V)}
|
||||||
end
|
end
|
||||||
catch _:_ ->
|
catch _:_ ->
|
||||||
@ -333,29 +333,27 @@ convert_privacy_item({_, Item}) ->
|
|||||||
match_presence_out = MatchPresOut}.
|
match_presence_out = MatchPresOut}.
|
||||||
|
|
||||||
el_to_offline_msg(LUser, LServer, #xmlel{attrs = Attrs} = El) ->
|
el_to_offline_msg(LUser, LServer, #xmlel{attrs = Attrs} = El) ->
|
||||||
try xmpp_util:decode_timestamp(
|
try
|
||||||
fxml:get_attr_s(<<"stamp">>, Attrs)) of
|
TS = xmpp_util:decode_timestamp(
|
||||||
{_, _, _} = TS ->
|
fxml:get_attr_s(<<"stamp">>, Attrs)),
|
||||||
Attrs1 = lists:filter(
|
Attrs1 = lists:filter(
|
||||||
fun(<<"stamp">>) -> false;
|
fun(<<"stamp">>) -> false;
|
||||||
(<<"stamp_legacy">>) -> false;
|
(<<"stamp_legacy">>) -> false;
|
||||||
(_) -> true
|
(_) -> true
|
||||||
end, Attrs),
|
end, Attrs),
|
||||||
Packet = El#xmlel{attrs = Attrs1},
|
Packet = El#xmlel{attrs = Attrs1},
|
||||||
case {jid:from_string(fxml:get_attr_s(<<"from">>, Attrs)),
|
From = jid:decode(fxml:get_attr_s(<<"from">>, Attrs)),
|
||||||
jid:from_string(fxml:get_attr_s(<<"to">>, Attrs))} of
|
To = jid:decode(fxml:get_attr_s(<<"to">>, Attrs)),
|
||||||
{#jid{} = From, #jid{} = To} ->
|
[#offline_msg{
|
||||||
[#offline_msg{
|
us = {LUser, LServer},
|
||||||
us = {LUser, LServer},
|
timestamp = TS,
|
||||||
timestamp = TS,
|
expire = never,
|
||||||
expire = never,
|
from = From,
|
||||||
from = From,
|
to = To,
|
||||||
to = To,
|
packet = Packet}]
|
||||||
packet = Packet}];
|
|
||||||
_ ->
|
|
||||||
[]
|
|
||||||
end
|
|
||||||
catch _:{bad_timestamp, _} ->
|
catch _:{bad_timestamp, _} ->
|
||||||
|
[];
|
||||||
|
_:{bad_jid, _} ->
|
||||||
[]
|
[]
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -560,7 +560,7 @@ process_sasl_mechanisms(Mechs, #{user := User, server := Server} = State) ->
|
|||||||
case lists:member(<<"EXTERNAL">>, Mechs) of
|
case lists:member(<<"EXTERNAL">>, Mechs) of
|
||||||
true ->
|
true ->
|
||||||
State1 = State#{stream_state => wait_for_sasl_response},
|
State1 = State#{stream_state => wait_for_sasl_response},
|
||||||
Authzid = jid:to_string(jid:make(User, Server)),
|
Authzid = jid:encode(jid:make(User, Server)),
|
||||||
send_pkt(State1, #sasl_auth{mechanism = Mech, text = Authzid});
|
send_pkt(State1, #sasl_auth{mechanism = Mech, text = Authzid});
|
||||||
false ->
|
false ->
|
||||||
process_sasl_failure(
|
process_sasl_failure(
|
||||||
|
@ -106,11 +106,13 @@ get_cert_domains(Cert) ->
|
|||||||
true -> error
|
true -> error
|
||||||
end,
|
end,
|
||||||
if D /= error ->
|
if D /= error ->
|
||||||
case jid:from_string(D) of
|
try jid:decode(D) of
|
||||||
#jid{luser = <<"">>, lserver = LD,
|
#jid{luser = <<"">>, lserver = LD,
|
||||||
lresource = <<"">>} ->
|
lresource = <<"">>} ->
|
||||||
[LD];
|
[LD];
|
||||||
_ -> []
|
_ -> []
|
||||||
|
catch _:{bad_jid, _} ->
|
||||||
|
[]
|
||||||
end;
|
end;
|
||||||
true -> []
|
true -> []
|
||||||
end;
|
end;
|
||||||
@ -131,7 +133,7 @@ get_cert_domains(Cert) ->
|
|||||||
value = XmppAddr}}) ->
|
value = XmppAddr}}) ->
|
||||||
case 'XmppAddr':decode('XmppAddr', XmppAddr) of
|
case 'XmppAddr':decode('XmppAddr', XmppAddr) of
|
||||||
{ok, D} when is_binary(D) ->
|
{ok, D} when is_binary(D) ->
|
||||||
case jid:from_string(D) of
|
try jid:decode(D) of
|
||||||
#jid{luser = <<"">>,
|
#jid{luser = <<"">>,
|
||||||
lserver = LD,
|
lserver = LD,
|
||||||
lresource = <<"">>} ->
|
lresource = <<"">>} ->
|
||||||
@ -142,16 +144,20 @@ get_cert_domains(Cert) ->
|
|||||||
[PCLD]
|
[PCLD]
|
||||||
end;
|
end;
|
||||||
_ -> []
|
_ -> []
|
||||||
|
catch _:{bad_jid, _} ->
|
||||||
|
[]
|
||||||
end;
|
end;
|
||||||
_ -> []
|
_ -> []
|
||||||
end;
|
end;
|
||||||
({dNSName, D}) when is_list(D) ->
|
({dNSName, D}) when is_list(D) ->
|
||||||
case jid:from_string(list_to_binary(D)) of
|
try jid:decode(list_to_binary(D)) of
|
||||||
#jid{luser = <<"">>,
|
#jid{luser = <<"">>,
|
||||||
lserver = LD,
|
lserver = LD,
|
||||||
lresource = <<"">>} ->
|
lresource = <<"">>} ->
|
||||||
[LD];
|
[LD];
|
||||||
_ -> []
|
_ -> []
|
||||||
|
catch _:{bad_jid, _} ->
|
||||||
|
[]
|
||||||
end;
|
end;
|
||||||
(_) -> []
|
(_) -> []
|
||||||
end, SANs);
|
end, SANs);
|
||||||
|
Loading…
Reference in New Issue
Block a user