Changeset 0.32.0 (#206)
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"git.gobha.me/xcaliber/chat-switchboard/models"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/store"
|
||||
"chat-switchboard/models"
|
||||
"chat-switchboard/store"
|
||||
)
|
||||
|
||||
// ── Workflow Entry Handler ──────────────────
|
||||
@@ -24,24 +23,6 @@ func NewWorkflowEntryHandler(stores store.Stores) *WorkflowEntryHandler {
|
||||
return &WorkflowEntryHandler{stores: stores}
|
||||
}
|
||||
|
||||
// resolveTeamScope converts a URL scope parameter to a team ID.
|
||||
// Accepts "global" (returns nil), a UUID (passed through), or a team slug (looked up).
|
||||
func resolveTeamScope(ctx context.Context, teams store.TeamStore, scope string) *string {
|
||||
if scope == "global" {
|
||||
return nil
|
||||
}
|
||||
// UUID format: 36 chars with dashes at 8,13,18,23
|
||||
if len(scope) == 36 && scope[8] == '-' && scope[13] == '-' {
|
||||
return &scope
|
||||
}
|
||||
// Try team slug lookup
|
||||
t, err := teams.GetBySlug(ctx, scope)
|
||||
if err == nil && t != nil {
|
||||
return &t.ID
|
||||
}
|
||||
return &scope // fall through — will 404 downstream
|
||||
}
|
||||
|
||||
// StartVisitor creates an anonymous session + workflow instance for a visitor.
|
||||
// POST /api/v1/workflow-entry/:scope/:slug
|
||||
func (h *WorkflowEntryHandler) StartVisitor(c *gin.Context) {
|
||||
@@ -49,7 +30,10 @@ func (h *WorkflowEntryHandler) StartVisitor(c *gin.Context) {
|
||||
scope := c.Param("scope")
|
||||
slug := c.Param("slug")
|
||||
|
||||
teamID := resolveTeamScope(ctx, h.stores.Teams, scope)
|
||||
var teamID *string
|
||||
if scope != "global" {
|
||||
teamID = &scope
|
||||
}
|
||||
|
||||
wf, err := h.stores.Workflows.GetBySlug(ctx, teamID, slug)
|
||||
if err != nil || wf == nil {
|
||||
|
||||
Reference in New Issue
Block a user