diff options
Diffstat (limited to 'models/issue_comment.go')
-rw-r--r-- | models/issue_comment.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/models/issue_comment.go b/models/issue_comment.go index ea83c356ee..aedb124863 100644 --- a/models/issue_comment.go +++ b/models/issue_comment.go @@ -60,6 +60,12 @@ const ( CommentTypeAddTimeManual // Cancel a stopwatch for time tracking CommentTypeCancelTracking + // Added a due date + CommentTypeAddedDeadline + // Modified the due date + CommentTypeModifiedDeadline + // Removed a due date + CommentTypeRemovedDeadline ) // CommentTag defines comment tag type @@ -485,6 +491,34 @@ func createAssigneeComment(e *xorm.Session, doer *User, repo *Repository, issue }) } +func createDeadlineComment(e *xorm.Session, doer *User, issue *Issue, newDeadlineUnix util.TimeStamp) (*Comment, error) { + + var content string + var commentType CommentType + + // newDeadline = 0 means deleting + if newDeadlineUnix == 0 { + commentType = CommentTypeRemovedDeadline + content = issue.DeadlineUnix.Format("2006-01-02") + } else if issue.DeadlineUnix == 0 { + // Check if the new date was added or modified + // If the actual deadline is 0 => deadline added + commentType = CommentTypeAddedDeadline + content = newDeadlineUnix.Format("2006-01-02") + } else { // Otherwise modified + commentType = CommentTypeModifiedDeadline + content = newDeadlineUnix.Format("2006-01-02") + "|" + issue.DeadlineUnix.Format("2006-01-02") + } + + return createComment(e, &CreateCommentOptions{ + Type: commentType, + Doer: doer, + Repo: issue.Repo, + Issue: issue, + Content: content, + }) +} + func createChangeTitleComment(e *xorm.Session, doer *User, repo *Repository, issue *Issue, oldTitle, newTitle string) (*Comment, error) { return createComment(e, &CreateCommentOptions{ Type: CommentTypeChangeTitle, |