示例#1
0
func WriteAllRepos(user *model.HGHUser, w http.ResponseWriter) {
	myrepos, err := user.GetRepoBinds()
	if err != nil || len(myrepos) == 0 {
		WriteError(w, "No repos.")
		return
	}

	repos := make([]model.HGHRepoBinds, 0)

	for _, repoitr := range myrepos {
		repos = append(repos, repoitr)
	}

	if json.NewEncoder(w).Encode(repos) != nil {
		w.WriteHeader(500)
	}
}
示例#2
0
func processUser(user *model.HGHUser) {

	myrepos, err := user.GetRepoBinds()
	if err != nil || len(myrepos) == 0 {
		return
	}

	commitscount := 0
	repocount := 0
	for _, repobind := range myrepos {
		if repobind.NewCommitsCount > 0 {
			commitscount += repobind.NewCommitsCount
			repocount++
		}
	}

	if commitscount > 0 {
		user.NotifyTime = time.Now().Unix()
		user.Save()

		notify.SendWithCommitsRepos(*user, repocount, commitscount)
	}
}
示例#3
0
func AuthorizeUser(username string, token string, device string) bool {
	user := model.HGHUser{username, token, device, time.Now().Unix(), 0}
	user.Save()

	return true
}