PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 1.95.3
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v1.95.3
2.0.15 2.0.12 2.0.10 2.0.4 2.0.1 2.0.0 1.95.3 1.95.2 1.95 1.91.6 trunk 1.11 1.12 1.13 1.20 1.21 1.22 1.23 1.30 1.31 1.32 1.35 1.40 1.41 1.45 All 41 releases
fluent-boards / app / Modules / MCP / Tools / CommentTools.php

CommentTools.php in FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration 1.95.3, at app/Modules/MCP/Tools/CommentTools.php

62 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentBoards\App\Modules\MCP\Tools;
4
5 use FluentBoards\App\Modules\MCP\Helpers\MCPHelper;
6 use FluentBoards\App\Services\CommentService;
7
8 /**
9 * Comment write tools.
10 */
11 class CommentTools
12 {
13 public static function addComment($params = [])
14 {
15 $task = MCPHelper::resolveTask($params);
16 if (is_wp_error($task)) {
17 return $task;
18 }
19
20 if (!MCPHelper::canWriteBoard($task->board_id)) {
21 return MCPHelper::error('forbidden', __('You do not have permission to comment on this task', 'fluent-boards'));
22 }
23
24 $description = isset($params['description']) ? wp_kses_post($params['description']) : '';
25 if ($description === '') {
26 return MCPHelper::error('invalid_param', __('Comment description is required', 'fluent-boards'));
27 }
28
29 $privacy = !empty($params['privacy']) && $params['privacy'] === 'public' ? 'public' : 'private';
30 $mentionedIds = MCPHelper::sanitizeIdArray($params['mentioned_ids'] ?? []);
31 $commentService = new CommentService();
32
33 $comment = $commentService->create([
34 'board_id' => (int) $task->board_id,
35 'task_id' => (int) $task->id,
36 'type' => 'comment',
37 'privacy' => $privacy,
38 'status' => 'published',
39 'description' => $commentService->processMentionAndLink($description, $mentionedIds),
40 'settings' => [
41 'mentioned_users' => $mentionedIds,
42 'source' => 'mcp',
43 ],
44 'created_by' => get_current_user_id(),
45 ], $task->id);
46
47 return [
48 'comment' => [
49 'id' => (int) $comment->id,
50 'board_id' => (int) $comment->board_id,
51 'task_id' => (int) $comment->task_id,
52 'privacy' => $comment->privacy,
53 'status' => $comment->status,
54 'description' => $comment->description,
55 'created_by' => $comment->created_by ? (int) $comment->created_by : null,
56 'created_at' => MCPHelper::toIso8601($comment->created_at),
57 ],
58 'message' => __('Comment has been added', 'fluent-boards'),
59 ];
60 }
61 }
62