| @@ -1,8 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace FluentBoards\App\Services; |
| 4 | 4 | |
| 5 | +use FluentBoards\Framework\Database\Orm\ModelNotFoundException; | |
| 5 | 6 | use FluentBoards\App\App; |
| 6 | 7 | use FluentBoards\App\Models\Attachment; |
| 7 | 8 | use FluentBoards\App\Models\Comment; |
| 8 | 9 | use FluentBoards\App\Models\Notification; |
| @@ -32,14 +33,15 @@ | ||
| 32 | 33 | * Resolve a task only when it belongs to the requested board. |
| 33 | 34 | * |
| 34 | 35 | * Subtasks normally carry the same board_id as their parent, but the parent |
| 35 | 36 | * fallback protects older data where that relationship may be incomplete. |
| 37 | + * Missing or mismatched tasks use the router's deliberate 404 response. | |
| 36 | 38 | * |
| 37 | 39 | * @param int $taskId |
| 38 | 40 | * @param int $boardId |
| 39 | 41 | * @param bool $allowParentFallback |
| 40 | 42 | * @return Task |
| 41 | - * @throws \Exception | |
| 43 | + * @throws ModelNotFoundException | |
| 42 | 44 | */ |
| 43 | 45 | public function findTaskOnBoard($taskId, $boardId, $allowParentFallback = true) |
| 44 | 46 | { |
| 45 | 47 | $taskId = absint($taskId); |
| @@ -45,9 +47,9 @@ | ||
| 45 | 47 | $taskId = absint($taskId); |
| 46 | 48 | $boardId = absint($boardId); |
| 47 | 49 | |
| 48 | 50 | if (!$taskId || !$boardId) { |
| 49 | - throw new \Exception(esc_html__('Task not found', 'fluent-boards')); | |
| 51 | + throw new ModelNotFoundException(esc_html__('Task not found', 'fluent-boards')); | |
| 50 | 52 | } |
| 51 | 53 | |
| 52 | 54 | $task = Task::where('id', $taskId) |
| 53 | 55 | ->where('board_id', $boardId) |
| @@ -71,9 +73,9 @@ | ||
| 71 | 73 | } |
| 72 | 74 | } |
| 73 | 75 | } |
| 74 | 76 | |
| 75 | - throw new \Exception(esc_html__('Task not found', 'fluent-boards')); | |
| 77 | + throw new ModelNotFoundException(esc_html__('Task not found', 'fluent-boards')); | |
| 76 | 78 | } |
| 77 | 79 | |
| 78 | 80 | private function normalizeTaskDescriptionForEditor(Task $task) |
| 79 | 81 | { |
| @@ -2222,9 +2224,9 @@ | ||
| 2222 | 2224 | |
| 2223 | 2225 | // Fetch comments and activities separately |
| 2224 | 2226 | $comments = []; |
| 2225 | 2227 | if ($feedType !== 'activities') { |
| 2226 | - $comments = $task->comments()->with('user')->orderBy('created_at', 'desc')->get()->toArray(); | |
| 2228 | + $comments = $task->comments()->with(['user', 'replies.user'])->orderBy('created_at', 'desc')->get()->toArray(); | |
| 2227 | 2229 | } |
| 2228 | 2230 | |
| 2229 | 2231 | $activities = []; |
| 2230 | 2232 | if ($feedType !== 'comments') { |