Skip to content

Commit

Permalink
Upgrade to the latest mongoose_jid
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonVides committed Apr 16, 2022
1 parent 4f6a845 commit 8c30878
Show file tree
Hide file tree
Showing 34 changed files with 97 additions and 112 deletions.
2 changes: 1 addition & 1 deletion big_tests/rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
{csv, "3.0.3", {pkg, csve}},
{amqp_client, "3.9.5"},
{esip, "1.0.43"},
{jid, "1.1.1", {pkg, mongoose_jid}}
{jid, {git, "https://github.com/esl/mongoose_jid.git", {branch, "reduce_jid_struct"}}}
]}.
7 changes: 4 additions & 3 deletions big_tests/rebar.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
{<<"fusco">>,{pkg,<<"fusco">>,<<"0.1.1">>},0},
{<<"goldrush">>,{pkg,<<"goldrush">>,<<"0.1.9">>},1},
{<<"gun">>,{pkg,<<"gun">>,<<"2.0.0-rc.2">>},0},
{<<"jid">>,{pkg,<<"mongoose_jid">>,<<"1.1.1">>},0},
{<<"jid">>,
{git,"https://github.com/esl/mongoose_jid.git",
{ref,"648f1c9ea0163195b3c8c734a3a335410dd15412"}},
0},
{<<"jiffy">>,{pkg,<<"jiffy">>,<<"1.1.1">>},0},
{<<"jsx">>,{pkg,<<"jsx">>,<<"3.1.0">>},2},
{<<"lager">>,{pkg,<<"lager">>,<<"3.9.2">>},0},
Expand Down Expand Up @@ -50,7 +53,6 @@
{<<"fusco">>, <<"3DD6A90151DFEF30EA1937CC44E9A59177C0094918388D9BCAA2F2DC5E2AE4AA">>},
{<<"goldrush">>, <<"F06E5D5F1277DA5C413E84D5A2924174182FB108DABB39D5EC548B27424CD106">>},
{<<"gun">>, <<"7C489A32DEDCCB77B6E82D1F3C5A7DADFBFA004EC14E322CDB5E579C438632D2">>},
{<<"jid">>, <<"C9D92768FBC120C717E944AFE523FA0062C5B665E4D776724B2F8E54831AB2CA">>},
{<<"jiffy">>, <<"ACA10F47AA91697BF24AB9582C74E00E8E95474C7EF9F76D4F1A338D0F5DE21B">>},
{<<"jsx">>, <<"D12516BAA0BB23A59BB35DCCAF02A1BD08243FCBB9EFE24F2D9D056CCFF71268">>},
{<<"lager">>, <<"4CAB289120EB24964E3886BD22323CB5FEFE4510C076992A23AD18CF85413D8C">>},
Expand Down Expand Up @@ -82,7 +84,6 @@
{<<"fusco">>, <<"6343551BD1E824F2A6CA85E1158C5B37C320FD449FBFEC7450A73F192AAF9022">>},
{<<"goldrush">>, <<"99CB4128CFFCB3227581E5D4D803D5413FA643F4EB96523F77D9E6937D994CEB">>},
{<<"gun">>, <<"6B9D1EAE146410D727140DBF8B404B9631302ECC2066D1D12F22097AD7D254FC">>},
{<<"jid">>, <<"61EDDBAC9908747DA29F7C79545C744C31A25652CCB53248E684DBB083EFBE9A">>},
{<<"jiffy">>, <<"62E1F0581C3C19C33A725C781DFA88410D8BFF1BBAFC3885A2552286B4785C4C">>},
{<<"jsx">>, <<"0C5CC8FDC11B53CC25CF65AC6705AD39E54ECC56D1C22E4ADB8F5A53FB9427F3">>},
{<<"lager">>, <<"7F904D9E87A8CB7E66156ED31768D1C8E26EBA1D54F4BC85B1AA4AC1F6340C28">>},
Expand Down
4 changes: 2 additions & 2 deletions big_tests/tests/accounts_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ registration_conflict(Config) ->
admin_notify(Config) ->
[{Name1, UserSpec1}, {Name2, UserSpec2}] = escalus_users:get_users([alice, bob]),
[{_, AdminSpec}] = escalus_users:get_users([admin]),
[Username1, _Server1, _Pass1] = escalus_users:get_usp(Config, UserSpec1),
[Username2, _Server2, _Pass2] = escalus_users:get_usp(Config, UserSpec2),
Username1 = jid:str_tolower(escalus_users:get_username(Config, UserSpec1)),
Username2 = jid:str_tolower(escalus_users:get_username(Config, UserSpec2)),
[AdminU, AdminS, AdminP] = escalus_users:get_usp(Config, AdminSpec),

