summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/user
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2021-03-27 17:45:26 +0100
committerGitHub <noreply@github.com>2021-03-27 17:45:26 +0100
commit290cf75f9343a43d9770b1d6f8f3332a23357e27 (patch)
tree520f9f8616fbff3b43a1808ef2d73af3f2fe534b /routers/api/v1/user
parentf4d27498bdc615605e14f783501e1d1256cd8d22 (diff)
downloadgitea-290cf75f9343a43d9770b1d6f8f3332a23357e27.tar.gz
gitea-290cf75f9343a43d9770b1d6f8f3332a23357e27.zip
[refactor] Unify the export of user data via API (#15144)
* [refactor] unify how user data is exported via API * test time via unix timestamp
Diffstat (limited to 'routers/api/v1/user')
-rw-r--r--routers/api/v1/user/follower.go2
-rw-r--r--routers/api/v1/user/key.go4
-rw-r--r--routers/api/v1/user/user.go6
3 files changed, 6 insertions, 6 deletions
diff --git a/routers/api/v1/user/follower.go b/routers/api/v1/user/follower.go
index 39f3c20927..4d316425cd 100644
--- a/routers/api/v1/user/follower.go
+++ b/routers/api/v1/user/follower.go
@@ -18,7 +18,7 @@ import (
func responseAPIUsers(ctx *context.APIContext, users []*models.User) {
apiUsers := make([]*api.User, len(users))
for i := range users {
- apiUsers[i] = convert.ToUser(users[i], ctx.IsSigned, ctx.User != nil && ctx.User.IsAdmin)
+ apiUsers[i] = convert.ToUser(users[i], ctx.User)
}
ctx.JSON(http.StatusOK, &apiUsers)
}
diff --git a/routers/api/v1/user/key.go b/routers/api/v1/user/key.go
index df8a11c61f..780cdf417c 100644
--- a/routers/api/v1/user/key.go
+++ b/routers/api/v1/user/key.go
@@ -25,13 +25,13 @@ func appendPrivateInformation(apiKey *api.PublicKey, key *models.PublicKey, defa
apiKey.KeyType = "user"
if defaultUser.ID == key.OwnerID {
- apiKey.Owner = convert.ToUser(defaultUser, true, true)
+ apiKey.Owner = convert.ToUser(defaultUser, defaultUser)
} else {
user, err := models.GetUserByID(key.OwnerID)
if err != nil {
return apiKey, err
}
- apiKey.Owner = convert.ToUser(user, true, true)
+ apiKey.Owner = convert.ToUser(user, user)
}
} else {
apiKey.KeyType = "unknown"
diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go
index ecc149fe52..6e811bf0f8 100644
--- a/routers/api/v1/user/user.go
+++ b/routers/api/v1/user/user.go
@@ -75,7 +75,7 @@ func Search(ctx *context.APIContext) {
results := make([]*api.User, len(users))
for i := range users {
- results[i] = convert.ToUser(users[i], ctx.IsSigned, ctx.User != nil && ctx.User.IsAdmin)
+ results[i] = convert.ToUser(users[i], ctx.User)
}
ctx.SetLinkHeader(int(maxResults), listOptions.PageSize)
@@ -112,7 +112,7 @@ func GetInfo(ctx *context.APIContext) {
return
}
- ctx.JSON(http.StatusOK, convert.ToUser(u, ctx.IsSigned, ctx.User != nil && (ctx.User.ID == u.ID || ctx.User.IsAdmin)))
+ ctx.JSON(http.StatusOK, convert.ToUser(u, ctx.User))
}
// GetAuthenticatedUser get current user's information
@@ -126,7 +126,7 @@ func GetAuthenticatedUser(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/User"
- ctx.JSON(http.StatusOK, convert.ToUser(ctx.User, ctx.IsSigned, ctx.User != nil))
+ ctx.JSON(http.StatusOK, convert.ToUser(ctx.User, ctx.User))
}
// GetUserHeatmapData is the handler to get a users heatmap