25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-30 16:36:29 +01:00

Kick occupants with reason when room is stopped due to MUC shutdown (EJAB-1149)

SVN Revision: 2849
This commit is contained in:
Badlop 2009-12-30 01:29:02 +00:00
parent 69869f0446
commit 60915a7f21

View File

@ -594,7 +594,7 @@ handle_event({destroy, Reason}, _StateName, StateData) ->
?INFO_MSG("Destroyed MUC room ~s with reason: ~p", ?INFO_MSG("Destroyed MUC room ~s with reason: ~p",
[exmpp_jid:to_binary(StateData#state.jid), Reason]), [exmpp_jid:to_binary(StateData#state.jid), Reason]),
add_to_log(room_existence, destroyed, StateData), add_to_log(room_existence, destroyed, StateData),
{stop, normal, StateData}; {stop, Reason, StateData};
handle_event(destroy, StateName, StateData) -> handle_event(destroy, StateName, StateData) ->
?INFO_MSG("Destroyed MUC room ~s", ?INFO_MSG("Destroyed MUC room ~s",
[exmpp_jid:to_binary(StateData#state.jid)]), [exmpp_jid:to_binary(StateData#state.jid)]),
@ -751,12 +751,40 @@ handle_info(_Info, StateName, StateData) ->
%% Purpose: Shutdown the fsm %% Purpose: Shutdown the fsm
%% Returns: any %% Returns: any
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
terminate(_Reason, _StateName, StateData) -> terminate(Reason, _StateName, StateData) ->
?INFO_MSG("Stopping MUC room ~s@~s", ?INFO_MSG("Stopping MUC room ~s@~s",
[StateData#state.room, StateData#state.host]), [StateData#state.room, StateData#state.host]),
ReasonT = case Reason of
shutdown -> "You are being removed from the room because"
" of a system shutdown";
_ -> atom_to_list(Reason)
end,
ReasonEl = #xmlel{name = 'reason', children = [#xmlcdata{cdata = ReasonT}]},
ItemAttrs = [?XMLATTR('affiliation', <<"none">>),
?XMLATTR('role', <<"none">>)],
XEls = [#xmlel{ns = ?NS_MUC_USER, name = 'item',
attrs = ItemAttrs,
children = [ReasonEl]},
#xmlel{ns = ?NS_MUC_USER, name = 'status',
attrs = [?XMLATTR('code', <<"332">>)]}],
Packet = #xmlel{ns = ?NS_JABBER_CLIENT,
name = 'presence',
attrs = [?XMLATTR('type', <<"unavailable">>)],
children = [#xmlel{ns = ?NS_MUC_USER, name = 'x',
children = XEls}
]},
?DICT:fold( ?DICT:fold(
fun(J, _, _) -> fun(LJID, Info, _) ->
tab_remove_online_user(J, StateData) Nick = Info#user.nick,
case Reason of
shutdown ->
ejabberd_router:route(
exmpp_jid:full(StateData#state.jid, Nick),
Info#user.jid,
Packet);
_ -> ok
end,
tab_remove_online_user(LJID, StateData)
end, [], StateData#state.users), end, [], StateData#state.users),
add_to_log(room_existence, stopped, StateData), add_to_log(room_existence, stopped, StateData),
mod_muc:room_destroyed(StateData#state.host, StateData#state.room, self(), mod_muc:room_destroyed(StateData#state.host, StateData#state.room, self(),