diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-06-20 20:55:50 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-06-20 20:55:50 -0400 |
commit | 98fd34bfe340fae6d0fd3b7333b6f9a6647cbae2 (patch) | |
tree | d22b7bff634a05e73f89d423938776df43554f52 /app/Action/CommentCreation.php | |
parent | 7b947ebdbd3b6bcd9de10ea4255bfa11fc88695c (diff) |
Improve automatic action to create comments based on commit messages
Diffstat (limited to 'app/Action/CommentCreation.php')
-rw-r--r-- | app/Action/CommentCreation.php | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/app/Action/CommentCreation.php b/app/Action/CommentCreation.php index 44deb819..fb9f1172 100644 --- a/app/Action/CommentCreation.php +++ b/app/Action/CommentCreation.php @@ -2,7 +2,9 @@ namespace Action; +use Integration\BitbucketWebhook; use Integration\GithubWebhook; +use Integration\GitlabWebhook; /** * Create automatically a comment from a webhook @@ -22,6 +24,9 @@ class CommentCreation extends Base { return array( GithubWebhook::EVENT_ISSUE_COMMENT, + GithubWebhook::EVENT_COMMIT, + BitbucketWebhook::EVENT_COMMIT, + GitlabWebhook::EVENT_COMMIT, ); } @@ -45,8 +50,6 @@ class CommentCreation extends Base public function getEventRequiredParameters() { return array( - 'comment', - 'user_id', 'task_id', ); } @@ -62,9 +65,9 @@ class CommentCreation extends Base { return (bool) $this->comment->create(array( 'reference' => isset($data['reference']) ? $data['reference'] : '', - 'comment' => $data['comment'], + 'comment' => empty($data['comment']) ? $data['commit_comment'] : $data['comment'], 'task_id' => $data['task_id'], - 'user_id' => $data['user_id'], + 'user_id' => empty($data['user_id']) ? 0 : $data['user_id'], )); } @@ -77,6 +80,6 @@ class CommentCreation extends Base */ public function hasRequiredCondition(array $data) { - return true; + return ! empty($data['comment']) || ! empty($data['commit_comment']); } } |