Skip to content

Add RBAC middleware to activity log API endpoints#36

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-activity-logs-api
Draft

Add RBAC middleware to activity log API endpoints#36
Copilot wants to merge 2 commits intomainfrom
copilot/add-activity-logs-api

Conversation

Copy link

Copilot AI commented Nov 28, 2025

Activity log endpoints (GET /api/boards/:boardId/activities and GET /api/tasks/:taskId/activities) were implemented but lacked RBAC middleware, inconsistent with other board/task routes.

Changes

  • Added rbac.RequireProjectAccess("view", ...) middleware to both activity log endpoints to match authorization pattern used elsewhere
// Before
protected.GET("/boards/:boardId/activities", boardActivitiesHandler.GetBoardActivities)

// After
protected.GET("/boards/:boardId/activities",
    rbac.RequireProjectAccess("view", "boardId", "board"),
    boardActivitiesHandler.GetBoardActivities,
)

The underlying feature (B6) was already implemented in 735f15d—this change aligns the authorization approach with existing patterns.

Original prompt

This section details on the original issue you should resolve

<issue_title>B6: 提供根据任务或看板查询活动日志的接口</issue_title>
<issue_description>#### 🎯 任务目标 (Objective)

基于 B5 中创建的 ActivityLogs 模型和日志服务,开发专用的 RESTful API 端点,允许客户端(主要是前端 F10 组件)根据“看板”或“任务卡”两个不同维度,拉取格式化的活动日志历史记录。

📖 详细描述 (Description)

在 B5 中,我们实现了记录日志的通用服务。现在,我们需要实现读取日志的功能。

前端在两个主要场景下需要展示活动日志:

  1. 看板维度 (Board Level): 用户在看板侧边栏或专门的活动页面,希望看到该看板上发生的所有事情(例如:“用户A 在 ‘进行中’ 列表创建了任务X”,“用户B 将 任务Y 移动到了 ‘已完成’”)。
  2. 任务卡维度 (Task Level): 用户打开一个任务卡的详情模态框,希望只看到与这张卡片相关的特定历史(例如:“用户A 创建了此任务”,“用户C 更新了截止日期”,“用户A 添加了评论”)。

此任务需要创建两个独立的、高效的查询接口来满足这两种需求。

验收标准 (Acceptance Criteria)

  1. [API] 看板日志端点:

    • 成功实现 GET /api/boards/{board_id}/activities 端点。
    • 当调用此端点时,它应返回一个与该 board_id 关联的 ActivityLog 列表。
    • 返回的日志应按时间戳倒序排列(最新的活动在最前面)。
  2. [API] 任务卡日志端点:

    • 成功实现 GET /api/tasks/{task_id}/activities 端点。
    • 当调用此端点时,它应只返回与该 task_id 直接相关的 ActivityLog 列表。
    • 同样,返回的日志应按时间戳倒序排列。
  3. [功能] 分页支持 (Pagination):

    • 两个端点都必须支持分页查询(例如,使用 ?page=1&limit=20?offset=0&limit=20)。
    • 活动日志可能会非常多,缺少分页将导致严重的性能问题和过大的数据包。
    • API 响应中应包含分页元数据(如 total_items, total_pages, current_page)。
  4. [安全] 权限:

    • API 必须受 B1 的认证系统保护。
    • 在返回日志前,API 必须验证当前登录的用户是否有权访问所请求的 {board_id}{task_id}
  5. [数据] 响应格式:

    • 返回的日志数据应易于前端 F10 解析(例如,包含执行操作的用户名、操作类型、操作描述文本和时间戳)。

🔗 前置依赖 (Dependencies)

  • B1: 用户认证与授权系统: 需要用于保护 API 端点。
  • B2: 核心数据库模型: 需要 BoardTask 模型来关联查询。
  • B5: 设计 ActivityLogs 数据模型: 此任务查询的数据源完全依赖 B5 的设计和实现。</issue_description>

Comments on the Issue (you are @copilot in this section)

@WiDayn https://github.com/Azure0Sky/progress-wall/commit/735f15d5db42b02d72f52b2d4e08e52e47b6f25f

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: QingSH-J <112738576+QingSH-J@users.noreply.github.com>
Copilot AI changed the title [WIP] Add RESTful API for querying activity logs Add RBAC middleware to activity log API endpoints Nov 28, 2025
Copilot AI requested a review from QingSH-J November 28, 2025 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

B6: 提供根据任务或看板查询活动日志的接口

2 participants