25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Write in room log when a room is created, destroyed, started, stopped (EJAB-1144)

SVN Revision: 2837
This commit is contained in:
Badlop 2009-12-29 14:44:12 +00:00
parent a7bd529dac
commit d911cd1124
2 changed files with 21 additions and 1 deletions

View File

@ -227,6 +227,9 @@ add_to_log2(roomconfig_change, _Occupants, Room, Opts, State) ->
add_to_log2(roomconfig_change_enabledlogging, Occupants, Room, Opts, State) ->
add_message_to_log("", {roomconfig_change, Occupants}, Room, Opts, State);
add_to_log2(room_existence, NewStatus, Room, Opts, State) ->
add_message_to_log("", {room_existence, NewStatus}, Room, Opts, State);
add_to_log2(nickchange, {OldNick, NewNick}, Room, Opts, State) ->
add_message_to_log(binary_to_list(NewNick), {nickchange, binary_to_list(OldNick)}, Room, Opts, State);
@ -425,7 +428,10 @@ add_message_to_log(Nick1, Message, RoomJID, Opts, State) ->
{nomatch, _} ->
io_lib:format("<font class=\"mn\">~s</font> ~s<br/>",
[Nick2, htmlize(T,NoFollow,FileFormat)])
end
end;
{room_existence, RoomNewExistence} ->
io_lib:format("<font class=\"mrcm\">~s</font><br/>",
[get_room_existence_string(RoomNewExistence, Lang)])
end,
{Hour, Minute, Second} = Time,
STime = lists:flatten(
@ -445,6 +451,11 @@ add_message_to_log(Nick1, Message, RoomJID, Opts, State) ->
%%----------------------------------------------------------------------
%% Utilities
get_room_existence_string(created, Lang) -> ?T("Chatroom is created");
get_room_existence_string(destroyed, Lang) -> ?T("Chatroom is destroyed");
get_room_existence_string(started, Lang) -> ?T("Chatroom is started");
get_room_existence_string(stopped, Lang) -> ?T("Chatroom is stopped").
get_dateweek(Date, Lang) ->
Weekday = case calendar:day_of_the_week(Date) of
1 -> ?T("Monday");

View File

@ -133,6 +133,8 @@ init([Host, ServerHost, Access, Room, HistorySize, RoomShaper, Creator, _Nick, D
State1 = set_opts(DefRoomOpts, State),
?INFO_MSG("Created MUC room ~s@~s by ~s",
[Room, Host, exmpp_jid:to_binary(Creator)]),
add_to_log(room_existence, created, State1),
add_to_log(room_existence, started, State1),
{ok, normal_state, State1};
init([Host, ServerHost, Access, Room, HistorySize, RoomShaper, Opts]) ->
process_flag(trap_exit, true),
@ -144,6 +146,7 @@ init([Host, ServerHost, Access, Room, HistorySize, RoomShaper, Opts]) ->
history = lqueue_new(HistorySize),
jid = exmpp_jid:make(Room, Host),
room_shaper = Shaper}),
add_to_log(room_existence, started, State),
{ok, normal_state, State}.
%%----------------------------------------------------------------------
@ -590,6 +593,7 @@ handle_event({destroy, Reason}, _StateName, StateData) ->
?INFO_MSG("Destroyed MUC room ~s with reason: ~p",
[exmpp_jid:to_binary(StateData#state.jid), Reason]),
add_to_log(room_existence, destroyed, StateData),
{stop, normal, StateData};
handle_event(destroy, StateName, StateData) ->
?INFO_MSG("Destroyed MUC room ~s",
@ -748,10 +752,13 @@ handle_info(_Info, StateName, StateData) ->
%% Returns: any
%%----------------------------------------------------------------------
terminate(_Reason, _StateName, StateData) ->
?INFO_MSG("Stopping MUC room ~s@~s",
[StateData#state.room, StateData#state.host]),
?DICT:fold(
fun(J, _, _) ->
tab_remove_online_user(J, StateData)
end, [], StateData#state.users),
add_to_log(room_existence, stopped, StateData),
mod_muc:room_destroyed(StateData#state.host, StateData#state.room, self(),
StateData#state.server_host),
ok.
@ -989,6 +996,7 @@ process_presence(From, Nick, #xmlel{name = 'presence'} = Packet,
true ->
?INFO_MSG("Destroyed MUC room ~s because it's temporary and empty",
[exmpp_jid:to_binary(StateData#state.jid)]),
add_to_log(room_existence, destroyed, StateData),
{stop, normal, StateData1};
_ ->
{next_state, normal_state, StateData1}
@ -2763,6 +2771,7 @@ process_iq_owner(From, set, Lang, SubEl, StateData) ->
[#xmlel{name = 'destroy'} = SubEl1] ->
?INFO_MSG("Destroyed MUC room ~s by the owner ~s",
[exmpp_jid:to_binary(StateData#state.jid), exmpp_jid:to_binary(From)]),
add_to_log(room_existence, destroyed, StateData),
destroy_room(SubEl1, StateData);
Items ->
process_admin_items_set(From, Items, Lang, StateData)