From 2c735c91d64a45b70b8a41d7a3d667699ac37668 Mon Sep 17 00:00:00 2001 From: Evgeniy Khramtsov Date: Wed, 26 Aug 2009 04:14:54 +0000 Subject: [PATCH] check if a room is not persistent before starting a new one with the same name (EJAB-1026) SVN Revision: 2539 --- src/mod_muc/mod_muc.erl | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/mod_muc/mod_muc.erl b/src/mod_muc/mod_muc.erl index 22e8bb6e0..c0e2168ae 100644 --- a/src/mod_muc/mod_muc.erl +++ b/src/mod_muc/mod_muc.erl @@ -468,8 +468,7 @@ do_route1(Host, ServerHost, Access, HistorySize, RoomShaper, AccessCreate, From, Room) of true -> - ?DEBUG("MUC: open new room '~s'~n", [Room]), - {ok, Pid} = mod_muc_room:start( + {ok, Pid} = start_new_room( Host, ServerHost, Access, Room, HistorySize, RoomShaper, From, @@ -538,6 +537,23 @@ load_permanent_rooms(Host, ServerHost, Access, HistorySize, RoomShaper) -> end, Rs) end. +start_new_room(Host, ServerHost, Access, Room, + HistorySize, RoomShaper, From, + Nick, DefRoomOpts) -> + case mnesia:dirty_read(muc_room, {Room, Host}) of + [] -> + ?DEBUG("MUC: open new room '~s'~n", [Room]), + mod_muc_room:start(Host, ServerHost, Access, + Room, HistorySize, + RoomShaper, From, + Nick, DefRoomOpts); + [#muc_room{opts = Opts}|_] -> + ?DEBUG("MUC: restore room '~s'~n", [Room]), + mod_muc_room:start(Host, ServerHost, Access, + Room, HistorySize, + RoomShaper, Opts) + end. + register_room(Host, Room, Pid) -> F = fun() -> mnesia:write(#muc_online_room{name_host = {Room, Host},