Skip to content

Commit

Permalink
Merge pull request #2574 from stakwork/feat/add_new_stakwork_key
Browse files Browse the repository at this point in the history
Adds SWWFSWKEY to tribes
  • Loading branch information
humansinstitute authored Feb 25, 2025
2 parents f7383f9 + 049cfa8 commit 0bd8f7b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion handlers/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ func (ch *ChatHandler) SendBuildMessage(w http.ResponseWriter, r *http.Request)
return
}

apiKey := os.Getenv("SWWFKEY")
apiKey := os.Getenv("SWWFSWKEY")
if apiKey == "" {
http.Error(w, "API key not set in environment", http.StatusInternalServerError)
return
Expand Down
9 changes: 2 additions & 7 deletions handlers/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,6 @@ func (oh *featureHandler) StoriesSend(w http.ResponseWriter, r *http.Request) {
apiKey := os.Getenv("SWWFKEY")
if apiKey == "" {
panic("API key not set in environment")
return
}

postData.Alias = user.OwnerAlias
Expand All @@ -670,13 +669,11 @@ func (oh *featureHandler) StoriesSend(w http.ResponseWriter, r *http.Request) {
stakworkPayloadJSON, err := json.Marshal(stakworkPayload)
if err != nil {
panic("Failed to encode payload")
return
}

req, err := http.NewRequest("POST", "https://api.stakwork.com/api/v1/projects", bytes.NewBuffer(stakworkPayloadJSON))
if err != nil {
panic("Failed to create request to Stakwork API")
return
}
req.Header.Set("Authorization", "Token token="+apiKey)
req.Header.Set("Content-Type", "application/json")
Expand All @@ -685,14 +682,12 @@ func (oh *featureHandler) StoriesSend(w http.ResponseWriter, r *http.Request) {
resp, err := client.Do(req)
if err != nil {
panic("Failed to send request to Stakwork API")
return
}
defer resp.Body.Close()

respBody, err := io.ReadAll(resp.Body)
if err != nil {
panic("Failed to read response from Stakwork API")
return
}

w.WriteHeader(resp.StatusCode)
Expand Down Expand Up @@ -911,7 +906,7 @@ func (oh *featureHandler) GetQuickBounties(w http.ResponseWriter, r *http.Reques
}

status := calculateBountyStatus(bounty)

var phaseID *string
if bounty.PhaseUuid != "" {
phaseUUID := bounty.PhaseUuid
Expand All @@ -923,7 +918,7 @@ func (oh *featureHandler) GetQuickBounties(w http.ResponseWriter, r *http.Reques
BountyTitle: bounty.Title,
Status: status,
AssignedAlias: assignedAlias,
PhaseID: phaseID,
PhaseID: phaseID,
}

if status == db.StatusTodo {
Expand Down
6 changes: 2 additions & 4 deletions routes/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
"github.com/posthog/posthog-go"
"github.com/rs/cors"
"github.com/urfave/negroni"
"github.com/xhd2015/xgo/runtime/core"
Expand All @@ -28,8 +29,6 @@ import (
"github.com/stakwork/sphinx-tribes/logger"
customMiddleware "github.com/stakwork/sphinx-tribes/middlewares"
"github.com/stakwork/sphinx-tribes/utils"

"github.com/posthog/posthog-go"
)

// NewRouter creates a chi router
Expand Down Expand Up @@ -134,7 +133,6 @@ type extractResponse struct {
}

func getFromAuth(path string) (*extractResponse, error) {

authURL := "http://auth:9090"
resp, err := http.Get(authURL + path)
if err != nil {
Expand Down Expand Up @@ -336,7 +334,7 @@ func initChi() *chi.Mux {
r.Use(customMiddleware.FeatureFlag(db.DB))
cors := cors.New(cors.Options{
AllowedOrigins: []string{"*"},
AllowedMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"},
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token", "X-User", "authorization", "x-jwt", "Referer", "User-Agent", "x-session-id"},
AllowCredentials: true,
MaxAge: 300,
Expand Down

0 comments on commit 0bd8f7b

Please sign in to comment.