summaryrefslogtreecommitdiff
path: root/app/Integration/GithubWebhook.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Integration/GithubWebhook.php')
-rw-r--r--app/Integration/GithubWebhook.php19
1 files changed, 12 insertions, 7 deletions
diff --git a/app/Integration/GithubWebhook.php b/app/Integration/GithubWebhook.php
index d95eba78..607bbc1e 100644
--- a/app/Integration/GithubWebhook.php
+++ b/app/Integration/GithubWebhook.php
@@ -80,7 +80,7 @@ class GithubWebhook extends \Core\Base
$task_id = $this->task->getTaskIdFromText($commit['message']);
- if (! $task_id) {
+ if (empty($task_id)) {
continue;
}
@@ -90,7 +90,7 @@ class GithubWebhook extends \Core\Base
continue;
}
- if ($task['is_active'] == Task::STATUS_OPEN && $task['project_id'] == $this->project_id) {
+ if ($task['project_id'] == $this->project_id) {
$this->container['dispatcher']->dispatch(
self::EVENT_COMMIT,
new GenericEvent(array('task_id' => $task_id) + $task)
@@ -140,15 +140,20 @@ class GithubWebhook extends \Core\Base
public function parseCommentIssueEvent(array $payload)
{
$task = $this->taskFinder->getByReference($this->project_id, $payload['issue']['number']);
- $user = $this->user->getByUsername($payload['comment']['user']['login']);
- if (! empty($task) && ! empty($user)) {
+ if (! empty($task)) {
+
+ $user = $this->user->getByUsername($payload['comment']['user']['login']);
+
+ if (! empty($user) && ! $this->projectPermission->isMember($this->project_id, $user['id'])) {
+ $user = array();
+ }
$event = array(
'project_id' => $this->project_id,
'reference' => $payload['comment']['id'],
- 'comment' => $payload['comment']['body'],
- 'user_id' => $user['id'],
+ 'comment' => $payload['comment']['body']."\n\n[".t('By @%s on Github', $payload['comment']['user']['login']).']('.$payload['comment']['html_url'].')',
+ 'user_id' => ! empty($user) ? $user['id'] : 0,
'task_id' => $task['id'],
);
@@ -257,7 +262,7 @@ class GithubWebhook extends \Core\Base
$user = $this->user->getByUsername($issue['assignee']['login']);
$task = $this->taskFinder->getByReference($this->project_id, $issue['number']);
- if (! empty($user) && ! empty($task)) {
+ if (! empty($user) && ! empty($task) && $this->projectPermission->isMember($this->project_id, $user['id'])) {
$event = array(
'project_id' => $this->project_id,