From 87ae2d7996747da537e634d0396997b76f826aa2 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Tue, 11 Apr 2017 13:38:33 +0200 Subject: [PATCH] mod_muc_room: Replace deprecated function call Use jid:decode/1 instead of jlib:string_to_jid/1. --- src/mod_muc_admin.erl | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/mod_muc_admin.erl b/src/mod_muc_admin.erl index 708d4ff2b..31f267879 100644 --- a/src/mod_muc_admin.erl +++ b/src/mod_muc_admin.erl @@ -242,14 +242,17 @@ muc_online_rooms(ServerHost) -> end, Hosts). muc_register_nick(Nick, JIDBinary, Domain) -> - JID = jlib:string_to_jid(JIDBinary), - %{jid, UID, Host, _,_,_,_} = jlib:string_to_jid(JIDBinary), - F = fun (MHost, MNick) -> - mnesia:write(#muc_registered{us_host=MHost, nick=MNick}) - end, - case mnesia:transaction(F, [{{JID#jid.luser, JID#jid.lserver}, Domain}, Nick]) of - {atomic, ok} -> ok; - {aborted, _Error} -> error + try jid:decode(JIDBinary) of + JID -> + F = fun (MHost, MNick) -> + mnesia:write(#muc_registered{us_host=MHost, nick=MNick}) + end, + case mnesia:transaction(F, [{{JID#jid.luser, JID#jid.lserver}, + Domain}, Nick]) of + {atomic, ok} -> ok; + {aborted, _Error} -> error + end + catch _:{bad_jid, _} -> throw({error, "Malformed JID"}) end. muc_unregister_nick(Nick) -> -- 2.40.0