feat(database): include BusinessAPI config in WhatsApp account sync
This commit is contained in:
@@ -388,11 +388,19 @@ func (wh *WhatsHooked) syncConfigToDatabase(ctx context.Context) error {
|
||||
accountType = "whatsmeow"
|
||||
}
|
||||
|
||||
cfgJSON := ""
|
||||
if wa.BusinessAPI != nil {
|
||||
if b, err := json.Marshal(wa.BusinessAPI); err == nil {
|
||||
cfgJSON = string(b)
|
||||
}
|
||||
}
|
||||
|
||||
row := models.ModelPublicWhatsappAccount{
|
||||
ID: resolvespec_common.NewSqlString(wa.ID),
|
||||
AccountType: resolvespec_common.NewSqlString(accountType),
|
||||
PhoneNumber: resolvespec_common.NewSqlString(wa.PhoneNumber),
|
||||
SessionPath: resolvespec_common.NewSqlString(wa.SessionPath),
|
||||
Config: resolvespec_common.NewSqlString(cfgJSON),
|
||||
Active: !wa.Disabled,
|
||||
UserID: resolvespec_common.NewSqlString(adminID),
|
||||
CreatedAt: resolvespec_common.NewSqlTimeStamp(now),
|
||||
@@ -405,6 +413,7 @@ func (wh *WhatsHooked) syncConfigToDatabase(ctx context.Context) error {
|
||||
Set("account_type = EXCLUDED.account_type").
|
||||
Set("phone_number = EXCLUDED.phone_number").
|
||||
Set("session_path = EXCLUDED.session_path").
|
||||
Set("config = EXCLUDED.config").
|
||||
Set("active = EXCLUDED.active").
|
||||
Set("updated_at = EXCLUDED.updated_at").
|
||||
Exec(ctx)
|
||||
|
||||
Reference in New Issue
Block a user