fix(baileys): read groups_enabled flag dynamically from ENV
GROUPS_ENABLED was a Ruby constant evaluated once at class load time, so changes to the env var were not picked up on boot. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
2bf55d261a
commit
eb22a96ba5
@ -8,10 +8,9 @@ class Whatsapp::Providers::WhatsappBaileysService < Whatsapp::Providers::BaseSer
|
||||
DEFAULT_CLIENT_NAME = ENV.fetch('BAILEYS_PROVIDER_DEFAULT_CLIENT_NAME', nil)
|
||||
DEFAULT_URL = ENV.fetch('BAILEYS_PROVIDER_DEFAULT_URL', nil)
|
||||
DEFAULT_API_KEY = ENV.fetch('BAILEYS_PROVIDER_DEFAULT_API_KEY', nil)
|
||||
GROUPS_ENABLED = ENV.fetch('BAILEYS_WHATSAPP_GROUPS_ENABLED', 'false') == 'true'
|
||||
|
||||
def self.groups_enabled?
|
||||
GROUPS_ENABLED
|
||||
ENV.fetch('BAILEYS_WHATSAPP_GROUPS_ENABLED', 'false') == 'true'
|
||||
end
|
||||
|
||||
def self.status
|
||||
@ -47,7 +46,7 @@ class Whatsapp::Providers::WhatsappBaileysService < Whatsapp::Providers::BaseSer
|
||||
webhookVerifyToken: whatsapp_channel.provider_config['webhook_verify_token'],
|
||||
# TODO: Remove on Baileys v2, default will be false
|
||||
includeMedia: false,
|
||||
groupsEnabled: GROUPS_ENABLED
|
||||
groupsEnabled: self.class.groups_enabled?
|
||||
}.compact.to_json
|
||||
)
|
||||
|
||||
|
||||
@ -101,7 +101,7 @@ describe Whatsapp::Providers::WhatsappBaileysService do
|
||||
webhookUrl: whatsapp_channel.inbox.callback_webhook_url,
|
||||
webhookVerifyToken: whatsapp_channel.provider_config['webhook_verify_token'],
|
||||
includeMedia: false,
|
||||
groupsEnabled: Whatsapp::Providers::WhatsappBaileysService::GROUPS_ENABLED
|
||||
groupsEnabled: described_class.groups_enabled?
|
||||
}.to_json
|
||||
)
|
||||
.to_return(status: 200)
|
||||
@ -122,7 +122,7 @@ describe Whatsapp::Providers::WhatsappBaileysService do
|
||||
webhookUrl: whatsapp_channel.inbox.callback_webhook_url,
|
||||
webhookVerifyToken: whatsapp_channel.provider_config['webhook_verify_token'],
|
||||
includeMedia: false,
|
||||
groupsEnabled: Whatsapp::Providers::WhatsappBaileysService::GROUPS_ENABLED
|
||||
groupsEnabled: described_class.groups_enabled?
|
||||
}.to_json
|
||||
)
|
||||
.to_return(
|
||||
@ -1331,7 +1331,7 @@ describe Whatsapp::Providers::WhatsappBaileysService do
|
||||
webhookUrl: whatsapp_channel.inbox.callback_webhook_url,
|
||||
webhookVerifyToken: whatsapp_channel.provider_config['webhook_verify_token'],
|
||||
includeMedia: false,
|
||||
groupsEnabled: Whatsapp::Providers::WhatsappBaileysService::GROUPS_ENABLED
|
||||
groupsEnabled: described_class.groups_enabled?
|
||||
}.to_json
|
||||
)
|
||||
.to_return(status: 200)
|
||||
@ -1350,7 +1350,7 @@ describe Whatsapp::Providers::WhatsappBaileysService do
|
||||
webhookUrl: whatsapp_channel.inbox.callback_webhook_url,
|
||||
webhookVerifyToken: whatsapp_channel.provider_config['webhook_verify_token'],
|
||||
includeMedia: false,
|
||||
groupsEnabled: Whatsapp::Providers::WhatsappBaileysService::GROUPS_ENABLED
|
||||
groupsEnabled: described_class.groups_enabled?
|
||||
}.to_json
|
||||
)
|
||||
.to_return(status: 200)
|
||||
@ -1369,7 +1369,7 @@ describe Whatsapp::Providers::WhatsappBaileysService do
|
||||
webhookUrl: whatsapp_channel.inbox.callback_webhook_url,
|
||||
webhookVerifyToken: whatsapp_channel.provider_config['webhook_verify_token'],
|
||||
includeMedia: false,
|
||||
groupsEnabled: Whatsapp::Providers::WhatsappBaileysService::GROUPS_ENABLED
|
||||
groupsEnabled: described_class.groups_enabled?
|
||||
}.to_json
|
||||
)
|
||||
.to_return(status: 400, body: 'reconnection failed')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user