]> granicus.if.org Git - ejabberd/commitdiff
mod_muc_room: Replace deprecated function call
authorHolger Weiss <holger@zedat.fu-berlin.de>
Tue, 11 Apr 2017 11:38:33 +0000 (13:38 +0200)
committerHolger Weiss <holger@zedat.fu-berlin.de>
Tue, 11 Apr 2017 11:38:33 +0000 (13:38 +0200)
Use jid:decode/1 instead of jlib:string_to_jid/1.

src/mod_muc_admin.erl

index 708d4ff2be861bc447f0f2dfd66f4cb3a96458f0..31f267879f2de0e664530c89b7b1f15f711db3d2 100644 (file)
@@ -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) ->