Skip to content

Commit

Permalink
Merge pull request #3525 from esl/upgrade_mongoose_jid
Browse files Browse the repository at this point in the history
Upgrade mongoose jid
  • Loading branch information
chrzaszcz authored Apr 27, 2022
2 parents 7c573d4 + b9dc81d commit 72db059
Show file tree
Hide file tree
Showing 48 changed files with 123 additions and 140 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, "2.0.0", {pkg, mongoose_jid}}
]}.
6 changes: 3 additions & 3 deletions big_tests/rebar.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{<<"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">>,{pkg,<<"mongoose_jid">>,<<"2.0.0">>},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 +50,7 @@
{<<"fusco">>, <<"3DD6A90151DFEF30EA1937CC44E9A59177C0094918388D9BCAA2F2DC5E2AE4AA">>},
{<<"goldrush">>, <<"F06E5D5F1277DA5C413E84D5A2924174182FB108DABB39D5EC548B27424CD106">>},
{<<"gun">>, <<"7C489A32DEDCCB77B6E82D1F3C5A7DADFBFA004EC14E322CDB5E579C438632D2">>},
{<<"jid">>, <<"C9D92768FBC120C717E944AFE523FA0062C5B665E4D776724B2F8E54831AB2CA">>},
{<<"jid">>, <<"0D0FD1130EAD05DF672D1C9E0405D3000F0C87A7D446577755CF5EB173104FE9">>},
{<<"jiffy">>, <<"ACA10F47AA91697BF24AB9582C74E00E8E95474C7EF9F76D4F1A338D0F5DE21B">>},
{<<"jsx">>, <<"D12516BAA0BB23A59BB35DCCAF02A1BD08243FCBB9EFE24F2D9D056CCFF71268">>},
{<<"lager">>, <<"4CAB289120EB24964E3886BD22323CB5FEFE4510C076992A23AD18CF85413D8C">>},
Expand Down Expand Up @@ -82,7 +82,7 @@
{<<"fusco">>, <<"6343551BD1E824F2A6CA85E1158C5B37C320FD449FBFEC7450A73F192AAF9022">>},
{<<"goldrush">>, <<"99CB4128CFFCB3227581E5D4D803D5413FA643F4EB96523F77D9E6937D994CEB">>},
{<<"gun">>, <<"6B9D1EAE146410D727140DBF8B404B9631302ECC2066D1D12F22097AD7D254FC">>},
{<<"jid">>, <<"61EDDBAC9908747DA29F7C79545C744C31A25652CCB53248E684DBB083EFBE9A">>},
{<<"jid">>, <<"7BAE8403552D5BCECD1CD2A848445B5FC3533F5EEB355173A0531A1A1AA8E008">>},
{<<"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 @@ -1397,7 +1397,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
4 changes: 2 additions & 2 deletions 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, "2.0.0", {pkg, mongoose_jid}},
{tomerl, "0.5.0"},
{bbmustache, "1.12.2"},
{erl_csv, "0.2.0"},
Expand All @@ -76,7 +76,7 @@
%%% Stateful apps
{cache_tab, "1.0.29"},
{segmented_cache, "0.1.1"},
{worker_pool, "6.0.0"},
{worker_pool, "6.0.1"},

%%% HTTP tools
{cowboy, "2.9.0"},
Expand Down
12 changes: 6 additions & 6 deletions rebar.lock
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
{ref,"ad3dbab419762fc2d5821abb88b989da006b85c6"}},
2},
{<<"idna">>,{pkg,<<"idna">>,<<"6.1.1">>},0},
{<<"jid">>,{pkg,<<"mongoose_jid">>,<<"1.1.1">>},0},
{<<"jid">>,{pkg,<<"mongoose_jid">>,<<"2.0.0">>},0},
{<<"jiffy">>,{pkg,<<"jiffy">>,<<"1.1.1">>},0},
{<<"jsx">>,{pkg,<<"jsx">>,<<"2.9.0">>},1},
{<<"jwerl">>,
Expand Down Expand Up @@ -133,7 +133,7 @@
{<<"trails">>,{pkg,<<"trails">>,<<"2.3.0">>},0},
{<<"unicode_util_compat">>,{pkg,<<"unicode_util_compat">>,<<"0.7.0">>},1},
{<<"uuid">>,{pkg,<<"uuid_erl">>,<<"2.0.4">>},0},
{<<"worker_pool">>,{pkg,<<"worker_pool">>,<<"6.0.0">>},0}]}.
{<<"worker_pool">>,{pkg,<<"worker_pool">>,<<"6.0.1">>},0}]}.
[
{pkg_hash,[
{<<"amqp_client">>, <<"4EBE8040BE3EE195E42BB483D37CD64FAF3C306201DC22A3F5CCE2A91A9E562E">>},
Expand Down Expand Up @@ -165,7 +165,7 @@
{<<"gun">>, <<"CF8B51BEB36C22B9C8DF1921E3F2BC4D2B1F68B49AD4FBC64E91875AA14E16B4">>},
{<<"hackney">>, <<"24EDC8CD2B28E1C652593833862435C80661834F6C9344E84B6A2255E7AEEF03">>},
{<<"idna">>, <<"8A63070E9F7D0C62EB9D9FCB360A7DE382448200FBBD1B106CC96D3D8099DF8D">>},
{<<"jid">>, <<"C9D92768FBC120C717E944AFE523FA0062C5B665E4D776724B2F8E54831AB2CA">>},
{<<"jid">>, <<"0D0FD1130EAD05DF672D1C9E0405D3000F0C87A7D446577755CF5EB173104FE9">>},
{<<"jiffy">>, <<"ACA10F47AA91697BF24AB9582C74E00E8E95474C7EF9F76D4F1A338D0F5DE21B">>},
{<<"jsx">>, <<"D2F6E5F069C00266CAD52FB15D87C428579EA4D7D73A33669E12679E203329DD">>},
{<<"lager">>, <<"4CAB289120EB24964E3886BD22323CB5FEFE4510C076992A23AD18CF85413D8C">>},
Expand Down Expand Up @@ -196,7 +196,7 @@
{<<"trails">>, <<"B09703F056705F4943E14FFF077B98C711A6F48FAD40F4FF0B350794074AD69C">>},
{<<"unicode_util_compat">>, <<"BC84380C9AB48177092F43AC89E4DFA2C6D62B40B8BD132B1059ECC7232F9A78">>},
{<<"uuid">>, <<"77C3E3EE1E1701A2856CE945846D7CEB71931C60633A305D0B0FEAE03B2B3B5C">>},
{<<"worker_pool">>, <<"F7B442B30121EED6D8C828833533E5C15DB61E4AB2EF343C8B67824267656822">>}]},
{<<"worker_pool">>, <<"CA262C2DFB3B4AF661B206C82065D86F83922B7227508AA6E0BC34D3E5AE5135">>}]},
{pkg_hash_ext,[
{<<"amqp_client">>, <<"CDD74BC8E9D5E8610975009DCAE1293BDF7198EE6D8315A1FFB5055467010520">>},
{<<"backoff">>, <<"30CEAD738D20E4C8D36CD37857DD5E23AEBA57CB868BF64766D47D371422BDFF">>},
Expand Down Expand Up @@ -227,7 +227,7 @@
{<<"gun">>, <<"3106CE167F9C9723F849E4FB54EA4A4D814E3996AE243A1C828B256E749041E0">>},
{<<"hackney">>, <<"4D605D33DD07EE1B82B105033CCCB02379515105FCEB1850746591814B00C205">>},
{<<"idna">>, <<"92376EB7894412ED19AC475E4A86F7B413C1B9FBB5BD16DCCD57934157944CEA">>},
{<<"jid">>, <<"61EDDBAC9908747DA29F7C79545C744C31A25652CCB53248E684DBB083EFBE9A">>},
{<<"jid">>, <<"7BAE8403552D5BCECD1CD2A848445B5FC3533F5EEB355173A0531A1A1AA8E008">>},
{<<"jiffy">>, <<"62E1F0581C3C19C33A725C781DFA88410D8BFF1BBAFC3885A2552286B4785C4C">>},
{<<"jsx">>, <<"8EE1DB1CABAFDD578A2776A6AAAE87C2A8CE54B47B59E9EC7DAB5D7EB71CD8DC">>},
{<<"lager">>, <<"7F904D9E87A8CB7E66156ED31768D1C8E26EBA1D54F4BC85B1AA4AC1F6340C28">>},
Expand Down Expand Up @@ -258,5 +258,5 @@
{<<"trails">>, <<"40804001EB80417AA9D02400F39B7216956C3F251539A8A6096A69B3FAC0EA07">>},
{<<"unicode_util_compat">>, <<"25EEE6D67DF61960CF6A794239566599B09E17E668D3700247BC498638152521">>},
{<<"uuid">>, <<"7A4CCD1C151D9B88B4383FA802BCCF9BCB3754B7F53D7CAA164D51A14A6652E4">>},
{<<"worker_pool">>, <<"F9D95B85E80C5C27B7AB2E60BF780DA70A5E26DD9E6D30BE45032742FC039CC5">>}]}
{<<"worker_pool">>, <<"772E12CCB26909EA7F804B52E86E733DF66BB8150F683B591B0A762196494C74">>}]}
].
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 @@ -876,15 +876,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 @@ -983,13 +981,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 @@ -3256,7 +3251,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/event_pusher/mod_event_pusher_push_plugin_defaults.erl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ get_unread_count(Acc, To) ->
sender_id(From, Packet) ->
case exml_query:attr(Packet, <<"type">>) of
<<"chat">> ->
jid:to_binary(jid:to_bare(jid:to_lower(From)));
jid:to_bare_binary(jid:to_lower(From));
<<"groupchat">> ->
jid:to_binary(jid:to_lower(From))
end.
Expand Down
10 changes: 5 additions & 5 deletions src/event_pusher/mod_event_pusher_push_rdbms.erl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ init(_HostType, _Opts) ->
Form :: mod_event_pusher_push:form(),
Result :: ok | {error, term()}.
enable(HostType, User, PubSub, Node, Forms) ->
ExtUser = jid:to_binary(jid:to_lus(User)),
ExtUser = jid:to_bare_binary(User),
ExtPubSub = jid:to_binary(PubSub),
ExtForms = encode_form(Forms),
execute_delete(HostType, ExtUser, Node, ExtPubSub),
Expand All @@ -47,19 +47,19 @@ enable(HostType, User, PubSub, Node, Forms) ->

