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 642B

12345678910111213141516171819202122232425
  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. api "code.gitea.io/sdk/gitea"
  7. "code.gitea.io/gitea/modules/context"
  8. )
  9. // ListSubscribers list a repo's subscribers (i.e. watchers)
  10. func ListSubscribers(ctx *context.APIContext) {
  11. subscribers, err := ctx.Repo.Repository.GetWatchers(0)
  12. if err != nil {
  13. ctx.Error(500, "GetWatchers", err)
  14. return
  15. }
  16. users := make([]*api.User, len(subscribers))
  17. for i, subscriber := range subscribers {
  18. users[i] = subscriber.APIFormat()
  19. }
  20. ctx.JSON(200, users)
  21. }