feat(database): include BusinessAPI config in WhatsApp account sync
Some checks failed
CI / Build (push) Failing after -22m24s
CI / Lint (push) Failing after -21m54s
CI / Test (1.23) (push) Failing after -21m38s
CI / Test (1.22) (push) Failing after -21m30s

This commit is contained in:
2026-02-20 23:22:03 +02:00
parent 80a4c2b70a
commit 8732b332a1

View File

@@ -388,11 +388,19 @@ func (wh *WhatsHooked) syncConfigToDatabase(ctx context.Context) error {
accountType = "whatsmeow" accountType = "whatsmeow"
} }
cfgJSON := ""
if wa.BusinessAPI != nil {
if b, err := json.Marshal(wa.BusinessAPI); err == nil {
cfgJSON = string(b)
}
}
row := models.ModelPublicWhatsappAccount{ row := models.ModelPublicWhatsappAccount{
ID: resolvespec_common.NewSqlString(wa.ID), ID: resolvespec_common.NewSqlString(wa.ID),
AccountType: resolvespec_common.NewSqlString(accountType), AccountType: resolvespec_common.NewSqlString(accountType),
PhoneNumber: resolvespec_common.NewSqlString(wa.PhoneNumber), PhoneNumber: resolvespec_common.NewSqlString(wa.PhoneNumber),
SessionPath: resolvespec_common.NewSqlString(wa.SessionPath), SessionPath: resolvespec_common.NewSqlString(wa.SessionPath),
Config: resolvespec_common.NewSqlString(cfgJSON),
Active: !wa.Disabled, Active: !wa.Disabled,
UserID: resolvespec_common.NewSqlString(adminID), UserID: resolvespec_common.NewSqlString(adminID),
CreatedAt: resolvespec_common.NewSqlTimeStamp(now), CreatedAt: resolvespec_common.NewSqlTimeStamp(now),
@@ -405,6 +413,7 @@ func (wh *WhatsHooked) syncConfigToDatabase(ctx context.Context) error {
Set("account_type = EXCLUDED.account_type"). Set("account_type = EXCLUDED.account_type").
Set("phone_number = EXCLUDED.phone_number"). Set("phone_number = EXCLUDED.phone_number").
Set("session_path = EXCLUDED.session_path"). Set("session_path = EXCLUDED.session_path").
Set("config = EXCLUDED.config").
Set("active = EXCLUDED.active"). Set("active = EXCLUDED.active").
Set("updated_at = EXCLUDED.updated_at"). Set("updated_at = EXCLUDED.updated_at").
Exec(ctx) Exec(ctx)