summaryrefslogtreecommitdiffstats
path: root/models/issue_comment.go
diff options
context:
space:
mode:
authorblueworrybear <blueworrybear@gmail.com>2019-10-15 20:19:32 +0800
committerzeripath <art27@cantab.net>2019-10-15 13:19:32 +0100
commit8c909820a9fd1697bb690ec0451c4ead97b51505 (patch)
treebda76eca8361237fbd5bc59bda58b278a516ffd6 /models/issue_comment.go
parentd7d348ea86bd8066aeb079ad121120095d5cba4d (diff)
downloadgitea-8c909820a9fd1697bb690ec0451c4ead97b51505.tar.gz
gitea-8c909820a9fd1697bb690ec0451c4ead97b51505.zip
Enable Uploading/Removing Attachments When Editing an Issue/Comment (#8426)
Diffstat (limited to 'models/issue_comment.go')
-rw-r--r--models/issue_comment.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/models/issue_comment.go b/models/issue_comment.go
index 3a090c3b19..ccf239d600 100644
--- a/models/issue_comment.go
+++ b/models/issue_comment.go
@@ -357,6 +357,27 @@ func (c *Comment) LoadAttachments() error {
return nil
}
+// UpdateAttachments update attachments by UUIDs for the comment
+func (c *Comment) UpdateAttachments(uuids []string) error {
+ sess := x.NewSession()
+ defer sess.Close()
+ if err := sess.Begin(); err != nil {
+ return err
+ }
+ attachments, err := getAttachmentsByUUIDs(sess, uuids)
+ if err != nil {
+ return fmt.Errorf("getAttachmentsByUUIDs [uuids: %v]: %v", uuids, err)
+ }
+ for i := 0; i < len(attachments); i++ {
+ attachments[i].IssueID = c.IssueID
+ attachments[i].CommentID = c.ID
+ if err := updateAttachment(sess, attachments[i]); err != nil {
+ return fmt.Errorf("update attachment [id: %d]: %v", attachments[i].ID, err)
+ }
+ }
+ return sess.Commit()
+}
+
// LoadAssigneeUser if comment.Type is CommentTypeAssignees, then load assignees
func (c *Comment) LoadAssigneeUser() error {
var err error