aboutsummaryrefslogtreecommitdiffstats
path: root/models/issue_lock.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-10-11 14:44:43 +0800
committerGitHub <noreply@github.com>2019-10-11 14:44:43 +0800
commit46a12f196b1742a2462259ed3dd9c33c4c2f150b (patch)
treeb8203c7d6d91841ce53a7b875135714b372fa1a5 /models/issue_lock.go
parent9ff9f5ad1d8d2680c9c146831458afdbd4e641df (diff)
downloadgitea-46a12f196b1742a2462259ed3dd9c33c4c2f150b.tar.gz
gitea-46a12f196b1742a2462259ed3dd9c33c4c2f150b.zip
Move change issue title from models to issue service package (#8456)
* move change issue title from models to issue service package * make the change less * fix typo
Diffstat (limited to 'models/issue_lock.go')
-rw-r--r--models/issue_lock.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/models/issue_lock.go b/models/issue_lock.go
index 5a2d996b64..dc6655ad3b 100644
--- a/models/issue_lock.go
+++ b/models/issue_lock.go
@@ -28,7 +28,6 @@ func updateIssueLock(opts *IssueLockOptions, lock bool) error {
}
opts.Issue.IsLocked = lock
-
var commentType CommentType
if opts.Issue.IsLocked {
commentType = CommentTypeLock
@@ -36,16 +35,26 @@ func updateIssueLock(opts *IssueLockOptions, lock bool) error {
commentType = CommentTypeUnlock
}
- if err := UpdateIssueCols(opts.Issue, "is_locked"); err != nil {
+ sess := x.NewSession()
+ defer sess.Close()
+ if err := sess.Begin(); err != nil {
+ return err
+ }
+
+ if err := updateIssueCols(sess, opts.Issue, "is_locked"); err != nil {
return err
}
- _, err := CreateComment(&CreateCommentOptions{
+ _, err := createComment(sess, &CreateCommentOptions{
Doer: opts.Doer,
Issue: opts.Issue,
Repo: opts.Issue.Repo,
Type: commentType,
Content: opts.Reason,
})
- return err
+ if err != nil {
+ return err
+ }
+
+ return sess.Commit()
}