26
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-26 17:38:45 +01:00

Don't pass empty resource to jid:make()

This commit is contained in:
Evgeniy Khramtsov 2017-02-25 10:01:01 +03:00
parent 485aae8134
commit 603ec9cb19
23 changed files with 44 additions and 48 deletions

View File

@ -731,7 +731,7 @@ check_access(Command, Access, Auth, CallerInfo)
Command#ejabberd_commands.policy == user -> Command#ejabberd_commands.policy == user ->
case check_auth(Command, Auth) of case check_auth(Command, Auth) of
{ok, User, Server} -> {ok, User, Server} ->
check_access2(Access, CallerInfo#{usr => jid:split(jid:make(User, Server, <<>>))}, Server); check_access2(Access, CallerInfo#{usr => jid:split(jid:make(User, Server))}, Server);
no_auth_provided -> no_auth_provided ->
case Command#ejabberd_commands.policy of case Command#ejabberd_commands.policy of
user -> user ->
@ -834,7 +834,7 @@ oauth_token_user(noauth) ->
oauth_token_user(admin) -> oauth_token_user(admin) ->
undefined; undefined;
oauth_token_user({User, Server, _, _}) -> oauth_token_user({User, Server, _, _}) ->
jid:make(User, Server, <<>>). jid:make(User, Server).
is_admin(_Name, admin, _Extra) -> is_admin(_Name, admin, _Extra) ->
true; true;
@ -845,7 +845,7 @@ is_admin(_Name, Map, _extra) when is_map(Map) ->
is_admin(Name, Auth, Extra) -> is_admin(Name, Auth, Extra) ->
{ACLInfo, Server} = case Auth of {ACLInfo, Server} = case Auth of
{U, S, _, _} -> {U, S, _, _} ->
{Extra#{usr=>jid:split(jid:make(U, S, <<>>))}, S}; {Extra#{usr=>jid:split(jid:make(U, S))}, S};
_ -> _ ->
{Extra, global} {Extra, global}
end, end,

View File

@ -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:to_string(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].
@ -193,7 +193,7 @@ get_client_identity(Client, Ctx) -> {ok, {Ctx, {client, Client}}}.
verify_redirection_uri(_, _, Ctx) -> {ok, Ctx}. verify_redirection_uri(_, _, Ctx) -> {ok, Ctx}.
authenticate_user({User, Server}, Ctx) -> authenticate_user({User, Server}, Ctx) ->
case jid:make(User, Server, <<"">>) of case jid:make(User, Server) of
#jid{} = JID -> #jid{} = JID ->
Access = Access =
ejabberd_config:get_option( ejabberd_config:get_option(

View File

@ -246,7 +246,7 @@ get_privacy(User, Server) ->
-spec get_roster(binary(), binary()) -> [xmlel()]. -spec get_roster(binary(), binary()) -> [xmlel()].
get_roster(User, Server) -> get_roster(User, Server) ->
JID = jid:make(User, Server, <<>>), JID = jid:make(User, Server),
case mod_roster:get_roster(User, Server) of case mod_roster:get_roster(User, Server) of
[_|_] = Items -> [_|_] = Items ->
Subs = Subs =

View File

@ -189,7 +189,7 @@ bounce_offline_message(Acc) ->
-spec disconnect_removed_user(binary(), binary()) -> ok. -spec disconnect_removed_user(binary(), binary()) -> ok.
disconnect_removed_user(User, Server) -> disconnect_removed_user(User, Server) ->
route(jid:make(User, Server, <<"">>), {exit, <<"User removed">>}). route(jid:make(User, Server), {exit, <<"User removed">>}).
get_user_resources(User, Server) -> get_user_resources(User, Server) ->
LUser = jid:nodeprep(User), LUser = jid:nodeprep(User),
@ -739,7 +739,7 @@ check_max_sessions(LUser, LServer) ->
-spec get_max_user_sessions(binary(), binary()) -> infinity | non_neg_integer(). -spec get_max_user_sessions(binary(), binary()) -> infinity | non_neg_integer().
get_max_user_sessions(LUser, Host) -> get_max_user_sessions(LUser, Host) ->
case acl:match_rule(Host, max_user_sessions, case acl:match_rule(Host, max_user_sessions,
jid:make(LUser, Host, <<"">>)) jid:make(LUser, Host))
of of
Max when is_integer(Max) -> Max; Max when is_integer(Max) -> Max;
infinity -> infinity; infinity -> infinity;

View File

@ -102,7 +102,7 @@ get_acl_rule(_RPath, 'POST') ->
get_jid(Auth, HostHTTP, Method) -> get_jid(Auth, HostHTTP, Method) ->
case get_auth_admin(Auth, HostHTTP, [], Method) of case get_auth_admin(Auth, HostHTTP, [], Method) of
{ok, {User, Server}} -> {ok, {User, Server}} ->
jid:make(User, Server, <<"">>); jid:make(User, Server);
{unauthorized, Error} -> {unauthorized, Error} ->
?ERROR_MSG("Unauthorized ~p: ~p", [Auth, Error]), ?ERROR_MSG("Unauthorized ~p: ~p", [Auth, Error]),
throw({unauthorized, Auth}) throw({unauthorized, Auth})
@ -274,7 +274,7 @@ get_auth_account(HostOfRule, AccessRule, User, Server,
case ejabberd_auth:check_password(User, <<"">>, Server, Pass) of case ejabberd_auth:check_password(User, <<"">>, Server, Pass) of
true -> true ->
case acl:any_rules_allowed(HostOfRule, AccessRule, case acl:any_rules_allowed(HostOfRule, AccessRule,
jid:make(User, Server, <<"">>)) jid:make(User, Server))
of of
false -> {unauthorized, <<"unprivileged-account">>}; false -> {unauthorized, <<"unprivileged-account">>};
true -> {ok, {User, Server}} true -> {ok, {User, Server}}

View File

@ -638,7 +638,7 @@ create_delay_tag(TimeStamp, FromJID, Desc) when is_tuple(FromJID) ->
{<<"stamp">>, Stamp}], {<<"stamp">>, Stamp}],
children = Children}; children = Children};
create_delay_tag(DateTime, Host, Desc) when is_binary(Host) -> create_delay_tag(DateTime, Host, Desc) when is_binary(Host) ->
FromJID = jid:make(<<"">>, Host, <<"">>), FromJID = jid:make(Host),
create_delay_tag(DateTime, FromJID, Desc). create_delay_tag(DateTime, FromJID, Desc).
-type tz() :: {binary(), {integer(), integer()}} | {integer(), integer()} | utc. -type tz() :: {binary(), {integer(), integer()}} | {integer(), integer()} | utc.

View File

@ -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:to_string(jid:make(MUser, MServer))
|| {MUser, MServer} <- Members]. || {MUser, MServer} <- Members].
srg_user_add(User, Host, Group, GroupHost) -> srg_user_add(User, Host, Group, GroupHost) ->