rpc(mim(), ejabberd_auth, try_register, [mongoose_helper:make_jid(AdminU, AdminS), AdminP]),
Expand Down
2 changes: 1 addition & 1 deletion big_tests/tests/domain_removal_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ connect_and_disconnect(Spec) ->
escalus_connection:stop(Client).

does_cached_user_exist(Config, User) ->
Jid = #jid{server = Domain} = jid:from_binary(escalus_users:get_jid(Config, User)),
Jid = #jid{lserver = Domain} = jid:from_binary(escalus_users:get_jid(Config, User)),
HostType = domain_to_host_type(mim(), Domain),
rpc(mim(), mod_cache_users, does_cached_user_exist, [false, HostType, Jid, stored]).

Expand Down
2 changes: 1 addition & 1 deletion big_tests/tests/inbox_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1398,7 +1398,7 @@ rpc_stop_hook_handler(HookExtra, HostType) ->
hook_handler_fn(Acc,
#{args := [_HostType, User, _Stored]} = _Params,
#{test_case_pid := Pid} = _Extra) ->
Pid ! {input, User#jid.user},
Pid ! {input, User#jid.luser},
{ok, Acc}.

verify_hook_listener(RoomName) ->
Expand Down
9 changes: 4 additions & 5 deletions big_tests/tests/mongooseimctl_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ remove_old_messages_test(Config) ->
OldTimestamp = fallback_timestamp(10, os:system_time(microsecond)),
OfflineOld = generate_offline_message(JidRecordAlice, JidRecordBob, Msg1, OldTimestamp),
OfflineNew = generate_offline_message(JidRecordAlice, JidRecordBob, Msg2, os:system_time(microsecond)),
{jid, _, _, _, LUser, LServer, _} = JidRecordBob,
{LUser, LServer} = jid:to_lus(JidRecordBob),
HostType = host_type(),
rpc_call(mod_offline_backend, write_messages, [host_type(), LUser, LServer, [OfflineOld, OfflineNew]]),
%% when
Expand Down Expand Up @@ -1269,7 +1269,7 @@ remove_expired_messages_test(Config) ->
JidRecordKate, Msg4,
OldTimestamp,
ExpirationTimeFuture),
{jid, _, _, _, LUser, LServer, _} = JidRecordKate,
{LUser, LServer} = jid:to_lus(JidRecordKate),
Args = [OfflineOld, OfflineNow, OfflineFuture, OfflineFuture2],
HostType = host_type(),
rpc_call(mod_offline_backend, write_messages, [HostType, LUser, LServer, Args]),
Expand All @@ -1290,12 +1290,12 @@ nick_to_jid(UserName, Config) when is_atom(UserName) ->
escalus_utils:jid_to_lower(escalus_users:get_jid(Config, UserSpec)).

generate_offline_message(From, To, Msg, TimeStamp) ->
{jid, _, _, _, LUser, LServer, _} = To,
{LUser, LServer} = jid:to_lus(To),
#offline_msg{us = {LUser, LServer}, timestamp = TimeStamp, expire = never,
from = From, to = To, packet = Msg}.

generate_offline_expired_message(From, To, Msg, TimeStamp, ExpirationTime) ->
{jid, _, _, _, LUser, LServer, _} = To,
{LUser, LServer} = jid:to_lus(To),
#offline_msg{us = {LUser, LServer}, timestamp = TimeStamp,
expire = ExpirationTime, from = From, to = To, packet = Msg}.

Expand Down Expand Up @@ -1336,7 +1336,6 @@ delete_users(_Config) ->

match_user_status(Users, StatusTxt) ->
Statuses = string:tokens(StatusTxt, "\n"),

true = (length(Users) == length(Statuses)),
match_user_status2(Users, Statuses).

