lgtm/api/teams.go

27 строки
594 B
Go
Исходник Обычный вид История

2016-04-19 07:22:23 +03:00
package api
import (
2016-11-14 15:32:32 +03:00
"github.com/go-gitea/lgtm/cache"
"github.com/go-gitea/lgtm/model"
"github.com/go-gitea/lgtm/router/middleware/session"
2016-04-19 07:22:23 +03:00
"github.com/gin-gonic/gin"
2020-12-06 17:11:10 +03:00
"github.com/sirupsen/logrus"
2016-04-19 07:22:23 +03:00
)
// GetTeams gets the list of user teams.
func GetTeams(c *gin.Context) {
user := session.User(c)
teams, err := cache.GetTeams(c, user)
if err != nil {
2016-04-19 21:53:52 +03:00
logrus.Errorf("Error getting teams for user %s. %s", user.Login, err)
2016-04-19 07:22:23 +03:00
c.String(500, "Error getting team list")
return
}
teams = append(teams, &model.Team{
Login: user.Login,
Avatar: user.Avatar,
})
c.JSON(200, teams)
}