@@ -21,6 +21,7 @@ import (
21
21
// CommentType defines whether a comment is just a simple comment, an action (like close) or a reference.
22
22
type CommentType int
23
23
24
+ // Enumerate all the comment types
24
25
const (
25
26
// Plain comment, can be associated with a commit (CommitID > 0) and a line (LineNum > 0)
26
27
CommentTypeComment CommentType = iota
@@ -37,8 +38,10 @@ const (
37
38
CommentTypePullRef
38
39
)
39
40
41
+ // CommentTag defines comment tag type
40
42
type CommentTag int
41
43
44
+ // Enumerate all the comment tag types
42
45
const (
43
46
CommentTagNone CommentTag = iota
44
47
CommentTagPoster
@@ -72,15 +75,19 @@ type Comment struct {
72
75
ShowTag CommentTag `xorm:"-"`
73
76
}
74
77
78
+ // BeforeInsert will be invoked by XORM before inserting a record
79
+ // representing this object.
75
80
func (c * Comment ) BeforeInsert () {
76
81
c .CreatedUnix = time .Now ().Unix ()
77
82
c .UpdatedUnix = c .CreatedUnix
78
83
}
79
84
85
+ // BeforeUpdate is invoked from XORM before updating this object.
80
86
func (c * Comment ) BeforeUpdate () {
81
87
c .UpdatedUnix = time .Now ().Unix ()
82
88
}
83
89
90
+ // AfterSet is invoked from XORM after setting the value of a field of this object.
84
91
func (c * Comment ) AfterSet (colName string , _ xorm.Cell ) {
85
92
var err error
86
93
switch colName {
@@ -107,6 +114,7 @@ func (c *Comment) AfterSet(colName string, _ xorm.Cell) {
107
114
}
108
115
}
109
116
117
+ // AfterDelete is invoked from XORM after the object is deleted.
110
118
func (c * Comment ) AfterDelete () {
111
119
_ , err := DeleteAttachmentsByComment (c .ID , true )
112
120
@@ -115,6 +123,7 @@ func (c *Comment) AfterDelete() {
115
123
}
116
124
}
117
125
126
+ // APIFormat converts a Comment to the api.Comment format
118
127
func (c * Comment ) APIFormat () * api.Comment {
119
128
return & api.Comment {
120
129
ID : c .ID ,
@@ -137,21 +146,21 @@ func (c *Comment) EventTag() string {
137
146
138
147
// MailParticipants sends new comment emails to repository watchers
139
148
// and mentioned people.
140
- func (cmt * Comment ) MailParticipants (opType ActionType , issue * Issue ) (err error ) {
141
- mentions := markdown .FindAllMentions (cmt .Content )
142
- if err = UpdateIssueMentions (cmt .IssueID , mentions ); err != nil {
143
- return fmt .Errorf ("UpdateIssueMentions [%d]: %v" , cmt .IssueID , err )
149
+ func (c * Comment ) MailParticipants (opType ActionType , issue * Issue ) (err error ) {
150
+ mentions := markdown .FindAllMentions (c .Content )
151
+ if err = UpdateIssueMentions (c .IssueID , mentions ); err != nil {
152
+ return fmt .Errorf ("UpdateIssueMentions [%d]: %v" , c .IssueID , err )
144
153
}
145
154
146
155
switch opType {
147
156
case ActionCommentIssue :
148
- issue .Content = cmt .Content
157
+ issue .Content = c .Content
149
158
case ActionCloseIssue :
150
159
issue .Content = fmt .Sprintf ("Closed #%d" , issue .Index )
151
160
case ActionReopenIssue :
152
161
issue .Content = fmt .Sprintf ("Reopened #%d" , issue .Index )
153
162
}
154
- if err = mailIssueCommentToParticipants (issue , cmt .Poster , mentions ); err != nil {
163
+ if err = mailIssueCommentToParticipants (issue , c .Poster , mentions ); err != nil {
155
164
log .Error (4 , "mailIssueCommentToParticipants: %v" , err )
156
165
}
157
166
@@ -272,6 +281,7 @@ func createStatusComment(e *xorm.Session, doer *User, repo *Repository, issue *I
272
281
})
273
282
}
274
283
284
+ // CreateCommentOptions defines options for creating comment
275
285
type CreateCommentOptions struct {
276
286
Type CommentType
277
287
Doer * User
@@ -374,7 +384,7 @@ func GetCommentsByIssueID(issueID int64) ([]*Comment, error) {
374
384
return getCommentsByIssueID (x , issueID )
375
385
}
376
386
377
- // GetCommentsByIssueID returns a list of comments of an issue since a given time point.
387
+ // GetCommentsByIssueIDSince returns a list of comments of an issue since a given time point.
378
388
func GetCommentsByIssueIDSince (issueID , since int64 ) ([]* Comment , error ) {
379
389
return getCommentsByIssueIDSince (x , issueID , since )
380
390
}
0 commit comments