fix(wuzapi): troca /chat/send/file por /chat/send/document pra PDF
Wuzapi (asternic) atual usa /chat/send/document pra arquivos. O endpoint /chat/send/file não existe (404), então PDF nunca chegava — propagado como ECONNRESET pelo proxy. Mantém os antigos como fallback. Também trata Errno::ECONNRESET como ConnectionError no http handler pra ativar a cadeia de fallback se voltar a acontecer. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
74aea5e2d5
commit
5e7447f1d8
@ -57,12 +57,14 @@ class Wuzapi::Client # rubocop:disable Metrics/ClassLength
|
||||
|
||||
def send_file(user_token, phone_number, base64_data, filename)
|
||||
payload = { 'Phone' => phone_number, 'Body' => base64_data, 'Filename' => filename }
|
||||
# Wuzapi usa `/chat/send/document` pra PDFs/arquivos. As versões antigas
|
||||
# tinham `/chat/send/file` — mantém como fallback pra compat.
|
||||
request(
|
||||
:post,
|
||||
'/chat/send/file',
|
||||
'/chat/send/document',
|
||||
payload,
|
||||
user_auth_headers(user_token),
|
||||
fallback_paths: ['/send/file'],
|
||||
fallback_paths: ['/send/document', '/chat/send/file', '/send/file'],
|
||||
allow_base_fallback: true
|
||||
)
|
||||
end
|
||||
@ -224,7 +226,9 @@ class Wuzapi::Client # rubocop:disable Metrics/ClassLength
|
||||
|
||||
begin
|
||||
http.request(request_obj)
|
||||
rescue SocketError, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ENETUNREACH, Net::OpenTimeout, Net::ReadTimeout => e
|
||||
rescue SocketError, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::EHOSTUNREACH, Errno::ENETUNREACH, Net::OpenTimeout, Net::ReadTimeout => e
|
||||
# ECONNRESET surge quando proxy intermediário corta antes do servidor
|
||||
# responder — tratar como ConnectionError pra ativar fallback de path/base.
|
||||
raise ConnectionError, "Could not connect to Wuzapi: #{e.message}"
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user