Log modified fields when modifying a room conf

master
Daniel Berteaud 9 years ago
parent 0ca69a4edc
commit 1368baec84
  1. 18
      vroom.pl

@ -266,7 +266,6 @@ helper get_room_by_id => sub {
}; };
# Update a room, take a room object as argument (hashref) # Update a room, take a room object as argument (hashref)
# TODO: log modified fields
helper modify_room => sub { helper modify_room => sub {
my $self = shift; my $self = shift;
my ($room) = @_; my ($room) = @_;
@ -276,6 +275,10 @@ helper modify_room => sub {
if (!$self->valid_room_name($room->{name})){ if (!$self->valid_room_name($room->{name})){
return 0; return 0;
} }
my $old_room = $self->get_room_by_id($room->{id});
if (!$old_room){
return 0;
}
if (!$room->{max_members} || if (!$room->{max_members} ||
($room->{max_members} > $config->{'rooms.max_members'} && $config->{'rooms.max_members'} > 0)){ ($room->{max_members} > $config->{'rooms.max_members'} && $config->{'rooms.max_members'} > 0)){
$room->{max_members} = 0; $room->{max_members} = 0;
@ -306,6 +309,19 @@ helper modify_room => sub {
$room->{id} $room->{id}
); );
$self->app->log->info("Room " . $room->{name} ." modified by " . $self->get_name); $self->app->log->info("Room " . $room->{name} ." modified by " . $self->get_name);
my $mods = '';
foreach my $field (keys %$room){
if (($old_room->{$field} // '' ) ne ($room->{$field} // '')){
if ($field =~ m/_password$/){
$old_room->{$field} = '<hidden>';
$room->{$field} = '<hidden>';
}
$mods .= $field . ": " . $old_room->{$field} . ' -> ' . $room->{$field} . "\n";
}
}
if ($mods ne ''){
$self->app->log->debug("Modified fields:\n$mods");
}
return 1; return 1;
}; };

Loading…
Cancel
Save