View File

@ -630,7 +630,7 @@ announce_all(#message{to = To} = Packet) ->
Local = jid:make(To#jid.server), Local = jid:make(To#jid.server),
lists:foreach( lists:foreach(
fun({User, Server}) -> fun({User, Server}) ->
Dest = jid:make(User, Server, <<>>), Dest = jid:make(User, Server),
ejabberd_router:route( ejabberd_router:route(
xmpp:set_from_to(add_store_hint(Packet), Local, Dest)) xmpp:set_from_to(add_store_hint(Packet), Local, Dest))
end, ejabberd_auth:get_vh_registered_users(To#jid.lserver)). end, ejabberd_auth:get_vh_registered_users(To#jid.lserver)).
@ -639,7 +639,7 @@ announce_all_hosts_all(#message{to = To} = Packet) ->
Local = jid:make(To#jid.server), Local = jid:make(To#jid.server),
lists:foreach( lists:foreach(
fun({User, Server}) -> fun({User, Server}) ->
Dest = jid:make(User, Server, <<>>), Dest = jid:make(User, Server),
ejabberd_router:route( ejabberd_router:route(
xmpp:set_from_to(add_store_hint(Packet), Local, Dest)) xmpp:set_from_to(add_store_hint(Packet), Local, Dest))
end, ejabberd_auth:dirty_get_registered_users()). end, ejabberd_auth:dirty_get_registered_users()).

View File

@ -395,7 +395,7 @@ caps_write_fun(Host, Node, Features) ->
-spec make_my_disco_hash(binary()) -> binary(). -spec make_my_disco_hash(binary()) -> binary().
make_my_disco_hash(Host) -> make_my_disco_hash(Host) ->
JID = jid:make(<<"">>, Host, <<"">>), JID = jid:make(Host),
case {ejabberd_hooks:run_fold(disco_local_features, case {ejabberd_hooks:run_fold(disco_local_features,
Host, empty, [JID, JID, <<"">>, <<"">>]), Host, empty, [JID, JID, <<"">>, <<"">>]),
ejabberd_hooks:run_fold(disco_local_identity, Host, [], ejabberd_hooks:run_fold(disco_local_identity, Host, [],

View File

@ -928,7 +928,7 @@ remove_user(User, Server) ->
end, end,
sha1), sha1),
DocRoot1 = expand_host(expand_home(DocRoot), ServerHost), DocRoot1 = expand_host(expand_home(DocRoot), ServerHost),
UserStr = make_user_string(jid:make(User, Server, <<"">>), JIDinURL), UserStr = make_user_string(jid:make(User, Server), JIDinURL),
UserDir = str:join([DocRoot1, UserStr], <<$/>>), UserDir = str:join([DocRoot1, UserStr], <<$/>>),
case del_tree(UserDir) of case del_tree(UserDir) of
ok -> ok ->

View File

@ -73,7 +73,7 @@ update_table() ->
fun(#irc_custom{us_host = {_, H}}) -> H end, fun(#irc_custom{us_host = {_, H}}) -> H end,
fun(#irc_custom{us_host = {{U, S}, H}, fun(#irc_custom{us_host = {{U, S}, H},
data = Data} = R) -> data = Data} = R) ->
JID = jid:make(U, S, <<"">>), JID = jid:make(U, S),
R#irc_custom{us_host = {{iolist_to_binary(U), R#irc_custom{us_host = {{iolist_to_binary(U),
iolist_to_binary(S)}, iolist_to_binary(S)},
iolist_to_binary(H)}, iolist_to_binary(H)},

View File

@ -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:to_string(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;"),

View File

@ -732,7 +732,7 @@ get_room_occupants_number(Room, Host) ->
%% http://xmpp.org/extensions/xep-0249.html %% http://xmpp.org/extensions/xep-0249.html
send_direct_invitation(RoomName, RoomService, Password, Reason, UsersString) -> send_direct_invitation(RoomName, RoomService, Password, Reason, UsersString) ->
RoomJid = jid:make(RoomName, RoomService, <<"">>), RoomJid = jid:make(RoomName, RoomService),
XmlEl = build_invitation(Password, Reason, RoomJid), XmlEl = build_invitation(Password, Reason, RoomJid),
UsersStrings = get_users_to_invite(RoomJid, UsersString), UsersStrings = get_users_to_invite(RoomJid, UsersString),
[send_direct_invitation(RoomJid, UserStrings, XmlEl) [send_direct_invitation(RoomJid, UserStrings, XmlEl)

View File

@ -126,7 +126,7 @@ init([Host, ServerHost, Access, Room, HistorySize,
#state{host = Host, server_host = ServerHost, #state{host = Host, server_host = ServerHost,
access = Access, room = Room, access = Access, room = Room,
history = lqueue_new(HistorySize), history = lqueue_new(HistorySize),
jid = jid:make(Room, Host, <<"">>), jid = jid:make(Room, Host),
just_created = true, just_created = true,
room_shaper = Shaper}), room_shaper = Shaper}),
State1 = set_opts(DefRoomOpts, State), State1 = set_opts(DefRoomOpts, State),
@ -144,7 +144,7 @@ init([Host, ServerHost, Access, Room, HistorySize, RoomShaper, Opts]) ->
access = Access, access = Access,
room = Room, room = Room,
history = lqueue_new(HistorySize), history = lqueue_new(HistorySize),
jid = jid:make(Room, Host, <<"">>), jid = jid:make(Room, Host),
room_shaper = Shaper}), room_shaper = Shaper}),
add_to_log(room_existence, started, State), add_to_log(room_existence, started, State),
{ok, normal_state, State}. {ok, normal_state, State}.

