(c *context.Context)
| 741 | } |
| 742 | |
| 743 | func UpdateIssueLabel(c *context.Context) { |
| 744 | issue := getActionIssue(c) |
| 745 | if c.Written() { |
| 746 | return |
| 747 | } |
| 748 | |
| 749 | if c.Query("action") == "clear" { |
| 750 | if err := issue.ClearLabels(c.User); err != nil { |
| 751 | c.Error(err, "clear labels") |
| 752 | return |
| 753 | } |
| 754 | } else { |
| 755 | isAttach := c.Query("action") == "attach" |
| 756 | label, err := database.GetLabelOfRepoByID(c.Repo.Repository.ID, c.QueryInt64("id")) |
| 757 | if err != nil { |
| 758 | c.NotFoundOrError(err, "get label by ID") |
| 759 | return |
| 760 | } |
| 761 | |
| 762 | if isAttach && !issue.HasLabel(label.ID) { |
| 763 | if err = issue.AddLabel(c.User, label); err != nil { |
| 764 | c.Error(err, "add label") |
| 765 | return |
| 766 | } |
| 767 | } else if !isAttach && issue.HasLabel(label.ID) { |
| 768 | if err = issue.RemoveLabel(c.User, label); err != nil { |
| 769 | c.Error(err, "remove label") |
| 770 | return |
| 771 | } |
| 772 | } |
| 773 | } |
| 774 | |
| 775 | c.JSONSuccess(map[string]any{ |
| 776 | "ok": true, |
| 777 | }) |
| 778 | } |
| 779 | |
| 780 | func UpdateIssueMilestone(c *context.Context) { |
| 781 | issue := getActionIssue(c) |
nothing calls this directly
no test coverage detected