本站源代码
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

54 rindas
1.4KB

  1. // Copyright 2019 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 issue
  5. import (
  6. "code.gitea.io/gitea/models"
  7. "code.gitea.io/gitea/modules/notification"
  8. )
  9. // DeleteNotPassedAssignee deletes all assignees who aren't passed via the "assignees" array
  10. func DeleteNotPassedAssignee(issue *models.Issue, doer *models.User, assignees []*models.User) (err error) {
  11. var found bool
  12. for _, assignee := range issue.Assignees {
  13. found = false
  14. for _, alreadyAssignee := range assignees {
  15. if assignee.ID == alreadyAssignee.ID {
  16. found = true
  17. break
  18. }
  19. }
  20. if !found {
  21. // This function also does comments and hooks, which is why we call it seperatly instead of directly removing the assignees here
  22. if _, _, err := ToggleAssignee(issue, doer, assignee.ID); err != nil {
  23. return err
  24. }
  25. }
  26. }
  27. return nil
  28. }
  29. // ToggleAssignee changes a user between assigned and not assigned for this issue, and make issue comment for it.
  30. func ToggleAssignee(issue *models.Issue, doer *models.User, assigneeID int64) (removed bool, comment *models.Comment, err error) {
  31. removed, comment, err = issue.ToggleAssignee(doer, assigneeID)
  32. if err != nil {
  33. return
  34. }
  35. assignee, err1 := models.GetUserByID(assigneeID)
  36. if err1 != nil {
  37. err = err1
  38. return
  39. }
  40. notification.NotifyIssueChangeAssignee(doer, issue, assignee, removed, comment)
  41. return
  42. }
上海开阖软件有限公司 沪ICP备12045867号-1