Skip to content

Commit

Permalink
Merge pull request stakwork#2148 from MahtabBukhari/Update_PostTicket…
Browse files Browse the repository at this point in the history
…DataToStakwork_to_also_capture_Workspace_Schematic

Update PostTicketDataToStakwork to also capture Workspace Schematic and add to call
  • Loading branch information
humansinstitute authored Dec 11, 2024
2 parents dfb25de + ab1bf96 commit 0f7ee06
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions handlers/ticket.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,13 @@ func (th *ticketHandler) PostTicketDataToStakwork(w http.ResponseWriter, r *http
return
}

var productBrief, featureBrief string
var (
productBrief, featureBrief string
feature db.WorkspaceFeatures
)

if ticket.FeatureUUID != "" {
feature := th.db.GetFeatureByUuid(ticket.FeatureUUID)
feature = th.db.GetFeatureByUuid(ticket.FeatureUUID)
if feature.Uuid == "" {
w.WriteHeader(http.StatusInternalServerError)
json.NewEncoder(w).Encode(TicketResponse{
Expand Down Expand Up @@ -322,6 +326,31 @@ func (th *ticketHandler) PostTicketDataToStakwork(w http.ResponseWriter, r *http

webhookURL := fmt.Sprintf("%s/bounties/ticket/review", host)

var schematicURL string
if feature.WorkspaceUuid != "" {

workspace := th.db.GetWorkspaceByUuid(feature.WorkspaceUuid)

if workspace.Uuid == "" {
w.WriteHeader(http.StatusNotFound)
json.NewEncoder(w).Encode(TicketResponse{
Success: false,
Message: "Workspace not found",
})
return
}

schematicURL = workspace.SchematicUrl
if schematicURL == "" {
w.WriteHeader(http.StatusNotFound)
json.NewEncoder(w).Encode(TicketResponse{
Success: false,
Message: "Schematic URL not found in the workspace",
})
return
}
}

stakworkPayload := map[string]interface{}{
"name": "Hive Ticket Builder",
"workflow_id": 37324,
Expand All @@ -339,6 +368,7 @@ func (th *ticketHandler) PostTicketDataToStakwork(w http.ResponseWriter, r *http
"examples": "",
"sourceWebsocket": ticketRequest.Metadata.ID,
"webhook_url": webhookURL,
"phaseSchematic": schematicURL,
},
},
},
Expand Down

0 comments on commit 0f7ee06

Please sign in to comment.