From e36eacb0fe8f5bd5fbaaf003729b413511d6bb97 Mon Sep 17 00:00:00 2001 From: Scott Ferguson Date: Mon, 10 Feb 2014 15:21:04 -0600 Subject: [PATCH 1/2] Fix team invites --- pkg/handler/members.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/handler/members.go b/pkg/handler/members.go index ff0dea55..27e4b0af 100644 --- a/pkg/handler/members.go +++ b/pkg/handler/members.go @@ -173,7 +173,7 @@ func TeamMemberInvite(w http.ResponseWriter, r *http.Request, u *User) error { } // generate a token that is valid for 3 days to join the team - token := authcookie.New(team.Name, time.Now().Add(72*time.Hour), secret) + token := authcookie.New(strconv.Itoa(int(team.ID)), time.Now().Add(72*time.Hour), secret) // hostname from settings hostname := database.SettingsMust().URL().String() @@ -202,14 +202,14 @@ func TeamMemberInvite(w http.ResponseWriter, r *http.Request, u *User) error { func TeamMemberAccept(w http.ResponseWriter, r *http.Request, u *User) error { // get the team name from the token token := r.FormValue("token") - teamName := authcookie.Login(token, secret) - if len(teamName) == 0 { + teamToken := authcookie.Login(token, secret) + teamId, err := strconv.Atoi(teamToken) + if err != nil || teamId == 0 { return ErrInvalidTeamName } // get the team from the database - // TODO it might make more sense to use the ID in case the Slug changes - team, err := database.GetTeamSlug(teamName) + team, err := database.GetTeam(int64(teamId)) if err != nil { return RenderError(w, err, http.StatusNotFound) } @@ -222,6 +222,6 @@ func TeamMemberAccept(w http.ResponseWriter, r *http.Request, u *User) error { } // send the user to the dashboard - http.Redirect(w, r, "/dashboard/team/"+team.Name, http.StatusSeeOther) + http.Redirect(w, r, "/dashboard/team/"+team.Slug, http.StatusSeeOther) return nil } From 326c5ce45ecd8522c02d191d3cb4ebe2e9f3f12d Mon Sep 17 00:00:00 2001 From: Scott Ferguson Date: Tue, 11 Feb 2014 08:47:55 -0600 Subject: [PATCH 2/2] Alert Github when a build has started --- pkg/queue/queue.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/queue/queue.go b/pkg/queue/queue.go index 7ad39fde..ae462ecb 100644 --- a/pkg/queue/queue.go +++ b/pkg/queue/queue.go @@ -105,6 +105,11 @@ func (b *BuildTask) execute() error { b.Script.Notifications.Send(context) } + // Send "started" notification to Github + if err := updateGitHubStatus(b.Repo, b.Commit); err != nil { + log.Printf("error updating github status: %s\n", err.Error()) + } + // make sure a channel exists for the repository, // the commit, and the commit output (TODO) reposlug := fmt.Sprintf("%s/%s/%s", b.Repo.Host, b.Repo.Owner, b.Repo.Name) @@ -208,7 +213,7 @@ func updateGitHubStatus(repo *Repo, commit *Commit) error { case "Failure": status = "failure" message = "The build failed on drone.io" - case "Pending": + case "Started": status = "pending" message = "The build is pending on drone.io" default: