Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

assignee.go 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. }