Move all mail related codes from models to services/mailer (#7200)

* move all mail related codes from models to modules/mailer

* fix lint

* use DBContext instead Engine

* use WithContext not WithEngine

* Use DBContext instead of Engine

* don't use defer when sess.Close()

* move DBContext to context.go and add some methods

* move mailer from modules/ to services

* fix lint

* fix tests

* fix fmt

* add gitea copyright

* fix tests

* don't expose db functions

* make code clear

* add DefaultDBContext

* fix build

* fix bug
This commit is contained in:
Lunny Xiao 2019-09-24 13:02:49 +08:00 committed by GitHub
parent 730065a3dc
commit 5a438ee3c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 253 additions and 134 deletions

View file

@ -94,22 +94,22 @@ func UpdateIssueUserByRead(uid, issueID int64) error {
}
// UpdateIssueUsersByMentions updates issue-user pairs by mentioning.
func UpdateIssueUsersByMentions(e Engine, issueID int64, uids []int64) error {
func UpdateIssueUsersByMentions(ctx DBContext, issueID int64, uids []int64) error {
for _, uid := range uids {
iu := &IssueUser{
UID: uid,
IssueID: issueID,
}
has, err := e.Get(iu)
has, err := ctx.e.Get(iu)
if err != nil {
return err
}
iu.IsMentioned = true
if has {
_, err = e.ID(iu.ID).Cols("is_mentioned").Update(iu)
_, err = ctx.e.ID(iu.ID).Cols("is_mentioned").Update(iu)
} else {
_, err = e.Insert(iu)
_, err = ctx.e.Insert(iu)
}
if err != nil {
return err