Expand Down
4 changes: 2 additions & 2 deletions big_tests/tests/muc_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ generate_rpc_jid({_,User}) ->
{server, Server} = lists:keyfind(server, 1, User),
LUsername = escalus_utils:jid_to_lower(Username),
LServer = escalus_utils:jid_to_lower(Server),
{jid, Username, Server, <<"rpc">>, LUsername, LServer, <<"rpc">>}.
jid:make_noprep(LUsername, LServer, <<"rpc">>).

create_instant_room(Room, From, Nick, Opts) ->
ServerHost = ct:get_config({hosts, mim, domain}),
Expand All @@ -170,7 +170,7 @@ destroy_room(Config) ->
destroy_room(muc_host(), ?config(room, Config)).

destroy_room(Host, Room) when is_binary(Host), is_binary(Room) ->
Room1 = rpc(mim(), jid, nodeprep, [Room]),
Room1 = jid:nodeprep(Room),
case rpc(mim(), ets, lookup, [muc_online_room, {Room1, Host}]) of
[{_,_,Pid}|_] ->
%% @TODO related to gen_fsm_compat: after migration to gen_statem
Expand Down
7 changes: 3 additions & 4 deletions big_tests/tests/oauth_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ token_login_failure(Config, User, Token) ->

get_revoked_token(Config, UserName) ->
BJID = escalus_users:get_jid(Config, UserName),
JID = rpc(mim(), jid, from_binary, [BJID]),
JID = jid:from_binary(BJID),
HostType = domain_helper:host_type(),
Token = rpc(mim(), mod_auth_token, token, [HostType, JID, refresh]),
ValidSeqNo = rpc(mim(), mod_auth_token_rdbms, get_valid_sequence_number, [HostType, JID]),
Expand Down Expand Up @@ -280,7 +280,7 @@ token_revocation_test(Config) ->
get_owner_seqno_to_revoke(Config, User) ->
{_, RefreshToken} = request_tokens_once_logged_in_impl(Config, User),
[_, BOwner, _, SeqNo, _] = binary:split(RefreshToken, <<0>>, [global]),
Owner = rpc(mim(), jid, from_binary, [BOwner]),
Owner = jid:from_binary(BOwner),
{Owner, binary_to_integer(SeqNo), RefreshToken}.

