|
|
@@ -6,6 +6,7 @@ |
|
|
|
package org |
|
|
|
|
|
|
|
import ( |
|
|
|
"code.gitea.io/gitea/routers/response" |
|
|
|
"net/http" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/models" |
|
|
@@ -278,3 +279,29 @@ func Delete(ctx *context.APIContext) { |
|
|
|
} |
|
|
|
ctx.Status(http.StatusNoContent) |
|
|
|
} |
|
|
|
|
|
|
|
func GetMyOwners(ctx *context.APIContext) { |
|
|
|
result := make([]*models.User4Front, 0) |
|
|
|
result = append(result, ctx.User.ToFrontFormat()) |
|
|
|
|
|
|
|
orgs, err := models.GetOrgsCanCreateRepoByUserID(ctx.User.ID) |
|
|
|
if err != nil { |
|
|
|
ctx.JSON(http.StatusOK, response.ResponseError(err)) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if !ctx.User.IsAdmin { |
|
|
|
orgsAvailable := []*models.User{} |
|
|
|
for i := 0; i < len(orgs); i++ { |
|
|
|
if orgs[i].CanCreateRepo() { |
|
|
|
orgsAvailable = append(orgsAvailable, orgs[i]) |
|
|
|
} |
|
|
|
} |
|
|
|
orgs = orgsAvailable |
|
|
|
} |
|
|
|
|
|
|
|
for _, o := range orgs { |
|
|
|
result = append(result, o.ToFrontFormat()) |
|
|
|
} |
|
|
|
ctx.JSON(http.StatusOK, response.SuccessWithData(result)) |
|
|
|
} |