style: fix code error handling, pass nil to context

This commit is contained in:
LinkinStar 2022-10-22 12:07:29 +08:00
parent 67bedfed9f
commit 44ede047d1
4 changed files with 14 additions and 6 deletions

View File

@ -35,7 +35,6 @@ var (
// @name Authorization
func main() {
Execute()
return
}
func runApp() {

View File

@ -99,7 +99,7 @@ func (ar *FollowRepo) Follow(ctx context.Context, objectId, userId string) error
}
func (ar *FollowRepo) FollowCancel(ctx context.Context, objectId, userId string) error {
activityType, _, _, err := ar.activityRepo.GetActivityTypeByObjID(nil, objectId, "follow")
activityType, _, _, err := ar.activityRepo.GetActivityTypeByObjID(ctx, objectId, "follow")
if err != nil {
return err
}
@ -138,6 +138,9 @@ func (ar *FollowRepo) FollowCancel(ctx context.Context, objectId, userId string)
func (ar *FollowRepo) updateFollows(ctx context.Context, session *xorm.Session, objectId string, follows int) error {
objectType, err := obj.GetObjectTypeStrByObjectID(objectId)
if err != nil {
return err
}
switch objectType {
case "question":
_, err = session.Where("id = ?", objectId).Incr("follow_count", follows).Update(&entity.Question{})

View File

@ -109,7 +109,6 @@ func (es *EmailService) Send(ctx context.Context, toEmailAddr, subject, body, co
log.Error(err)
}
}
return
}
// VerifyUrlExpired email send
@ -142,6 +141,9 @@ func (es *EmailService) RegisterTemplate(registerUrl string) (title, body string
}
tmpl, err = template.New("register_body").Parse(ec.RegisterBody)
if err != nil {
return "", "", err
}
err = tmpl.Execute(bodyBuf, templateData)
if err != nil {
return "", "", err
@ -169,6 +171,9 @@ func (es *EmailService) PassResetTemplate(passResetUrl string) (title, body stri
}
tmpl, err = template.New("pass_reset_body").Parse(ec.PassResetBody)
if err != nil {
return "", "", err
}
err = tmpl.Execute(bodyBuf, templateData)
if err != nil {
return "", "", err

View File

@ -2,13 +2,14 @@ package search
import (
"context"
"regexp"
"strings"
"github.com/segmentfault/answer/internal/entity"
"github.com/segmentfault/answer/internal/schema"
"github.com/segmentfault/answer/internal/service/activity_common"
"github.com/segmentfault/answer/internal/service/search_common"
tagcommon "github.com/segmentfault/answer/internal/service/tag_common"
"regexp"
"strings"
)
type TagSearch struct {
@ -64,7 +65,7 @@ func (ts *TagSearch) Search(ctx context.Context) (resp []schema.SearchResp, tota
tag *entity.Tag
exists, followed bool
)
tag, exists, err = ts.tagRepo.GetTagBySlugName(nil, ts.exp)
tag, exists, err = ts.tagRepo.GetTagBySlugName(ctx, ts.exp)
if err != nil {
return
}