Feat v0.7.8 bug fixes admin gaps (#62)
All checks were successful
CI/CD / detect-changes (push) Successful in 5s
CI/CD / e2e-smoke (push) Has been skipped
CI/CD / test-frontend (push) Successful in 6s
CI/CD / test-runners (push) Has been skipped
CI/CD / test-go-pg (push) Successful in 2m49s
CI/CD / build-and-deploy (push) Successful in 29s
CI/CD / test-sqlite (push) Successful in 2m55s
All checks were successful
CI/CD / detect-changes (push) Successful in 5s
CI/CD / e2e-smoke (push) Has been skipped
CI/CD / test-frontend (push) Successful in 6s
CI/CD / test-runners (push) Has been skipped
CI/CD / test-go-pg (push) Successful in 2m49s
CI/CD / build-and-deploy (push) Successful in 29s
CI/CD / test-sqlite (push) Successful in 2m55s
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #62.
This commit is contained in:
@@ -36,6 +36,51 @@ type publicInstanceResponse struct {
|
||||
UpdatedAt any `json:"updated_at"`
|
||||
}
|
||||
|
||||
// StartBySlug resolves a scope+slug to a workflow and starts a public instance.
|
||||
// POST /api/v1/workflow-entry/:scope/:slug
|
||||
// Called by the workflow landing page (/w/:scope/:slug).
|
||||
func (h *WorkflowPublicHandler) StartBySlug(c *gin.Context) {
|
||||
scope := c.Param("scope")
|
||||
slug := c.Param("slug")
|
||||
|
||||
var teamID *string
|
||||
if scope != "global" {
|
||||
teamID = &scope
|
||||
}
|
||||
|
||||
wf, err := h.stores.Workflows.GetBySlug(c.Request.Context(), teamID, slug)
|
||||
if err != nil || wf == nil {
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "workflow not found"})
|
||||
return
|
||||
}
|
||||
|
||||
var body struct {
|
||||
Data json.RawMessage `json:"data"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&body); err != nil && err.Error() != "EOF" {
|
||||
body.Data = json.RawMessage(`{}`)
|
||||
}
|
||||
if len(body.Data) == 0 {
|
||||
body.Data = json.RawMessage(`{}`)
|
||||
}
|
||||
|
||||
inst, err := h.engine.StartPublic(c.Request.Context(), wf.ID, body.Data)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
// Return redirect for the landing page JS
|
||||
redirectTo := "/w/" + inst.ID
|
||||
if inst.EntryToken != nil {
|
||||
redirectTo = "/w/" + inst.ID + "?token=" + *inst.EntryToken
|
||||
}
|
||||
c.JSON(http.StatusCreated, gin.H{
|
||||
"id": inst.ID,
|
||||
"redirect_to": redirectTo,
|
||||
})
|
||||
}
|
||||
|
||||
// StartPublic creates an anonymous workflow instance.
|
||||
// POST /api/v1/public/workflows/:id/start
|
||||
func (h *WorkflowPublicHandler) StartPublic(c *gin.Context) {
|
||||
|
||||
Reference in New Issue
Block a user