revoke_token(Owner) ->
Expand Down Expand Up @@ -433,8 +433,7 @@ make_provision_token(Config, User, VCard) ->
ExpiryFarInTheFuture = {{2055, 10, 27}, {10, 54, 22}},
Username = escalus_users:get_username(Config, User),
Domain = escalus_users:get_server(Config, User),
ServerSideJID = {jid, Username, Domain, <<>>,
Username, Domain, <<>>},
ServerSideJID = jid:make(Username, Domain, <<>>),
T0 = {token, provision,
ExpiryFarInTheFuture,
ServerSideJID,
Expand Down
2 changes: 1 addition & 1 deletion big_tests/tests/vcard_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@ delete_vcards(Config) ->

get_jid_record(JID) ->
[User, Server] = binary:split(JID, <<"@">>),
{jid, User, Server, <<"">>, User, Server, <<"">>}.
jid:make_bare(User, Server).

vcard_rpc(JID, Stanza) ->
Res = rpc(mim(), ejabberd_router, route, [JID, JID, Stanza]),
Expand Down
4 changes: 2 additions & 2 deletions include/mod_roster.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
%%%
%%%----------------------------------------------------------------------

-record(roster, {usj :: {jid:luser(), jid:lserver(), jid:simple_jid()},
-record(roster, {usj :: {jid:luser(), jid:lserver(), jid:ljid()},
us :: {jid:luser(), jid:lserver()},
jid :: jid:simple_jid(),
jid :: jid:ljid(),
name = <<>> :: binary(),
subscription = none :: both | from | to | none | remove,
ask = none :: subscribe | unsubscribe | in | out | both | none,
Expand Down
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
{base16, "2.0.1"},
{exml, "3.1.1", {pkg, hexml}},
{jiffy, "1.1.1"},
{jid, "1.1.1", {pkg, mongoose_jid}},
{jid, {git, "https://github.com/esl/mongoose_jid.git", {branch, "reduce_jid_struct"}}},
{tomerl, "0.5.0"},
{bbmustache, "1.12.2"},
{erl_csv, "0.2.0"},
Expand Down
7 changes: 4 additions & 3 deletions rebar.lock
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@
{ref,"ad3dbab419762fc2d5821abb88b989da006b85c6"}},
2},
{<<"idna">>,{pkg,<<"idna">>,<<"6.1.1">>},0},
{<<"jid">>,{pkg,<<"mongoose_jid">>,<<"1.1.1">>},0},
{<<"jid">>,
{git,"https://github.com/esl/mongoose_jid.git",
{ref,"648f1c9ea0163195b3c8c734a3a335410dd15412"}},
0},
{<<"jiffy">>,{pkg,<<"jiffy">>,<<"1.1.1">>},0},
{<<"jsx">>,{pkg,<<"jsx">>,<<"2.9.0">>},1},
{<<"jwerl">>,
Expand Down Expand Up @@ -165,7 +168,6 @@
{<<"gun">>, <<"CF8B51BEB36C22B9C8DF1921E3F2BC4D2B1F68B49AD4FBC64E91875AA14E16B4">>},
{<<"hackney">>, <<"24EDC8CD2B28E1C652593833862435C80661834F6C9344E84B6A2255E7AEEF03">>},
{<<"idna">>, <<"8A63070E9F7D0C62EB9D9FCB360A7DE382448200FBBD1B106CC96D3D8099DF8D">>},
{<<"jid">>, <<"C9D92768FBC120C717E944AFE523FA0062C5B665E4D776724B2F8E54831AB2CA">>},
{<<"jiffy">>, <<"ACA10F47AA91697BF24AB9582C74E00E8E95474C7EF9F76D4F1A338D0F5DE21B">>},
{<<"jsx">>, <<"D2F6E5F069C00266CAD52FB15D87C428579EA4D7D73A33669E12679E203329DD">>},
{<<"lager">>, <<"4CAB289120EB24964E3886BD22323CB5FEFE4510C076992A23AD18CF85413D8C">>},
Expand Down Expand Up @@ -227,7 +229,6 @@
{<<"gun">>, <<"3106CE167F9C9723F849E4FB54EA4A4D814E3996AE243A1C828B256E749041E0">>},
{<<"hackney">>, <<"4D605D33DD07EE1B82B105033CCCB02379515105FCEB1850746591814B00C205">>},
{<<"idna">>, <<"92376EB7894412ED19AC475E4A86F7B413C1B9FBB5BD16DCCD57934157944CEA">>},
{<<"jid">>, <<"61EDDBAC9908747DA29F7C79545C744C31A25652CCB53248E684DBB083EFBE9A">>},
{<<"jiffy">>, <<"62E1F0581C3C19C33A725C781DFA88410D8BFF1BBAFC3885A2552286B4785C4C">>},
{<<"jsx">>, <<"8EE1DB1CABAFDD578A2776A6AAAE87C2A8CE54B47B59E9EC7DAB5D7EB71CD8DC">>},
{<<"lager">>, <<"7F904D9E87A8CB7E66156ED31768D1C8E26EBA1D54F4BC85B1AA4AC1F6340C28">>},
Expand Down
4 changes: 2 additions & 2 deletions src/admin_extra/service_admin_extra_roster.erl
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,14 @@ push_roster_item(JID, #jid{luser = U, lserver = S} = RemJID, Action) ->
end, ejabberd_sm:get_user_resources(JID)).

-spec build_roster_item(jid:jid(), push_action()) -> exml:element().
build_roster_item(#jid{resource = <<>>} = JID, {add, Nick, Subs, Group}) ->
build_roster_item(#jid{lresource = <<>>} = JID, {add, Nick, Subs, Group}) ->
#xmlel{ name = <<"item">>,
attrs = [{<<"jid">>, jid:to_binary(JID)},
{<<"name">>, Nick},
{<<"subscription">>, Subs}],
children = [#xmlel{name = <<"group">>, children = [#xmlcdata{content = Group}]}]
};
build_roster_item(#jid{resource = <<>>} = JID, remove) ->
build_roster_item(#jid{lresource = <<>>} = JID, remove) ->
#xmlel{ name = <<"item">>,
attrs = [{<<"jid">>, jid:to_binary(JID)},
{<<"subscription">>, <<"remove">>}]};
Expand Down
4 changes: 2 additions & 2 deletions src/admin_extra/service_admin_extra_stanza.erl
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ send_packet_all_resources(FromJID, ToJIDString, Packet) when is_binary(ToJIDStri
{ok, ""}
end;
send_packet_all_resources(#jid{} = FromJID, #jid{} = ToJID, Packet) ->
case ToJID#jid.resource of
<<"">> ->
case ToJID#jid.lresource of
<<>> ->
send_packet_all_resources_2(FromJID, ToJID, Packet),
{ok, ""};
_Res ->
Expand Down
15 changes: 5 additions & 10 deletions src/ejabberd_c2s.erl
Original file line number Diff line number Diff line change
Expand Up @@ -887,15 +887,13 @@ process_outgoing_stanza(Acc, StateData) ->
fsm_next_state(session_established, NState).

process_outgoing_stanza(Acc, ToJID, <<"presence">>, StateData) ->
#jid{user = User, server = Server} = FromJID = mongoose_acc:from_jid(Acc),
FromJID = mongoose_acc:from_jid(Acc),
HostType = mongoose_acc:host_type(Acc),
Res = mongoose_hooks:c2s_update_presence(HostType, Acc),
El = mongoose_acc:element(Res),
Res1 = mongoose_hooks:user_send_packet(Res, FromJID, ToJID, El),
{_Acc1, NState} = case ToJID of
#jid{user = User,
server = Server,
resource = <<>>} ->
{_Acc1, NState} = case jid:are_bare_equal(FromJID, ToJID) of
true ->
presence_update(Res1, FromJID, StateData);
_ ->
presence_track(Res1, StateData)
Expand Down Expand Up @@ -994,13 +992,10 @@ handle_event(_Event, StateName, StateData) ->
-> {'reply', Reply :: [any()], statename(), state()}
| {'reply', Reply :: 'ok' | {_, _, _, _}, statename(), state(), timeout()}.
handle_sync_event(get_presence, _From, StateName, StateData) ->
User = StateData#state.user,
#jid{luser = User, lresource = Resource} = StateData#state.jid,
PresLast = StateData#state.pres_last,

Show = get_showtag(PresLast),
Status = get_statustag(PresLast),
Resource = StateData#state.resource,

Reply = {User, Resource, Show, Status},
fsm_reply(Reply, StateName, StateData);
handle_sync_event(get_info, _From, StateName, StateData) ->
Expand Down Expand Up @@ -3270,7 +3265,7 @@ handle_sasl_success(State, Creds) ->
authenticated = true,
auth_module = AuthModule,
user = User,
jid = jid:make(User, Server, <<>>)},
jid = jid:make_bare(User, Server)},
?LOG_INFO(#{what => auth_success, text => <<"Accepted SASL authentication">>,
stream_id => StreamID, auth_module => AuthModule,
c2s_state => NewState}),
Expand Down
2 changes: 1 addition & 1 deletion src/jingle_sip/jingle_sip_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ maybe_rewrite_to_phone(Acc) ->
ToRewrite = gen_mod:get_module_opt(HostType, mod_jingle_sip, username_to_phone),
case lists:keyfind(ToUser, 1, ToRewrite) of
{ToUser, PhoneNumber} ->
JID#jid{user = PhoneNumber, luser = PhoneNumber};
JID#jid{luser = PhoneNumber};
_ ->
JID
end.
Expand Down
8 changes: 4 additions & 4 deletions src/mam/mod_mam.erl
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ get_personal_data(Acc, HostType, ArcJID) ->
delete_archive(Server, User)
when is_binary(Server), is_binary(User) ->
?LOG_DEBUG(#{what => mam_delete_archive, user => User, server => Server}),
ArcJID = jid:make(User, Server, <<>>),
ArcJID = jid:make_bare(User, Server),
HostType = jid_to_host_type(ArcJID),
ArcID = archive_id_int(HostType, ArcJID),
remove_archive_hook(HostType, ArcID, ArcJID),
Expand All @@ -185,21 +185,21 @@ delete_archive(Server, User)
-spec archive_size(jid:server(), jid:user()) -> integer().
archive_size(Server, User)
when is_binary(Server), is_binary(User) ->
ArcJID = jid:make(User, Server, <<>>),
ArcJID = jid:make_bare(User, Server),
HostType = jid_to_host_type(ArcJID),
ArcID = archive_id_int(HostType, ArcJID),
archive_size(HostType, ArcID, ArcJID).

-spec archive_size_with_host_type(host_type(), jid:server(), jid:user()) -> integer().
archive_size_with_host_type(HostType, Server, User) ->
ArcJID = jid:make(User, Server, <<>>),
ArcJID = jid:make_bare(User, Server),
ArcID = archive_id_int(HostType, ArcJID),
archive_size(HostType, ArcID, ArcJID).

-spec archive_id(jid:server(), jid:user()) -> integer() | undefined.
archive_id(Server, User)
when is_binary(Server), is_binary(User) ->
ArcJID = jid:make(User, Server, <<>>),
ArcJID = jid:make_bare(User, Server),
HostType = jid_to_host_type(ArcJID),
archive_id_int(HostType, ArcJID).

Expand Down
6 changes: 3 additions & 3 deletions src/mam/mod_mam_muc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,22 @@ get_personal_data(Acc, HostType, ArcJID) ->
-spec delete_archive(jid:server(), jid:user()) -> ok.
delete_archive(MucHost, RoomName) when is_binary(MucHost), is_binary(RoomName) ->
?LOG_DEBUG(#{what => mam_delete_room, room => RoomName, sub_host => MucHost}),
ArcJID = jid:make(RoomName, MucHost, <<>>),
ArcJID = jid:make_bare(RoomName, MucHost),
HostType = mod_muc_light_utils:room_jid_to_host_type(ArcJID),
ArcID = archive_id_int(HostType, ArcJID),
remove_archive(HostType, ArcID, ArcJID),
ok.

-spec archive_size(jid:server(), jid:user()) -> integer().
archive_size(MucHost, RoomName) when is_binary(MucHost), is_binary(RoomName) ->
ArcJID = jid:make(RoomName, MucHost, <<>>),
ArcJID = jid:make_bare(RoomName, MucHost),
HostType = mod_muc_light_utils:room_jid_to_host_type(ArcJID),
ArcID = archive_id_int(HostType, ArcJID),
archive_size(HostType, ArcID, ArcJID).

-spec archive_id(jid:server(), jid:user()) -> integer().
archive_id(MucHost, RoomName) when is_binary(MucHost), is_binary(RoomName) ->
ArcJID = jid:make(RoomName, MucHost, <<>>),
ArcJID = jid:make_bare(RoomName, MucHost),
HostType = mod_muc_light_utils:room_jid_to_host_type(ArcJID),
archive_id_int(HostType, ArcJID).

Expand Down
7 changes: 3 additions & 4 deletions src/mod_disco.erl
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,11 @@ sm_error(_From, _To) ->
mongoose_xmpp_errors:not_allowed().

-spec get_user_resources(jid:jid()) -> [mongoose_disco:item()].
get_user_resources(JID) ->
#jid{user = User, server = Server} = JID,
get_user_resources(JID = #jid{luser = LUser}) ->
Rs = ejabberd_sm:get_user_resources(JID),
lists:map(fun(R) ->
BJID = jid:to_binary({User, Server, R}),
#{jid => BJID, name => User}
BJID = jid:to_binary(jid:replace_resource_noprep(JID, R)),
#{jid => BJID, name => LUser}
end, lists:sort(Rs)).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down
2 changes: 1 addition & 1 deletion src/mod_muc_commands.erl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ create_instant_room(Domain, Name, Owner, Nick) ->
%% the HTTP API, they will certainly recieve stanzas as a
%% consequence, even if their client(s) did not initiate this.
OwnerJID = jid:binary_to_bare(Owner),
BareRoomJID = #jid{server = MUCDomain} = room_jid(Domain, Name),
BareRoomJID = #jid{lserver = MUCDomain} = room_jid(Domain, Name),
UserRoomJID = jid:make(Name, MUCDomain, Nick),
%% Send presence to create a room.
ejabberd_router:route(OwnerJID, UserRoomJID,
Expand Down
2 changes: 1 addition & 1 deletion src/mod_muc_log.erl
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ build_filename_string(TimeStamp, OutDir, RoomJID, DirType, DirName, FileFormat)
-spec get_room_name(jid:literal_jid()) -> mod_muc:room().
get_room_name(RoomJID) ->
JID = jid:from_binary(RoomJID),
JID#jid.user.
JID#jid.luser.


%% @doc calculate day before
Expand Down
Loading

0 comments on commit 8c30878

Please sign in to comment.