diff options
Diffstat (limited to 'routes/api/v1/user/follower.go')
-rw-r--r-- | routes/api/v1/user/follower.go | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/routes/api/v1/user/follower.go b/routes/api/v1/user/follower.go index 7c743025..d5464f05 100644 --- a/routes/api/v1/user/follower.go +++ b/routes/api/v1/user/follower.go @@ -16,13 +16,13 @@ func responseApiUsers(c *context.APIContext, users []*models.User) { for i := range users { apiUsers[i] = users[i].APIFormat() } - c.JSON(200, &apiUsers) + c.JSONSuccess(&apiUsers) } func listUserFollowers(c *context.APIContext, u *models.User) { users, err := u.GetFollowers(c.QueryInt("page")) if err != nil { - c.Error(500, "GetUserFollowers", err) + c.ServerError("GetUserFollowers", err) return } responseApiUsers(c, users) @@ -32,7 +32,6 @@ func ListMyFollowers(c *context.APIContext) { listUserFollowers(c, c.User) } -// https://github.com/gogs/go-gogs-client/wiki/Users-Followers#list-followers-of-a-user func ListFollowers(c *context.APIContext) { u := GetUserByParams(c) if c.Written() { @@ -44,7 +43,7 @@ func ListFollowers(c *context.APIContext) { func listUserFollowing(c *context.APIContext, u *models.User) { users, err := u.GetFollowing(c.QueryInt("page")) if err != nil { - c.Error(500, "GetFollowing", err) + c.ServerError("GetFollowing", err) return } responseApiUsers(c, users) @@ -54,7 +53,6 @@ func ListMyFollowing(c *context.APIContext) { listUserFollowing(c, c.User) } -// https://github.com/gogs/go-gogs-client/wiki/Users-Followers#list-users-followed-by-another-user func ListFollowing(c *context.APIContext) { u := GetUserByParams(c) if c.Written() { @@ -65,13 +63,12 @@ func ListFollowing(c *context.APIContext) { func checkUserFollowing(c *context.APIContext, u *models.User, followID int64) { if u.IsFollowing(followID) { - c.Status(204) + c.NotFound() } else { - c.Status(404) + c.NotFound() } } -// https://github.com/gogs/go-gogs-client/wiki/Users-Followers#check-if-you-are-following-a-user func CheckMyFollowing(c *context.APIContext) { target := GetUserByParams(c) if c.Written() { @@ -80,7 +77,6 @@ func CheckMyFollowing(c *context.APIContext) { checkUserFollowing(c, c.User, target.ID) } -// https://github.com/gogs/go-gogs-client/wiki/Users-Followers#check-if-one-user-follows-another func CheckFollowing(c *context.APIContext) { u := GetUserByParams(c) if c.Written() { @@ -93,28 +89,26 @@ func CheckFollowing(c *context.APIContext) { checkUserFollowing(c, u, target.ID) } -// https://github.com/gogs/go-gogs-client/wiki/Users-Followers#follow-a-user func Follow(c *context.APIContext) { target := GetUserByParams(c) if c.Written() { return } if err := models.FollowUser(c.User.ID, target.ID); err != nil { - c.Error(500, "FollowUser", err) + c.ServerError("FollowUser", err) return } - c.Status(204) + c.NoContent() } -// https://github.com/gogs/go-gogs-client/wiki/Users-Followers#unfollow-a-user func Unfollow(c *context.APIContext) { target := GetUserByParams(c) if c.Written() { return } if err := models.UnfollowUser(c.User.ID, target.ID); err != nil { - c.Error(500, "UnfollowUser", err) + c.ServerError("UnfollowUser", err) return } - c.Status(204) + c.NoContent() } |