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.

123456789101112131415161718192021222324252627282930313233343536
  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. "fmt"
  7. "net/http"
  8. "strconv"
  9. "code.gitea.io/gitea/models"
  10. "code.gitea.io/gitea/modules/context"
  11. )
  12. // IssueWatch sets issue watching
  13. func IssueWatch(c *context.Context) {
  14. watch, err := strconv.ParseBool(c.Req.PostForm.Get("watch"))
  15. if err != nil {
  16. c.ServerError("watch is not bool", err)
  17. return
  18. }
  19. issue := GetActionIssue(c)
  20. if c.Written() {
  21. return
  22. }
  23. if err := models.CreateOrUpdateIssueWatch(c.User.ID, issue.ID, watch); err != nil {
  24. c.ServerError("CreateOrUpdateIssueWatch", err)
  25. return
  26. }
  27. url := fmt.Sprintf("%s/issues/%d", c.Repo.RepoLink, issue.Index)
  28. c.Redirect(url, http.StatusSeeOther)
  29. }