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"
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user