diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-11-16 02:18:09 +0800 |
---|---|---|
committer | zeripath <art27@cantab.net> | 2019-11-15 18:18:09 +0000 |
commit | e0e44731723332ac49bb22e6d6d84ae4f92be067 (patch) | |
tree | 1af776de538d109e885cf971b7dd534b74afe926 /models/issue_xref.go | |
parent | c58fba944d701336daab57f0f0647850f7bb671f (diff) | |
download | gitea-e0e44731723332ac49bb22e6d6d84ae4f92be067.tar.gz gitea-e0e44731723332ac49bb22e6d6d84ae4f92be067.zip |
extract some inline functions related with create comment (#8931)
Diffstat (limited to 'models/issue_xref.go')
-rw-r--r-- | models/issue_xref.go | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/models/issue_xref.go b/models/issue_xref.go index 4b01022bc5..787a0e5119 100644 --- a/models/issue_xref.go +++ b/models/issue_xref.go @@ -25,25 +25,6 @@ type crossReferencesContext struct { OrigComment *Comment } -func newCrossReference(e *xorm.Session, ctx *crossReferencesContext, xref *crossReference) error { - var refCommentID int64 - if ctx.OrigComment != nil { - refCommentID = ctx.OrigComment.ID - } - _, err := createComment(e, &CreateCommentOptions{ - Type: ctx.Type, - Doer: ctx.Doer, - Repo: xref.Issue.Repo, - Issue: xref.Issue, - RefRepoID: ctx.OrigIssue.RepoID, - RefIssueID: ctx.OrigIssue.ID, - RefCommentID: refCommentID, - RefAction: xref.Action, - RefIsPull: xref.Issue.IsPull, - }) - return err -} - func neuterCrossReferences(e Engine, issueID int64, commentID int64) error { active := make([]*Comment, 0, 10) sess := e.Where("`ref_action` IN (?, ?, ?)", references.XRefActionNone, references.XRefActionCloses, references.XRefActionReopens) @@ -93,7 +74,21 @@ func (issue *Issue) createCrossReferences(e *xorm.Session, ctx *crossReferencesC return err } for _, xref := range xreflist { - if err = newCrossReference(e, ctx, xref); err != nil { + var refCommentID int64 + if ctx.OrigComment != nil { + refCommentID = ctx.OrigComment.ID + } + if _, err := createComment(e, &CreateCommentOptions{ + Type: ctx.Type, + Doer: ctx.Doer, + Repo: xref.Issue.Repo, + Issue: xref.Issue, + RefRepoID: ctx.OrigIssue.RepoID, + RefIssueID: ctx.OrigIssue.ID, + RefCommentID: refCommentID, + RefAction: xref.Action, + RefIsPull: xref.Issue.IsPull, + }); err != nil { return err } } |