|
|
@ -8,7 +8,6 @@ package private |
|
|
|
import ( |
|
|
|
"strings" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/models" |
|
|
|
"code.gitea.io/gitea/modules/log" |
|
|
|
"code.gitea.io/gitea/modules/private" |
|
|
|
"code.gitea.io/gitea/modules/setting" |
|
|
@ -27,55 +26,6 @@ func CheckInternalToken(ctx *macaron.Context) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//GetRepositoryByOwnerAndName chainload to models.GetRepositoryByOwnerAndName
|
|
|
|
func GetRepositoryByOwnerAndName(ctx *macaron.Context) { |
|
|
|
//TODO use repo.Get(ctx *context.APIContext) ?
|
|
|
|
ownerName := ctx.Params(":owner") |
|
|
|
repoName := ctx.Params(":repo") |
|
|
|
repo, err := models.GetRepositoryByOwnerAndName(ownerName, repoName) |
|
|
|
if err != nil { |
|
|
|
ctx.JSON(500, map[string]interface{}{ |
|
|
|
"err": err.Error(), |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
ctx.JSON(200, repo) |
|
|
|
} |
|
|
|
|
|
|
|
//CheckUnitUser chainload to models.CheckUnitUser
|
|
|
|
func CheckUnitUser(ctx *macaron.Context) { |
|
|
|
repoID := ctx.ParamsInt64(":repoid") |
|
|
|
userID := ctx.ParamsInt64(":userid") |
|
|
|
repo, err := models.GetRepositoryByID(repoID) |
|
|
|
if err != nil { |
|
|
|
ctx.JSON(500, map[string]interface{}{ |
|
|
|
"err": err.Error(), |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
var user *models.User |
|
|
|
if userID > 0 { |
|
|
|
user, err = models.GetUserByID(userID) |
|
|
|
if err != nil { |
|
|
|
ctx.JSON(500, map[string]interface{}{ |
|
|
|
"err": err.Error(), |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
perm, err := models.GetUserRepoPermission(repo, user) |
|
|
|
if err != nil { |
|
|
|
ctx.JSON(500, map[string]interface{}{ |
|
|
|
"err": err.Error(), |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
ctx.JSON(200, perm.UnitAccessMode(models.UnitType(ctx.QueryInt("unitType")))) |
|
|
|
} |
|
|
|
|
|
|
|
// RegisterRoutes registers all internal APIs routes to web application.
|
|
|
|
// These APIs will be invoked by internal commands for example `gitea serv` and etc.
|
|
|
|
func RegisterRoutes(m *macaron.Macaron) { |
|
|
|