diff --git a/pkg/config/config.go b/pkg/config/config.go index c90c9e14..0ebec2e2 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -30,6 +30,7 @@ type Config struct { LogType string WebhookFiles bool ConnectOnStartup bool + RerequestFromPhone bool OsName string AmqpUrl string AmqpGlobalEnabled bool @@ -280,6 +281,8 @@ func Load() *Config { checkUserExists = "true" } + rerequestFromPhone := os.Getenv(config_env.REREQUEST_FROM_PHONE) + // Convertendo para int com valores padrĂ£o caso estejam vazios major := 0 if whatsappVersionMajor != "" { @@ -375,6 +378,7 @@ func Load() *Config { EventIgnoreStatus: eventIgnoreStatus == "true", QrcodeMaxCount: qrMaxCount, CheckUserExists: checkUserExists != "false", // Default true, set to false to disable + RerequestFromPhone: rerequestFromPhone == "true", AmqpGlobalEvents: amqpGlobalEvents, AmqpSpecificEvents: amqpSpecificEvents, NatsUrl: natsUrl, diff --git a/pkg/config/env/env.go b/pkg/config/env/env.go index cda9be84..949307e0 100644 --- a/pkg/config/env/env.go +++ b/pkg/config/env/env.go @@ -14,6 +14,7 @@ const ( LOGTYPE = "LOG_TYPE" WEBHOOKFILES = "WEBHOOK_FILES" CONNECT_ON_STARTUP = "CONNECT_ON_STARTUP" + REREQUEST_FROM_PHONE = "REREQUEST_FROM_PHONE" OS_NAME = "OS_NAME" AMQP_URL = "AMQP_URL" AMQP_GLOBAL_ENABLED = "AMQP_GLOBAL_ENABLED" diff --git a/pkg/whatsmeow/service/whatsmeow.go b/pkg/whatsmeow/service/whatsmeow.go index 366f0edb..de144f10 100644 --- a/pkg/whatsmeow/service/whatsmeow.go +++ b/pkg/whatsmeow/service/whatsmeow.go @@ -463,6 +463,8 @@ func (w whatsmeowService) StartClient(cd *ClientData) { client.EnableAutoReconnect = false client.AutoTrustIdentity = true + // Re-request messages that fail to decrypt from the phone instead of dropping them. + client.AutomaticMessageRerequestFromPhone = w.config.RerequestFromPhone mycli := &MyClient{ service: &w,