Removed unrelated changes
This commit is contained in:
parent
58e7c2bc94
commit
5a9f2735f9
|
|
@ -79,23 +79,23 @@ const (
|
||||||
|
|
||||||
// Comment represents a comment in commit and issue page.
|
// Comment represents a comment in commit and issue page.
|
||||||
type Comment struct {
|
type Comment struct {
|
||||||
ID int64 `xorm:"pk autoincr"`
|
ID int64 `xorm:"pk autoincr"`
|
||||||
Type CommentType
|
Type CommentType
|
||||||
PosterID int64 `xorm:"INDEX"`
|
PosterID int64 `xorm:"INDEX"`
|
||||||
Poster *User `xorm:"-"`
|
Poster *User `xorm:"-"`
|
||||||
IssueID int64 `xorm:"INDEX"`
|
IssueID int64 `xorm:"INDEX"`
|
||||||
LabelID int64
|
LabelID int64
|
||||||
Label *Label `xorm:"-"`
|
Label *Label `xorm:"-"`
|
||||||
OldMilestoneID int64
|
OldMilestoneID int64
|
||||||
MilestoneID int64
|
MilestoneID int64
|
||||||
OldMilestone *Milestone `xorm:"-"`
|
OldMilestone *Milestone `xorm:"-"`
|
||||||
Milestone *Milestone `xorm:"-"`
|
Milestone *Milestone `xorm:"-"`
|
||||||
OldAssigneeID int64
|
OldAssigneeID int64
|
||||||
AssigneeID int64
|
AssigneeID int64
|
||||||
Assignee *User `xorm:"-"`
|
Assignee *User `xorm:"-"`
|
||||||
OldAssignee *User `xorm:"-"`
|
OldAssignee *User `xorm:"-"`
|
||||||
OldTitle string
|
OldTitle string
|
||||||
NewTitle string
|
NewTitle string
|
||||||
DependentIssueID int64
|
DependentIssueID int64
|
||||||
DependentIssue *Issue `xorm:"-"`
|
DependentIssue *Issue `xorm:"-"`
|
||||||
|
|
||||||
|
|
@ -118,30 +118,25 @@ type Comment struct {
|
||||||
ShowTag CommentTag `xorm:"-"`
|
ShowTag CommentTag `xorm:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// AfterSet is invoked from XORM after setting the value of a field of this object.
|
// AfterLoad is invoked from XORM after setting the values of all fields of this object.
|
||||||
func (c *Comment) AfterSet(colName string, _ xorm.Cell) {
|
func (c *Comment) AfterLoad(session *xorm.Session) {
|
||||||
var err error
|
c.Created = time.Unix(c.CreatedUnix, 0).Local()
|
||||||
switch colName {
|
c.Updated = time.Unix(c.UpdatedUnix, 0).Local()
|
||||||
case "id":
|
|
||||||
c.Attachments, err = GetAttachmentsByCommentID(c.ID)
|
|
||||||
if err != nil {
|
|
||||||
log.Error(3, "GetAttachmentsByCommentID[%d]: %v", c.ID, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
case "poster_id":
|
var err error
|
||||||
c.Poster, err = GetUserByID(c.PosterID)
|
c.Attachments, err = getAttachmentsByCommentID(session, c.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if IsErrUserNotExist(err) {
|
log.Error(3, "getAttachmentsByCommentID[%d]: %v", c.ID, err)
|
||||||
c.PosterID = -1
|
}
|
||||||
c.Poster = NewGhostUser()
|
|
||||||
} else {
|
c.Poster, err = getUserByID(session, c.PosterID)
|
||||||
log.Error(3, "GetUserByID[%d]: %v", c.ID, err)
|
if err != nil {
|
||||||
}
|
if IsErrUserNotExist(err) {
|
||||||
|
c.PosterID = -1
|
||||||
|
c.Poster = NewGhostUser()
|
||||||
|
} else {
|
||||||
|
log.Error(3, "getUserByID[%d]: %v", c.ID, err)
|
||||||
}
|
}
|
||||||
case "created_unix":
|
|
||||||
c.Created = time.Unix(c.CreatedUnix, 0).Local()
|
|
||||||
case "updated_unix":
|
|
||||||
c.Updated = time.Unix(c.UpdatedUnix, 0).Local()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -322,27 +317,25 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
|
||||||
}
|
}
|
||||||
|
|
||||||
comment := &Comment{
|
comment := &Comment{
|
||||||
Type: opts.Type,
|
Type: opts.Type,
|
||||||
PosterID: opts.Doer.ID,
|
PosterID: opts.Doer.ID,
|
||||||
Poster: opts.Doer,
|
Poster: opts.Doer,
|
||||||
IssueID: opts.Issue.ID,
|
IssueID: opts.Issue.ID,
|
||||||
LabelID: LabelID,
|
LabelID: LabelID,
|
||||||
OldMilestoneID: opts.OldMilestoneID,
|
OldMilestoneID: opts.OldMilestoneID,
|
||||||
MilestoneID: opts.MilestoneID,
|
MilestoneID: opts.MilestoneID,
|
||||||
OldAssigneeID: opts.OldAssigneeID,
|
OldAssigneeID: opts.OldAssigneeID,
|
||||||
AssigneeID: opts.AssigneeID,
|
AssigneeID: opts.AssigneeID,
|
||||||
CommitID: opts.CommitID,
|
CommitID: opts.CommitID,
|
||||||
CommitSHA: opts.CommitSHA,
|
CommitSHA: opts.CommitSHA,
|
||||||
Line: opts.LineNum,
|
Line: opts.LineNum,
|
||||||
Content: opts.Content,
|
Content: opts.Content,
|
||||||
OldTitle: opts.OldTitle,
|
OldTitle: opts.OldTitle,
|
||||||
NewTitle: opts.NewTitle,
|
NewTitle: opts.NewTitle,
|
||||||
DependentIssue: opts.DependentIssue,
|
DependentIssue: opts.DependentIssue,
|
||||||
DependentIssueID: depID,
|
DependentIssueID: depID,
|
||||||
}
|
}
|
||||||
|
if _, err = e.Insert(comment); err != nil {
|
||||||
_, err = e.Insert(comment)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -532,11 +525,11 @@ func createIssueDependencyComment(e *xorm.Session, doer *User, issue *Issue, dep
|
||||||
|
|
||||||
// CreateCommentOptions defines options for creating comment
|
// CreateCommentOptions defines options for creating comment
|
||||||
type CreateCommentOptions struct {
|
type CreateCommentOptions struct {
|
||||||
Type CommentType
|
Type CommentType
|
||||||
Doer *User
|
Doer *User
|
||||||
Repo *Repository
|
Repo *Repository
|
||||||
Issue *Issue
|
Issue *Issue
|
||||||
Label *Label
|
Label *Label
|
||||||
DependentIssue *Issue
|
DependentIssue *Issue
|
||||||
|
|
||||||
OldMilestoneID int64
|
OldMilestoneID int64
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user