You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

star.go 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2017 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package repo
  5. import (
  6. "code.gitea.io/gitea/modules/context"
  7. "code.gitea.io/gitea/modules/convert"
  8. api "code.gitea.io/gitea/modules/structs"
  9. )
  10. // ListStargazers list a repository's stargazers
  11. func ListStargazers(ctx *context.APIContext) {
  12. // swagger:operation GET /repos/{owner}/{repo}/stargazers repository repoListStargazers
  13. // ---
  14. // summary: List a repo's stargazers
  15. // produces:
  16. // - application/json
  17. // parameters:
  18. // - name: owner
  19. // in: path
  20. // description: owner of the repo
  21. // type: string
  22. // required: true
  23. // - name: repo
  24. // in: path
  25. // description: name of the repo
  26. // type: string
  27. // required: true
  28. // responses:
  29. // "200":
  30. // "$ref": "#/responses/UserList"
  31. stargazers, err := ctx.Repo.Repository.GetStargazers(-1)
  32. if err != nil {
  33. ctx.Error(500, "GetStargazers", err)
  34. return
  35. }
  36. users := make([]*api.User, len(stargazers))
  37. for i, stargazer := range stargazers {
  38. users[i] = convert.ToUser(stargazer, ctx.IsSigned, ctx.User != nil && ctx.User.IsAdmin)
  39. }
  40. ctx.JSON(200, users)
  41. }