Changeset 0.24.3 (#159)
This commit is contained in:
@@ -217,6 +217,60 @@ func (e *Engine) RenderLogin() gin.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// WorkflowPageData is passed to the workflow.html template via PageData.Data.
|
||||
type WorkflowPageData struct {
|
||||
ChannelID string
|
||||
ChannelTitle string
|
||||
ChannelDescription string
|
||||
SessionID string
|
||||
SessionName string
|
||||
}
|
||||
|
||||
// RenderWorkflow renders the workflow entry page for anonymous session visitors.
|
||||
// The middleware (AuthOrSession) has already created/resumed the session.
|
||||
func (e *Engine) RenderWorkflow() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
channelID := c.GetString("channel_id")
|
||||
sessionID := c.GetString("session_id")
|
||||
|
||||
// Load channel metadata
|
||||
var title, description string
|
||||
if e.stores.Channels != nil && channelID != "" {
|
||||
ch, err := e.stores.Channels.GetByID(c.Request.Context(), channelID)
|
||||
if err == nil {
|
||||
title = ch.Title
|
||||
description = ch.Description
|
||||
}
|
||||
}
|
||||
if title == "" {
|
||||
title = "Workflow"
|
||||
}
|
||||
|
||||
// Load session display name
|
||||
sessionName := "Visitor"
|
||||
if e.stores.Sessions != nil && sessionID != "" {
|
||||
sp, err := e.stores.Sessions.GetByID(c.Request.Context(), sessionID)
|
||||
if err == nil {
|
||||
sessionName = sp.DisplayName
|
||||
}
|
||||
}
|
||||
|
||||
instanceName, _, _ := e.loadBranding()
|
||||
|
||||
e.Render(c, "workflow.html", PageData{
|
||||
Surface: "workflow",
|
||||
InstanceName: instanceName,
|
||||
Data: WorkflowPageData{
|
||||
ChannelID: channelID,
|
||||
ChannelTitle: title,
|
||||
ChannelDescription: description,
|
||||
SessionID: sessionID,
|
||||
SessionName: sessionName,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// getUserContext extracts user info from gin context (set by auth middleware).
|
||||
func (e *Engine) getUserContext(c *gin.Context) *UserContext {
|
||||
userID, exists := c.Get("user_id")
|
||||
|
||||
Reference in New Issue
Block a user