feat(session): gate IM/embed/API channel sessions behind admin

Restrict channel-managed sessions (API keys, IM, embed) to tenant admin
in the Web console for list/read paths, hide channel sidebar buckets from
non-admins, and add CountSessionsBySource for aggregate stats without
exposing session rows to viewers.
This commit is contained in:
wizardchen
2026-07-20 20:27:56 +08:00
committed by lyingbug
parent b1b42abe23
commit 25ef7b6c68
10 changed files with 301 additions and 70 deletions
+2 -5
View File
@@ -749,7 +749,7 @@ func (h *EmbedChannelHandler) GetEmbedChannelStats(c *gin.Context) {
return
}
result, err := h.sessionService.ListSessions(ctx, &types.SessionListQuery{
result, err := h.sessionService.CountSessionsBySource(ctx, &types.SessionListQuery{
TenantID: tenantID,
Source: "embed:" + channelID,
Page: 1,
@@ -759,10 +759,7 @@ func (h *EmbedChannelHandler) GetEmbedChannelStats(c *gin.Context) {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
total := int64(0)
if result != nil {
total = result.Total
}
total := result
c.JSON(http.StatusOK, gin.H{
"success": true,
"data": gin.H{
+1 -1
View File
@@ -201,7 +201,7 @@ func (h *Handler) GetSession(c *gin.Context) {
// @Param page query int false "页码"
// @Param page_size query int false "每页数量"
// @Param keyword query string false "标题模糊搜索"
// @Param source query string false "来源过滤:web / embed / api(API Key 会话,需 Admin+)/ feishu / wechat / slack / ..."
// @Param source query string false "来源过滤:web / embed / api / feishu / wechat / slack / ...(api、embed、IM 渠道需 Admin+)"
// @Param agent_id query string false "按 Agent 过滤(仅对 IM 会话生效)"
// @Success 200 {object} map[string]interface{} "会话列表"
// @Failure 400 {object} errors.AppError "请求参数错误"