mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-26 16:26:24 +01:00
Write in room log when a room is created, destroyed, started, stopped (EJAB-1144)
SVN Revision: 2837
This commit is contained in:
parent
a7bd529dac
commit
d911cd1124
@ -227,6 +227,9 @@ add_to_log2(roomconfig_change, _Occupants, Room, Opts, State) ->
|
|||||||
add_to_log2(roomconfig_change_enabledlogging, 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_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_to_log2(nickchange, {OldNick, NewNick}, Room, Opts, State) ->
|
||||||
add_message_to_log(binary_to_list(NewNick), {nickchange, binary_to_list(OldNick)}, 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, _} ->
|
{nomatch, _} ->
|
||||||
io_lib:format("<font class=\"mn\">~s</font> ~s<br/>",
|
io_lib:format("<font class=\"mn\">~s</font> ~s<br/>",
|
||||||
[Nick2, htmlize(T,NoFollow,FileFormat)])
|
[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,
|
end,
|
||||||
{Hour, Minute, Second} = Time,
|
{Hour, Minute, Second} = Time,
|
||||||
STime = lists:flatten(
|
STime = lists:flatten(
|
||||||
@ -445,6 +451,11 @@ add_message_to_log(Nick1, Message, RoomJID, Opts, State) ->
|
|||||||
%%----------------------------------------------------------------------
|
%%----------------------------------------------------------------------
|
||||||
%% Utilities
|
%% 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) ->
|
get_dateweek(Date, Lang) ->
|
||||||
Weekday = case calendar:day_of_the_week(Date) of
|
Weekday = case calendar:day_of_the_week(Date) of
|
||||||
1 -> ?T("Monday");
|
1 -> ?T("Monday");
|
||||||
|
@ -133,6 +133,8 @@ init([Host, ServerHost, Access, Room, HistorySize, RoomShaper, Creator, _Nick, D
|
|||||||
State1 = set_opts(DefRoomOpts, State),
|
State1 = set_opts(DefRoomOpts, State),
|
||||||
?INFO_MSG("Created MUC room ~s@~s by ~s",
|
?INFO_MSG("Created MUC room ~s@~s by ~s",
|
||||||
[Room, Host, exmpp_jid:to_binary(Creator)]),
|
[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};
|
{ok, normal_state, State1};
|
||||||
init([Host, ServerHost, Access, Room, HistorySize, RoomShaper, Opts]) ->
|
init([Host, ServerHost, Access, Room, HistorySize, RoomShaper, Opts]) ->
|
||||||
process_flag(trap_exit, true),
|
process_flag(trap_exit, true),
|
||||||
@ -144,6 +146,7 @@ init([Host, ServerHost, Access, Room, HistorySize, RoomShaper, Opts]) ->
|
|||||||
history = lqueue_new(HistorySize),
|
history = lqueue_new(HistorySize),
|
||||||
jid = exmpp_jid:make(Room, Host),
|
jid = exmpp_jid:make(Room, Host),
|
||||||
room_shaper = Shaper}),
|
room_shaper = Shaper}),
|
||||||
|
add_to_log(room_existence, started, State),
|
||||||
{ok, normal_state, State}.
|
{ok, normal_state, State}.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
%%----------------------------------------------------------------------
|
||||||
@ -590,6 +593,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),
|
||||||
{stop, normal, StateData};
|
{stop, normal, StateData};
|
||||||
handle_event(destroy, StateName, StateData) ->
|
handle_event(destroy, StateName, StateData) ->
|
||||||
?INFO_MSG("Destroyed MUC room ~s",
|
?INFO_MSG("Destroyed MUC room ~s",
|
||||||
@ -748,10 +752,13 @@ handle_info(_Info, StateName, StateData) ->
|
|||||||
%% Returns: any
|
%% Returns: any
|
||||||
%%----------------------------------------------------------------------
|
%%----------------------------------------------------------------------
|
||||||
terminate(_Reason, _StateName, StateData) ->
|
terminate(_Reason, _StateName, StateData) ->
|
||||||
|
?INFO_MSG("Stopping MUC room ~s@~s",
|
||||||
|
[StateData#state.room, StateData#state.host]),
|
||||||
?DICT:fold(
|
?DICT:fold(
|
||||||
fun(J, _, _) ->
|
fun(J, _, _) ->
|
||||||
tab_remove_online_user(J, StateData)
|
tab_remove_online_user(J, StateData)
|
||||||
end, [], StateData#state.users),
|
end, [], StateData#state.users),
|
||||||
|
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(),
|
||||||
StateData#state.server_host),
|
StateData#state.server_host),
|
||||||
ok.
|
ok.
|
||||||
@ -989,6 +996,7 @@ process_presence(From, Nick, #xmlel{name = 'presence'} = Packet,
|
|||||||
true ->
|
true ->
|
||||||
?INFO_MSG("Destroyed MUC room ~s because it's temporary and empty",
|
?INFO_MSG("Destroyed MUC room ~s because it's temporary and empty",
|
||||||
[exmpp_jid:to_binary(StateData#state.jid)]),
|
[exmpp_jid:to_binary(StateData#state.jid)]),
|
||||||
|
add_to_log(room_existence, destroyed, StateData),
|
||||||
{stop, normal, StateData1};
|
{stop, normal, StateData1};
|
||||||
_ ->
|
_ ->
|
||||||
{next_state, normal_state, StateData1}
|
{next_state, normal_state, StateData1}
|
||||||
@ -2763,6 +2771,7 @@ process_iq_owner(From, set, Lang, SubEl, StateData) ->
|
|||||||
[#xmlel{name = 'destroy'} = SubEl1] ->
|
[#xmlel{name = 'destroy'} = SubEl1] ->
|
||||||
?INFO_MSG("Destroyed MUC room ~s by the owner ~s",
|
?INFO_MSG("Destroyed MUC room ~s by the owner ~s",
|
||||||
[exmpp_jid:to_binary(StateData#state.jid), exmpp_jid:to_binary(From)]),
|
[exmpp_jid:to_binary(StateData#state.jid), exmpp_jid:to_binary(From)]),
|
||||||
|
add_to_log(room_existence, destroyed, StateData),
|
||||||
destroy_room(SubEl1, StateData);
|
destroy_room(SubEl1, StateData);
|
||||||
Items ->
|
Items ->
|
||||||
process_admin_items_set(From, Items, Lang, StateData)
|
process_admin_items_set(From, Items, Lang, StateData)
|
||||||
|
Loading…
Reference in New Issue
Block a user