(c *context.Context)
| 920 | } |
| 921 | |
| 922 | func UpdateCommentContent(c *context.Context) { |
| 923 | comment, err := database.GetCommentByID(c.ParamsInt64(":id")) |
| 924 | if err != nil { |
| 925 | c.NotFoundOrError(err, "get comment by ID") |
| 926 | return |
| 927 | } |
| 928 | |
| 929 | issue, err := database.GetIssueByID(comment.IssueID) |
| 930 | if err != nil { |
| 931 | c.NotFoundOrError(err, "get issue by ID") |
| 932 | return |
| 933 | } |
| 934 | |
| 935 | if issue.RepoID != c.Repo.Repository.ID { |
| 936 | c.NotFound() |
| 937 | return |
| 938 | } |
| 939 | |
| 940 | if c.UserID() != comment.PosterID && !c.Repo.IsAdmin() { |
| 941 | c.NotFound() |
| 942 | return |
| 943 | } else if comment.Type != database.CommentTypeComment { |
| 944 | c.Status(http.StatusNoContent) |
| 945 | return |
| 946 | } |
| 947 | |
| 948 | oldContent := comment.Content |
| 949 | comment.Content = c.Query("content") |
| 950 | if comment.Content == "" { |
| 951 | c.JSONSuccess(map[string]any{ |
| 952 | "content": "", |
| 953 | }) |
| 954 | return |
| 955 | } |
| 956 | if err = database.UpdateComment(c.User, comment, oldContent); err != nil { |
| 957 | c.Error(err, "update comment") |
| 958 | return |
| 959 | } |
| 960 | |
| 961 | c.JSONSuccess(map[string]string{ |
| 962 | "content": string(markup.Markdown(comment.Content, c.Query("context"), c.Repo.Repository.ComposeMetas())), |
| 963 | }) |
| 964 | } |
| 965 | |
| 966 | func DeleteComment(c *context.Context) { |
| 967 | comment, err := database.GetCommentByID(c.ParamsInt64(":id")) |
nothing calls this directly
no test coverage detected