UpdateComment updates information of comment.
(doer *User, c *Comment, oldContent string)
| 477 | |
| 478 | // UpdateComment updates information of comment. |
| 479 | func UpdateComment(doer *User, c *Comment, oldContent string) (err error) { |
| 480 | if _, err = x.Id(c.ID).AllCols().Update(c); err != nil { |
| 481 | return err |
| 482 | } |
| 483 | |
| 484 | if err = c.Issue.LoadAttributes(); err != nil { |
| 485 | log.Error("Issue.LoadAttributes [issue_id: %d]: %v", c.IssueID, err) |
| 486 | } else if err = PrepareWebhooks(c.Issue.Repo, HookEventTypeIssueComment, &api.IssueCommentPayload{ |
| 487 | Action: api.HOOK_ISSUE_COMMENT_EDITED, |
| 488 | Issue: c.Issue.APIFormat(), |
| 489 | Comment: c.APIFormat(), |
| 490 | Changes: &api.ChangesPayload{ |
| 491 | Body: &api.ChangesFromPayload{ |
| 492 | From: oldContent, |
| 493 | }, |
| 494 | }, |
| 495 | Repository: c.Issue.Repo.APIFormatLegacy(nil), |
| 496 | Sender: doer.APIFormat(), |
| 497 | }); err != nil { |
| 498 | log.Error("PrepareWebhooks [comment_id: %d]: %v", c.ID, err) |
| 499 | } |
| 500 | |
| 501 | return nil |
| 502 | } |
| 503 | |
| 504 | // DeleteCommentByID deletes the comment by given ID. |
| 505 | func DeleteCommentByID(doer *User, id int64) error { |
no test coverage detected