fix: stop enqueueing disabled external table exports
This commit is contained in:
@@ -13,7 +13,19 @@ import (
|
||||
"gitea.zheromiku.top/Weknora/dobotai-platform/internal/core"
|
||||
)
|
||||
|
||||
type Store struct{ pool *pgxpool.Pool }
|
||||
type Store struct {
|
||||
pool *pgxpool.Pool
|
||||
questionTableExportEnabled bool
|
||||
faqExportEnabled bool
|
||||
}
|
||||
|
||||
func (s *Store) SetExternalTableExports(questionEnabled, faqEnabled bool) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
s.questionTableExportEnabled = questionEnabled
|
||||
s.faqExportEnabled = faqEnabled
|
||||
}
|
||||
|
||||
func Open(ctx context.Context, databaseURL string) (*Store, error) {
|
||||
if databaseURL == "" {
|
||||
@@ -213,7 +225,7 @@ func (s *Store) FinishTurn(ctx context.Context, turn core.Turn) error {
|
||||
}
|
||||
answerMessageID = turn.AnswerMessageID
|
||||
|
||||
if shouldEnqueueQuestionTableExport(turn) {
|
||||
if shouldEnqueueQuestionTableExport(turn, s.questionTableExportEnabled) {
|
||||
exportID, err := newUUID()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -366,8 +378,8 @@ func shouldCreateAnswerMessage(turn core.Turn) bool {
|
||||
strings.TrimSpace(turn.AnswerMessageID) != ""
|
||||
}
|
||||
|
||||
func shouldEnqueueQuestionTableExport(turn core.Turn) bool {
|
||||
return shouldCreateAnswerMessage(turn) && strings.EqualFold(strings.TrimSpace(turn.Channel), "dingtalk")
|
||||
func shouldEnqueueQuestionTableExport(turn core.Turn, enabled bool) bool {
|
||||
return enabled && shouldCreateAnswerMessage(turn) && strings.EqualFold(strings.TrimSpace(turn.Channel), "dingtalk")
|
||||
}
|
||||
|
||||
func validateDeliveryUpdate(update core.DeliveryUpdate) error {
|
||||
|
||||
Reference in New Issue
Block a user