summaryrefslogtreecommitdiff
path: root/app/Model/NotificationModel.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-07-23 14:05:15 -0400
committerFrederic Guillot <fred@kanboard.net>2016-07-23 14:05:15 -0400
commitb6119e7dee84869a619dedccd9c80df4422a4f5b (patch)
tree8487400f592d2c66dba91a9ce4f03b4ae657a0c2 /app/Model/NotificationModel.php
parent5fe81ae6ef59ee73e7d6f34fb333d3d19a08a266 (diff)
Added internal task links to activity stream
Diffstat (limited to 'app/Model/NotificationModel.php')
-rw-r--r--app/Model/NotificationModel.php39
1 files changed, 11 insertions, 28 deletions
diff --git a/app/Model/NotificationModel.php b/app/Model/NotificationModel.php
index 925d646e..39c1f581 100644
--- a/app/Model/NotificationModel.php
+++ b/app/Model/NotificationModel.php
@@ -3,6 +3,7 @@
namespace Kanboard\Model;
use Kanboard\Core\Base;
+use Kanboard\EventBuilder\TaskLinkEventBuilder;
/**
* Notification
@@ -85,7 +86,9 @@ class NotificationModel extends Base
case CommentModel::EVENT_USER_MENTION:
return e('%s mentioned you in a comment on the task #%d', $event_author, $event_data['task']['id']);
default:
- return e('Notification');
+ return TaskLinkEventBuilder::getInstance($this->container)
+ ->buildTitleWithAuthor($event_author, $event_name, $event_data) ?:
+ e('Notification');
}
}
@@ -138,7 +141,9 @@ class NotificationModel extends Base
case CommentModel::EVENT_USER_MENTION:
return e('You were mentioned in a comment on the task #%d', $event_data['task']['id']);
default:
- return e('Notification');
+ return TaskLinkEventBuilder::getInstance($this->container)
+ ->buildTitleWithoutAuthor($event_name, $event_data) ?:
+ e('Notification');
}
}
@@ -152,32 +157,10 @@ class NotificationModel extends Base
*/
public function getTaskIdFromEvent($event_name, array $event_data)
{
- switch ($event_name) {
- case TaskFileModel::EVENT_CREATE:
- return $event_data['file']['task_id'];
- case CommentModel::EVENT_CREATE:
- case CommentModel::EVENT_UPDATE:
- case CommentModel::EVENT_DELETE:
- return $event_data['comment']['task_id'];
- case SubtaskModel::EVENT_CREATE:
- case SubtaskModel::EVENT_UPDATE:
- case SubtaskModel::EVENT_DELETE:
- return $event_data['subtask']['task_id'];
- case TaskModel::EVENT_CREATE:
- case TaskModel::EVENT_UPDATE:
- case TaskModel::EVENT_CLOSE:
- case TaskModel::EVENT_OPEN:
- case TaskModel::EVENT_MOVE_COLUMN:
- case TaskModel::EVENT_MOVE_POSITION:
- case TaskModel::EVENT_MOVE_SWIMLANE:
- case TaskModel::EVENT_ASSIGNEE_CHANGE:
- case CommentModel::EVENT_USER_MENTION:
- case TaskModel::EVENT_USER_MENTION:
- return $event_data['task']['id'];
- case TaskModel::EVENT_OVERDUE:
- return $event_data['tasks'][0]['id'];
- default:
- return 0;
+ if ($event_name === TaskModel::EVENT_OVERDUE) {
+ return $event_data['tasks'][0]['id'];
}
+
+ return isset($event_data['task']['id']) ? $event_data['task']['id'] : 0;
}
}