fix: reconnecting deadlock (#66)

* fix: fill whatsapp provider url with value from inbox provider config

* chore: compact blank on setup channel provider

* fix: deadlock on `reconnecting` state
This commit is contained in:
Gabriel Jablonski 2025-06-11 00:21:19 -03:00 committed by GitHub
parent 6e1da287a2
commit b7a316fafa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 3 deletions

View File

@ -48,7 +48,10 @@ onMounted(() => {
}
});
onUnmounted(() => {
if (connection.value === 'connecting') {
if (
connection.value === 'connecting' ||
connection.value === 'reconnecting'
) {
disconnect();
}
});

View File

@ -61,6 +61,7 @@ export default {
methods: {
setDefaults() {
this.hmacMandatory = this.inbox.hmac_mandatory || false;
this.whatsAppProviderUrl = this.inbox.provider_config?.provider_url ?? '';
this.markAsRead = this.inbox.provider_config.mark_as_read ?? true;
},
handleHmacFlag() {

View File

@ -107,8 +107,13 @@ class Channel::Whatsapp < ApplicationRecord
provider_service.unread_message(conversation.contact.phone_number, last_message) if last_message
end
def disconnect_channel_provider
provider_service.disconnect_channel_provider
ensure
update_provider_connection!(connection: 'close')
end
delegate :setup_channel_provider, to: :provider_service
delegate :disconnect_channel_provider, to: :provider_service
delegate :send_message, to: :provider_service
delegate :send_template, to: :provider_service
delegate :sync_templates, to: :provider_service

View File

@ -18,7 +18,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
}.compact.to_json
}.compact_blank.to_json
)
process_response(response)