Browse Source

wip:历史记录截取

wangkaiyue 2 years ago
parent
commit
c4bc0152c9
1 changed files with 4 additions and 1 deletions
  1. 4 1
      internal/model/question.go

+ 4 - 1
internal/model/question.go

@@ -39,8 +39,11 @@ type QuestionReq struct {
 
 // ParseHistoryFsw 过滤历史记录敏感词
 func (r *BaseQuestion) ParseHistoryFsw() {
+	if len(r.History) == 0 {
+		return
+	}
 	var newHistory [][]string
-	for i := len(r.History) - 1; i >= 0; i++ {
+	for i := len(r.History) - 1; i >= 0; i-- {
 		var pass bool = true
 		for _, v := range r.History[i] {
 			if fsw.Match(v) {