From 234280ddc7af4e5a99c5ba5e8b5c9766bae74993 Mon Sep 17 00:00:00 2001 From: Evgeniy Khramtsov Date: Wed, 23 Jun 2010 17:51:05 +1000 Subject: [PATCH] now admins are able to see private rooms in disco (EJAB-1269) --- src/mod_muc/mod_muc_room.erl | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/mod_muc/mod_muc_room.erl b/src/mod_muc/mod_muc_room.erl index d2a897db4..50c8994e8 100644 --- a/src/mod_muc/mod_muc_room.erl +++ b/src/mod_muc/mod_muc_room.erl @@ -630,21 +630,9 @@ handle_event(_Event, StateName, StateData) -> %% {stop, Reason, Reply, NewStateData} %%---------------------------------------------------------------------- handle_sync_event({get_disco_item, JID, Lang}, _From, StateName, StateData) -> - case (StateData#state.config)#config.public_list of - true -> - Reply = get_roomdesc_reply(StateData, - get_roomdesc_tail(StateData, Lang)), - {reply, Reply, StateName, StateData}; - _ -> - case is_occupant_or_admin(JID, StateData) of - true -> - Reply = get_roomdesc_reply(StateData, get_roomdesc_tail( - StateData, Lang)), - {reply, Reply, StateName, StateData}; - _ -> - {reply, false, StateName, StateData} - end - end; + Reply = get_roomdesc_reply(JID, StateData, + get_roomdesc_tail(StateData, Lang)), + {reply, Reply, StateName, StateData}; handle_sync_event(get_config, _From, StateName, StateData) -> {reply, {ok, StateData#state.config}, StateName, StateData}; handle_sync_event(get_state, _From, StateName, StateData) -> @@ -3483,11 +3471,15 @@ get_title(StateData) -> Name end. -get_roomdesc_reply(StateData, Tail) -> - case ((StateData#state.config)#config.public == true) of - true -> - {item, get_title(StateData) ++ Tail}; - _ -> +get_roomdesc_reply(JID, StateData, Tail) -> + IsOccupantOrAdmin = is_occupant_or_admin(JID, StateData), + if (StateData#state.config)#config.public or IsOccupantOrAdmin -> + if (StateData#state.config)#config.public_list or IsOccupantOrAdmin -> + {item, get_title(StateData) ++ Tail}; + true -> + {item, get_title(StateData)} + end; + true -> false end.