package im

import (
	"net/http"
	"strings"

	"github.com/tidbcloud/AgentTeam/internal/api"
)

// ScopesHandler exposes the workspace-prefixed scope surface. The first slice
// keeps scope enumeration conservative until the existing scope store is split
// behind a narrow IM port; message/conversation reads still enforce visibility.
type ScopesHandler struct{}

// List handles GET /api/v1/workspaces/:workspaceId/scopes.
func (h *ScopesHandler) List(r api.WorkspaceScopedRequest) (api.Response, error) {
	return api.OK(map[string]any{
		"workspaceId": r.WorkspaceID(),
		"scopes":      []scopeResponse{},
	}), nil
}

// Get handles GET /api/v1/workspaces/:workspaceId/scopes/:scopeId.
func (h *ScopesHandler) Get(r api.WorkspaceScopedRequest) (api.Response, error) {
	scopeID := strings.TrimSpace(r.Gin.Param("scopeId"))
	if scopeID == "" {
		return api.Response{}, api.NewHTTPError(http.StatusBadRequest, "scopeId is required")
	}
	return api.OK(scopeResponse{WorkspaceID: r.WorkspaceID(), ScopeID: scopeID}), nil
}
