Fix Evolution webhook payload format
This commit is contained in:
@@ -142,17 +142,15 @@ public final class EvolutionApiClient {
|
|||||||
if (mockMode(baseUrl) || webhookUrl == null || webhookUrl.isBlank()) return;
|
if (mockMode(baseUrl) || webhookUrl == null || webhookUrl.isBlank()) return;
|
||||||
Map<String, Object> headers = new LinkedHashMap<>();
|
Map<String, Object> headers = new LinkedHashMap<>();
|
||||||
if (webhookSecret != null && !webhookSecret.isBlank()) headers.put("X-Webhook-Secret", webhookSecret);
|
if (webhookSecret != null && !webhookSecret.isBlank()) headers.put("X-Webhook-Secret", webhookSecret);
|
||||||
Map<String, Object> webhook = new LinkedHashMap<>();
|
|
||||||
webhook.put("enabled", true);
|
|
||||||
webhook.put("url", webhookUrl);
|
|
||||||
webhook.put("webhook_by_events", false);
|
|
||||||
webhook.put("webhook_base64", false);
|
|
||||||
webhook.put("byEvents", false);
|
|
||||||
webhook.put("base64", false);
|
|
||||||
webhook.put("events", java.util.List.of("MESSAGES_UPSERT"));
|
|
||||||
if (!headers.isEmpty()) webhook.put("headers", headers);
|
|
||||||
Map<String, Object> payload = new LinkedHashMap<>();
|
Map<String, Object> payload = new LinkedHashMap<>();
|
||||||
payload.put("webhook", webhook);
|
payload.put("enabled", true);
|
||||||
|
payload.put("url", webhookUrl);
|
||||||
|
payload.put("webhook_by_events", false);
|
||||||
|
payload.put("webhook_base64", false);
|
||||||
|
payload.put("byEvents", false);
|
||||||
|
payload.put("base64", false);
|
||||||
|
payload.put("events", java.util.List.of("MESSAGES_UPSERT"));
|
||||||
|
if (!headers.isEmpty()) payload.put("headers", headers);
|
||||||
HttpRequest req = HttpRequest.newBuilder(URI.create(clean(baseUrl) + "/webhook/set/" + instanceName))
|
HttpRequest req = HttpRequest.newBuilder(URI.create(clean(baseUrl) + "/webhook/set/" + instanceName))
|
||||||
.timeout(Duration.ofSeconds(20))
|
.timeout(Duration.ofSeconds(20))
|
||||||
.header("Content-Type", "application/json")
|
.header("Content-Type", "application/json")
|
||||||
|
|||||||
Reference in New Issue
Block a user