package channel

import (
	"net/http"
	"strings"

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

func (h *ThreadHandler) threadActionContext(r api.WorkspaceScopedRequest) (identity.AuthenticatedUser, string, string, error) {
	threadChannelID := strings.TrimSpace(r.Gin.Param("threadChannelId"))
	if threadChannelID == "" {
		return identity.AuthenticatedUser{}, "", "", api.NewHTTPError(http.StatusBadRequest, "threadChannelId is required")
	}
	return r.User, r.WorkspaceID(), threadChannelID, nil
}
