@@ -154,6 +154,34 @@ func (c *Comment) LoadIssue() (err error) {
154
154
return
155
155
}
156
156
157
+ func (c * Comment ) loadPoster (e Engine ) (err error ) {
158
+ if c .Poster != nil {
159
+ return nil
160
+ }
161
+
162
+ c .Poster , err = getUserByID (e , c .PosterID )
163
+ if err != nil {
164
+ if IsErrUserNotExist (err ) {
165
+ c .PosterID = - 1
166
+ c .Poster = NewGhostUser ()
167
+ } else {
168
+ log .Error ("getUserByID[%d]: %v" , c .ID , err )
169
+ }
170
+ }
171
+ return err
172
+ }
173
+
174
+ func (c * Comment ) loadAttachments (e Engine ) (err error ) {
175
+ if len (c .Attachments ) > 0 {
176
+ return
177
+ }
178
+ c .Attachments , err = getAttachmentsByCommentID (e , c .ID )
179
+ if err != nil {
180
+ log .Error ("getAttachmentsByCommentID[%d]: %v" , c .ID , err )
181
+ }
182
+ return err
183
+ }
184
+
157
185
// AfterDelete is invoked from XORM after the object is deleted.
158
186
func (c * Comment ) AfterDelete () {
159
187
if c .ID <= 0 {
@@ -997,32 +1025,6 @@ func FindComments(opts FindCommentsOptions) ([]*Comment, error) {
997
1025
return findComments (x , opts )
998
1026
}
999
1027
1000
- // GetCommentsByIssueID returns all comments of an issue.
1001
- func GetCommentsByIssueID (issueID int64 ) ([]* Comment , error ) {
1002
- return findComments (x , FindCommentsOptions {
1003
- IssueID : issueID ,
1004
- Type : CommentTypeUnknown ,
1005
- })
1006
- }
1007
-
1008
- // GetCommentsByIssueIDSince returns a list of comments of an issue since a given time point.
1009
- func GetCommentsByIssueIDSince (issueID , since int64 ) ([]* Comment , error ) {
1010
- return findComments (x , FindCommentsOptions {
1011
- IssueID : issueID ,
1012
- Type : CommentTypeUnknown ,
1013
- Since : since ,
1014
- })
1015
- }
1016
-
1017
- // GetCommentsByRepoIDSince returns a list of comments for all issues in a repo since a given time point.
1018
- func GetCommentsByRepoIDSince (repoID , since int64 ) ([]* Comment , error ) {
1019
- return findComments (x , FindCommentsOptions {
1020
- RepoID : repoID ,
1021
- Type : CommentTypeUnknown ,
1022
- Since : since ,
1023
- })
1024
- }
1025
-
1026
1028
// UpdateComment updates information of comment.
1027
1029
func UpdateComment (doer * User , c * Comment , oldContent string ) error {
1028
1030
if _ , err := x .ID (c .ID ).AllCols ().Update (c ); err != nil {
@@ -1039,6 +1041,9 @@ func UpdateComment(doer *User, c *Comment, oldContent string) error {
1039
1041
if err := c .Issue .LoadAttributes (); err != nil {
1040
1042
return err
1041
1043
}
1044
+ if err := c .loadPoster (x ); err != nil {
1045
+ return err
1046
+ }
1042
1047
1043
1048
mode , _ := AccessLevel (doer , c .Issue .Repo )
1044
1049
if err := PrepareWebhooks (c .Issue .Repo , HookEventIssueComment , & api.IssueCommentPayload {
@@ -1087,6 +1092,7 @@ func DeleteComment(doer *User, comment *Comment) error {
1087
1092
if err := sess .Commit (); err != nil {
1088
1093
return err
1089
1094
}
1095
+ sess .Close ()
1090
1096
1091
1097
if err := comment .LoadPoster (); err != nil {
1092
1098
return err
@@ -1098,6 +1104,9 @@ func DeleteComment(doer *User, comment *Comment) error {
1098
1104
if err := comment .Issue .LoadAttributes (); err != nil {
1099
1105
return err
1100
1106
}
1107
+ if err := comment .loadPoster (x ); err != nil {
1108
+ return err
1109
+ }
1101
1110
1102
1111
mode , _ := AccessLevel (doer , comment .Issue .Repo )
1103
1112
@@ -1154,6 +1163,11 @@ func fetchCodeCommentsByReview(e Engine, issue *Issue, currentUser *User, review
1154
1163
if err := issue .loadRepo (e ); err != nil {
1155
1164
return nil , err
1156
1165
}
1166
+
1167
+ if err := CommentList (comments ).loadPosters (e ); err != nil {
1168
+ return nil , err
1169
+ }
1170
+
1157
1171
// Find all reviews by ReviewID
1158
1172
reviews := make (map [int64 ]* Review )
1159
1173
var ids = make ([]int64 , 0 , len (comments ))
0 commit comments