View File

@ -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:to_string(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, "

View File

@ -251,7 +251,7 @@ store_offline_msg(Host, US, Msgs, Len, MaxOfflineMsgs) ->
get_max_user_messages(AccessRule, {User, Server}, Host) -> get_max_user_messages(AccessRule, {User, Server}, Host) ->
case acl:match_rule( case acl:match_rule(
Host, AccessRule, jid:make(User, Server, <<"">>)) of Host, AccessRule, jid:make(User, Server)) of
Max when is_integer(Max) -> Max; Max when is_integer(Max) -> Max;
infinity -> infinity; infinity -> infinity;
_ -> ?MAX_USER_MESSAGES _ -> ?MAX_USER_MESSAGES
@ -817,7 +817,7 @@ get_messages_subset2(Max, Length, MsgsAll) ->
{MsgsFirstN, Msgs2} = lists:split(FirstN, MsgsAll), {MsgsFirstN, Msgs2} = lists:split(FirstN, MsgsAll),
MsgsLastN = lists:nthtail(Length - FirstN - FirstN, MsgsLastN = lists:nthtail(Length - FirstN - FirstN,
Msgs2), Msgs2),
NoJID = jid:make(<<"...">>, <<"...">>, <<"">>), NoJID = jid:make(<<"...">>, <<"...">>),
Seq = <<"0">>, Seq = <<"0">>,
IntermediateMsg = #xmlel{name = <<"...">>, attrs = [], IntermediateMsg = #xmlel{name = <<"...">>, attrs = [],
children = []}, children = []},