-spec disable(mongooseim:host_type(), User :: jid:jid()) -> ok.
disable(HostType, User) ->
ExtUser = jid:to_binary(jid:to_lus(User)),
ExtUser = jid:to_bare_binary(User),
execute_delete(HostType, ExtUser),
ok.

-spec disable(mongooseim:host_type(), User :: jid:jid(), PubSub :: jid:jid(),
Node :: mod_event_pusher_push:pubsub_node() | undefined) -> ok.
disable(HostType, User, PubSub, undefined) ->
ExtUser = jid:to_binary(jid:to_lus(User)),
ExtUser = jid:to_bare_binary(User),
ExtPubSub = jid:to_binary(PubSub),
execute_delete(HostType, ExtUser, ExtPubSub),
ok;
disable(HostType, User, PubSub, Node) ->
ExtUser = jid:to_binary(jid:to_lus(User)),
ExtUser = jid:to_bare_binary(User),
ExtPubSub = jid:to_binary(PubSub),
execute_delete(HostType, ExtUser, Node, ExtPubSub),
ok.
Expand All @@ -69,7 +69,7 @@ disable(HostType, User, PubSub, Node) ->
Node :: mod_event_pusher_push:pubsub_node(),
Form :: mod_event_pusher_push:form()}]}.
get_publish_services(HostType, User) ->
ExtUser = jid:to_binary(jid:to_lus(User)),
ExtUser = jid:to_bare_binary(User),
{selected, Rows} = execute_select(HostType, ExtUser),
{ok, decode_rows(Rows)}.

