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.

subscriber.go 1.1KB

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. api "code.gitea.io/sdk/gitea"
  8. )
  9. // ListSubscribers list a repo's subscribers (i.e. watchers)
  10. func ListSubscribers(ctx *context.APIContext) {
  11. // swagger:operation GET /repos/{owner}/{repo}/subscribers repository repoListSubscribers
  12. // ---
  13. // summary: List a repo's watchers
  14. // produces:
  15. // - application/json
  16. // parameters:
  17. // - name: owner
  18. // in: path
  19. // description: owner of the repo
  20. // type: string
  21. // required: true
  22. // - name: repo
  23. // in: path
  24. // description: name of the repo
  25. // type: string
  26. // required: true
  27. // responses:
  28. // "200":
  29. // "$ref": "#/responses/UserList"
  30. subscribers, err := ctx.Repo.Repository.GetWatchers(0)
  31. if err != nil {
  32. ctx.Error(500, "GetWatchers", err)
  33. return
  34. }
  35. users := make([]*api.User, len(subscribers))
  36. for i, subscriber := range subscribers {
  37. users[i] = subscriber.APIFormat()
  38. }
  39. ctx.JSON(200, users)
  40. }