View File

@ -414,7 +414,7 @@ user_receive_packet({#iq{type = set, meta = #{privacy_updated_list := New}} = IQ
true -> true ->
State State
end, end,
From = jid:make(U, S, <<"">>), From = jid:make(U, S),
To = jid:make(U, S, R), To = jid:make(U, S, R),
{xmpp:set_from_to(IQ, From, To), State1}; {xmpp:set_from_to(IQ, From, To), State1};
user_receive_packet(Acc) -> user_receive_packet(Acc) ->

View File

@ -723,7 +723,7 @@ presence(ServerHost, Presence) ->
binary(), binary(), jid(), binary(), binary(), jid(),
subscribed | unsubscribed | subscribe | unsubscribe) -> boolean(). subscribed | unsubscribed | subscribe | unsubscribe) -> boolean().
out_subscription(User, Server, JID, subscribed) -> out_subscription(User, Server, JID, subscribed) ->
Owner = jid:make(User, Server, <<>>), Owner = jid:make(User, Server),
{PUser, PServer, PResource} = jid:tolower(JID), {PUser, PServer, PResource} = jid:tolower(JID),
PResources = case PResource of PResources = case PResource of
<<>> -> user_resources(PUser, PServer); <<>> -> user_resources(PUser, PServer);
@ -738,7 +738,7 @@ out_subscription(_, _, _, _) ->
subscribe | subscribed | unsubscribe | unsubscribed, subscribe | subscribed | unsubscribe | unsubscribed,
binary()) -> true. binary()) -> true.
in_subscription(_, User, Server, Owner, unsubscribed, _) -> in_subscription(_, User, Server, Owner, unsubscribed, _) ->
unsubscribe_user(jid:make(User, Server, <<>>), Owner), unsubscribe_user(jid:make(User, Server), Owner),
true; true;
in_subscription(_, _, _, _, _, _) -> in_subscription(_, _, _, _, _, _) ->
true. true.
@ -789,7 +789,7 @@ unsubscribe_user(Host, Entity, Owner) ->
remove_user(User, Server) -> remove_user(User, Server) ->
LUser = jid:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jid:nameprep(Server), LServer = jid:nameprep(Server),
Entity = jid:make(LUser, LServer, <<>>), Entity = jid:make(LUser, LServer),
Host = host(LServer), Host = host(LServer),
HomeTreeBase = <<"/home/", LServer/binary, "/", LUser/binary>>, HomeTreeBase = <<"/home/", LServer/binary, "/", LUser/binary>>,
spawn(fun () -> spawn(fun () ->
@ -3023,7 +3023,7 @@ broadcast_stanza({LUser, LServer, LResource}, Publisher, Node, Nidx, Type, NodeO
%% See XEP-0163 1.1 section 4.3.1 %% See XEP-0163 1.1 section 4.3.1
ejabberd_sm:route(jid:make(LUser, LServer, SenderResource), ejabberd_sm:route(jid:make(LUser, LServer, SenderResource),
{pep_message, <<((Node))/binary, "+notify">>, {pep_message, <<((Node))/binary, "+notify">>,
jid:make(LUser, LServer, <<"">>), jid:make(LUser, LServer),
add_extended_headers( add_extended_headers(
Stanza, extended_headers([Publisher]))}); Stanza, extended_headers([Publisher]))});
broadcast_stanza(Host, _Publisher, Node, Nidx, Type, NodeOptions, SubsByDepth, NotifyType, BaseStanza, SHIM) -> broadcast_stanza(Host, _Publisher, Node, Nidx, Type, NodeOptions, SubsByDepth, NotifyType, BaseStanza, SHIM) ->

View File

@ -316,7 +316,7 @@ try_register(User, Server, Password, SourceRaw, Lang) ->
case jid:is_nodename(User) of case jid:is_nodename(User) of
false -> {error, xmpp:err_bad_request(<<"Malformed username">>, Lang)}; false -> {error, xmpp:err_bad_request(<<"Malformed username">>, Lang)};
_ -> _ ->
JID = jid:make(User, Server, <<"">>), JID = jid:make(User, Server),
Access = gen_mod:get_module_opt(Server, ?MODULE, access, Access = gen_mod:get_module_opt(Server, ?MODULE, access,
fun(A) -> A end, fun(A) -> A end,
all), all),

View File

@ -106,7 +106,7 @@ process([<<"new">>],
lang = Lang, host = _HTTPHost}) -> lang = Lang, host = _HTTPHost}) ->
case form_new_post(Q) of case form_new_post(Q) of
{success, ok, {Username, Host, _Password}} -> {success, ok, {Username, Host, _Password}} ->
Jid = jid:make(Username, Host, <<"">>), Jid = jid:make(Username, Host),
mod_register:send_registration_notifications(?MODULE, Jid, Ip), mod_register:send_registration_notifications(?MODULE, Jid, Ip),
Text = (?T(<<"Your Jabber account was successfully " Text = (?T(<<"Your Jabber account was successfully "
"created.">>)), "created.">>)),
@ -499,7 +499,7 @@ register_account(Username, Host, Password) ->
Access = gen_mod:get_module_opt(Host, mod_register, access, Access = gen_mod:get_module_opt(Host, mod_register, access,
fun(A) -> A end, fun(A) -> A end,
all), all),
case jid:make(Username, Host, <<"">>) of case jid:make(Username, Host) of
error -> {error, invalid_jid}; error -> {error, invalid_jid};
JID -> JID ->
case acl:match_rule(Host, Access, JID) of case acl:match_rule(Host, Access, JID) of

