diff options
Diffstat (limited to 'models/issue_user.go')
-rw-r--r-- | models/issue_user.go | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/models/issue_user.go b/models/issue_user.go index 67a118fe57..6f9b7591cd 100644 --- a/models/issue_user.go +++ b/models/issue_user.go @@ -6,6 +6,8 @@ package models import ( "fmt" + + "code.gitea.io/gitea/models/db" ) // IssueUser represents an issue-user relation. @@ -17,7 +19,11 @@ type IssueUser struct { IsMentioned bool } -func newIssueUsers(e Engine, repo *Repository, issue *Issue) error { +func init() { + db.RegisterModel(new(IssueUser)) +} + +func newIssueUsers(e db.Engine, repo *Repository, issue *Issue) error { assignees, err := repo.getAssignees(e) if err != nil { return fmt.Errorf("getAssignees: %v", err) @@ -51,27 +57,27 @@ func newIssueUsers(e Engine, repo *Repository, issue *Issue) error { // UpdateIssueUserByRead updates issue-user relation for reading. func UpdateIssueUserByRead(uid, issueID int64) error { - _, err := x.Exec("UPDATE `issue_user` SET is_read=? WHERE uid=? AND issue_id=?", true, uid, issueID) + _, err := db.DefaultContext().Engine().Exec("UPDATE `issue_user` SET is_read=? WHERE uid=? AND issue_id=?", true, uid, issueID) return err } // UpdateIssueUsersByMentions updates issue-user pairs by mentioning. -func UpdateIssueUsersByMentions(ctx DBContext, issueID int64, uids []int64) error { +func UpdateIssueUsersByMentions(ctx *db.Context, issueID int64, uids []int64) error { for _, uid := range uids { iu := &IssueUser{ UID: uid, IssueID: issueID, } - has, err := ctx.e.Get(iu) + has, err := ctx.Engine().Get(iu) if err != nil { return err } iu.IsMentioned = true if has { - _, err = ctx.e.ID(iu.ID).Cols("is_mentioned").Update(iu) + _, err = ctx.Engine().ID(iu.ID).Cols("is_mentioned").Update(iu) } else { - _, err = ctx.e.Insert(iu) + _, err = ctx.Engine().Insert(iu) } if err != nil { return err |