Skip to content

Commit

Permalink
Merge pull request #859 from Martchus/improve_comment_events
Browse files Browse the repository at this point in the history
Distinguish comment events
  • Loading branch information
aaannz committed Sep 12, 2016
2 parents 7ea7b0d + f32ab31 commit bb34ce3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/Installing.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ Jobs:
Tables:
table_create table_update table_delete
Users:
user_comment user_login
user_new_comment user_update_comment user_delete_comment user_login
Needles:
needle_delete needle_modify
----
Expand Down
7 changes: 3 additions & 4 deletions lib/OpenQA/WebAPI/Controller/API/V1/Comment.pm
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ sub text {
# Adds a new comment to the specified job/group.
sub create {
my ($self) = @_;
$self->app->log->debug('create comment');
my $comments = $self->comments();
return unless $comments;

Expand All @@ -74,7 +73,7 @@ sub create {
text => $text,
user_id => $self->current_user->id
});
$self->emit_event('openqa_user_comment', {id => $res->id});
$self->emit_event('openqa_user_new_comment', {id => $res->id});
$self->render(json => {id => $res->id});
}

Expand All @@ -92,7 +91,7 @@ sub update {
return $self->render(json => {error => "Comment $comment_id does not exist"}, status => 404) unless $comment;
return $self->render(json => {error => "Forbidden (must be author)"}, status => 403) unless ($comment->user_id == $self->current_user->id);
my $res = $comment->update({text => $text});
$self->emit_event('openqa_user_comment', {id => $comment->id});
$self->emit_event('openqa_user_update_comment', {id => $comment->id});
$self->render(json => {id => $res->id});
}

Expand All @@ -106,7 +105,7 @@ sub delete {
my $comment = $comments->find($self->param('comment_id'));
return $self->render(json => {error => "Comment $comment_id does not exist"}, status => 404) unless $comment;
my $res = $comment->delete();
$self->emit_event('openqa_user_comment', {id => $res->id});
$self->emit_event('openqa_user_delete_comment', {id => $res->id});
$self->render(json => {id => $res->id});
}

Expand Down
2 changes: 1 addition & 1 deletion lib/OpenQA/WebAPI/Plugin/AuditLog.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ my @table_events = qw/table_create table_update table_delete/;
my @job_events = qw/job_create job_delete job_cancel job_duplicate job_restart jobs_restart job_update_result job_set_waiting job_set_running job_done job_grab job_cancel_by_settings/;
my @jobgroup_events = qw/jobgroup_create jobgroup_connect/;
my @jobtemplate_events = qw/jobtemplate_create jobtemplate_delete/;
my @user_events = qw/user_update user_login user_comment/;
my @user_events = qw/user_update user_login user_new_comment user_update_comment user_delete_comment/;
my @asset_events = qw/asset_register asset_delete/;
my @iso_events = qw/iso_create iso_delete iso_cancel/;
my @worker_events = qw/command_enqueue worker_register/;
Expand Down

0 comments on commit bb34ce3

Please sign in to comment.