View File

@ -643,7 +643,7 @@ process_subscription(Direction, User, Server, JID1,
_ -> _ ->
ejabberd_router:route( ejabberd_router:route(
#presence{type = AutoReply, #presence{type = AutoReply,
from = jid:make(User, Server, <<"">>), from = jid:make(User, Server),
to = JID1}) to = JID1})
end, end,
case Push of case Push of
@ -653,7 +653,7 @@ process_subscription(Direction, User, Server, JID1,
ok; ok;
true -> true ->
push_item(User, Server, push_item(User, Server,
jid:make(User, Server, <<"">>), Item) jid:make(User, Server), Item)
end, end,
true; true;
none -> false none -> false
@ -1068,7 +1068,7 @@ user_roster_parse_query(User, Server, Items, Query) ->
user_roster_subscribe_jid(User, Server, JID) -> user_roster_subscribe_jid(User, Server, JID) ->
out_subscription(User, Server, JID, subscribe), out_subscription(User, Server, JID, subscribe),
UJID = jid:make(User, Server, <<"">>), UJID = jid:make(User, Server),
ejabberd_router:route(#presence{from = UJID, to = JID, type = subscribe}). ejabberd_router:route(#presence{from = UJID, to = JID, type = subscribe}).
user_roster_item_parse_query(User, Server, Items, user_roster_item_parse_query(User, Server, Items,
@ -1083,7 +1083,7 @@ user_roster_item_parse_query(User, Server, Items,
JID1 = jid:make(JID), JID1 = jid:make(JID),
out_subscription(User, Server, JID1, out_subscription(User, Server, JID1,
subscribed), subscribed),
UJID = jid:make(User, Server, <<"">>), UJID = jid:make(User, Server),
ejabberd_router:route( ejabberd_router:route(
#presence{from = UJID, to = JID1, #presence{from = UJID, to = JID1,
type = subscribed}), type = subscribed}),

View File

@ -240,12 +240,10 @@ process_item(RosterItem, Host) ->
%% existing roster groups. %% existing roster groups.
[] -> [] ->
mod_roster:out_subscription(UserTo, ServerTo, mod_roster:out_subscription(UserTo, ServerTo,
jid:make(UserFrom, ServerFrom, jid:make(UserFrom, ServerFrom),
<<"">>),
unsubscribe), unsubscribe),
mod_roster:in_subscription(false, UserFrom, ServerFrom, mod_roster:in_subscription(false, UserFrom, ServerFrom,
jid:make(UserTo, ServerTo, jid:make(UserTo, ServerTo),
<<"">>),
unsubscribe, <<"">>), unsubscribe, <<"">>),
RosterItem#roster{subscription = both, ask = none}; RosterItem#roster{subscription = both, ask = none};
%% If so, it means the user wants to add that contact %% If so, it means the user wants to add that contact
@ -269,8 +267,8 @@ set_new_rosteritems(UserFrom, ServerFrom, UserTo,
RIFrom = build_roster_record(UserFrom, ServerFrom, RIFrom = build_roster_record(UserFrom, ServerFrom,
UserTo, ServerTo, NameTo, GroupsFrom), UserTo, ServerTo, NameTo, GroupsFrom),
set_item(UserFrom, ServerFrom, ResourceTo, RIFrom), set_item(UserFrom, ServerFrom, ResourceTo, RIFrom),
JIDTo = jid:make(UserTo, ServerTo, <<"">>), JIDTo = jid:make(UserTo, ServerTo),
JIDFrom = jid:make(UserFrom, ServerFrom, <<"">>), JIDFrom = jid:make(UserFrom, ServerFrom),
RITo = build_roster_record(UserTo, ServerTo, UserFrom, RITo = build_roster_record(UserTo, ServerTo, UserFrom,
ServerFrom, UserFrom, []), ServerFrom, UserFrom, []),
set_item(UserTo, ServerTo, <<"">>, RITo), set_item(UserTo, ServerTo, <<"">>, RITo),
@ -360,7 +358,7 @@ in_subscription(Acc, User, Server, JID, Type,
out_subscription(UserFrom, ServerFrom, JIDTo, out_subscription(UserFrom, ServerFrom, JIDTo,
unsubscribed) -> unsubscribed) ->
#jid{luser = UserTo, lserver = ServerTo} = JIDTo, #jid{luser = UserTo, lserver = ServerTo} = JIDTo,
JIDFrom = jid:make(UserFrom, ServerFrom, <<"">>), JIDFrom = jid:make(UserFrom, ServerFrom),
mod_roster:out_subscription(UserTo, ServerTo, JIDFrom, mod_roster:out_subscription(UserTo, ServerTo, JIDFrom,
unsubscribe), unsubscribe),
mod_roster:in_subscription(false, UserFrom, ServerFrom, mod_roster:in_subscription(false, UserFrom, ServerFrom,
@ -1054,7 +1052,7 @@ split_grouphost(Host, Group) ->
end. end.
broadcast_subscription(User, Server, ContactJid, Subscription) -> broadcast_subscription(User, Server, ContactJid, Subscription) ->
ejabberd_sm:route(jid:make(User, Server, <<"">>), ejabberd_sm:route(jid:make(User, Server),
{item, ContactJid, Subscription}). {item, ContactJid, Subscription}).
displayed_groups_update(Members, DisplayedGroups, Subscription) -> displayed_groups_update(Members, DisplayedGroups, Subscription) ->

View File

@ -182,9 +182,7 @@ export(_Server) ->
{sr_user, {sr_user,
fun(Host, #sr_user{us = {U, S}, group_host = {Group, LServer}}) fun(Host, #sr_user{us = {U, S}, group_host = {Group, LServer}})
when LServer == Host -> when LServer == Host ->
SJID = jid:to_string( SJID = make_jid_s(U, S),
jid:tolower(
jid:make(U, S, <<"">>))),
[?SQL("select @(jid)s from sr_user where jid=%(SJID)s" [?SQL("select @(jid)s from sr_user where jid=%(SJID)s"
" and grp=%(Group)s;"), " and grp=%(Group)s;"),
?SQL("insert into sr_user(jid, grp) values (" ?SQL("insert into sr_user(jid, grp) values ("
@ -200,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:to_string(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).