Expand Down
2 changes: 1 addition & 1 deletion src/inbox/mod_inbox_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ bool_to_binary(_) -> error.

build_inbox_entry_key(FromJid, ToJid) ->
{LUser, LServer} = jid:to_lus(FromJid),
ToBareJid = jid:nameprep(jid:to_binary(jid:to_lus(ToJid))),
ToBareJid = jid:nameprep(jid:to_bare_binary(ToJid)),
{LUser, LServer, ToBareJid}.

-spec build_forward_el(inbox_res()) -> exml:element().
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
4 changes: 2 additions & 2 deletions src/jingle_sip/mod_jingle_sip.erl
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ translate_to_sip(<<"session-initiate">>, Jingle, Acc) ->
SID = exml_query:attr(Jingle, <<"sid">>),
#jid{luser = ToUser} = ToJID = jingle_sip_helper:maybe_rewrite_to_phone(Acc),
#jid{luser = FromUser} = FromJID = mongoose_acc:from_jid(Acc),
From = jid:to_binary(jid:to_lus(FromJID)),
To = jid:to_binary(jid:to_lus(ToJID)),
From = jid:to_bare_binary(FromJID),
To = jid:to_bare_binary(ToJID),
LServer = mongoose_acc:lserver(Acc),
SDP = prepare_initial_sdp(LServer, Jingle),
ProxyURI = get_proxy_uri(LServer),
Expand Down
Loading

0 comments on commit 72db059

Please sign in to comment.