mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
Make sure that room_destroyed is called even when some code throws in terminate
We observed that some code was throwing exception in muc_room:terminate() and that make this room not properly unregister itself from muc_online table.
This commit is contained in:
parent
0c794c105f
commit
74731a5816
@ -699,36 +699,39 @@ handle_info(_Info, StateName, StateData) ->
|
||||
{next_state, StateName, StateData}.
|
||||
|
||||
terminate(Reason, _StateName, StateData) ->
|
||||
?INFO_MSG("Stopping MUC room ~s@~s",
|
||||
[StateData#state.room, StateData#state.host]),
|
||||
ReasonT = case Reason of
|
||||
shutdown ->
|
||||
<<"You are being removed from the room "
|
||||
"because of a system shutdown">>;
|
||||
_ -> <<"Room terminates">>
|
||||
end,
|
||||
Packet = #presence{
|
||||
type = unavailable,
|
||||
sub_els = [#muc_user{items = [#muc_item{affiliation = none,
|
||||
reason = ReasonT,
|
||||
role = none}],
|
||||
status_codes = [332,110]}]},
|
||||
maps:fold(
|
||||
fun(LJID, Info, _) ->
|
||||
Nick = Info#user.nick,
|
||||
case Reason of
|
||||
shutdown ->
|
||||
send_wrapped(jid:replace_resource(StateData#state.jid, Nick),
|
||||
Info#user.jid, Packet,
|
||||
?NS_MUCSUB_NODES_PARTICIPANTS,
|
||||
StateData);
|
||||
_ -> ok
|
||||
end,
|
||||
tab_remove_online_user(LJID, StateData)
|
||||
end, [], get_users_and_subscribers(StateData)),
|
||||
add_to_log(room_existence, stopped, StateData),
|
||||
mod_muc:room_destroyed(StateData#state.host, StateData#state.room, self(),
|
||||
StateData#state.server_host),
|
||||
try
|
||||
?INFO_MSG("Stopping MUC room ~s@~s",
|
||||
[StateData#state.room, StateData#state.host]),
|
||||
ReasonT = case Reason of
|
||||
shutdown ->
|
||||
<<"You are being removed from the room "
|
||||
"because of a system shutdown">>;
|
||||
_ -> <<"Room terminates">>
|
||||
end,
|
||||
Packet = #presence{
|
||||
type = unavailable,
|
||||
sub_els = [#muc_user{items = [#muc_item{affiliation = none,
|
||||
reason = ReasonT,
|
||||
role = none}],
|
||||
status_codes = [332,110]}]},
|
||||
maps:fold(
|
||||
fun(LJID, Info, _) ->
|
||||
Nick = Info#user.nick,
|
||||
case Reason of
|
||||
shutdown ->
|
||||
send_wrapped(jid:replace_resource(StateData#state.jid, Nick),
|
||||
Info#user.jid, Packet,
|
||||
?NS_MUCSUB_NODES_PARTICIPANTS,
|
||||
StateData);
|
||||
_ -> ok
|
||||
end,
|
||||
tab_remove_online_user(LJID, StateData)
|
||||
end, [], get_users_and_subscribers(StateData)),
|
||||
add_to_log(room_existence, stopped, StateData),
|
||||
after
|
||||
mod_muc:room_destroyed(StateData#state.host, StateData#state.room, self(),
|
||||
StateData#state.server_host)
|
||||
end,
|
||||
ok.
|
||||
|
||||
%%%----------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user