| @@ -3,8 +3,9 @@ | ||
| 3 | 3 | namespace FluentBoards\App\Modules\MCP\Tools; |
| 4 | 4 | |
| 5 | 5 | use FluentBoards\App\Modules\MCP\Helpers\MCPHelper; |
| 6 | 6 | use FluentBoards\App\Services\CommentService; |
| 7 | +use FluentBoards\App\Services\NotificationService; | |
| 7 | 8 | |
| 8 | 9 | /** |
| 9 | 10 | * Comment write tools. |
| 10 | 11 | */ |
| @@ -27,8 +28,14 @@ | ||
| 27 | 28 | } |
| 28 | 29 | |
| 29 | 30 | $privacy = !empty($params['privacy']) && $params['privacy'] === 'public' ? 'public' : 'private'; |
| 30 | 31 | $mentionedIds = MCPHelper::sanitizeIdArray($params['mentioned_ids'] ?? []); |
| 32 | + $boardMemberIds = (new NotificationService())->resolveBoardMentionUserIds($task->board_id, $mentionedIds); | |
| 33 | + if (array_diff($mentionedIds, $boardMemberIds)) { | |
| 34 | + return MCPHelper::error('forbidden', __('One or more mentioned users are not members of this board', 'fluent-boards')); | |
| 35 | + } | |
| 36 | + | |
| 37 | + $mentionedIds = $boardMemberIds; | |
| 31 | 38 | $commentService = new CommentService(); |
| 32 | 39 | |
| 33 | 40 | $comment = $commentService->create([ |
| 34 | 41 | 'board_id' => (int) $task->board_id, |