Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(sdk): keep the SearchQuery constructor Java SDK 0.7.0 shipped

Yudhi Armyndharis6ceb27a7c787
diff --git a/sdk/java/src/main/java/com/rmyndharis/openwa/model/SearchQuery.java b/sdk/java/src/main/java/com/rmyndharis/openwa/model/SearchQuery.java
index fe6303a30..ba1a02e85 100644
--- a/sdk/java/src/main/java/com/rmyndharis/openwa/model/SearchQuery.java
+++ b/sdk/java/src/main/java/com/rmyndharis/openwa/model/SearchQuery.java
@@ -23,6 +23,21 @@ public record SearchQuery(
Long dateTo,
Integer limit,
Integer offset) {
+ /** Back-compatible constructor without a match mode, the server's default (word). */
+ public SearchQuery(
+ String q,
+ String sessionId,
+ String chatId,
+ MessageDirection direction,
+ String type,
+ String from,
+ Long dateFrom,
+ Long dateTo,
+ Integer limit,
+ Integer offset) {
+ this(q, null, sessionId, chatId, direction, type, from, dateFrom, dateTo, limit, offset);
+ }
+
public static Builder builder() {
return new Builder();
}
diff --git a/sdk/java/src/test/java/com/rmyndharis/openwa/resources/SearchResourceTest.java b/sdk/java/src/test/java/com/rmyndharis/openwa/resources/SearchResourceTest.java
index 8bf5fdc25..1ef11b876 100644
--- a/sdk/java/src/test/java/com/rmyndharis/openwa/resources/SearchResourceTest.java
+++ b/sdk/java/src/test/java/com/rmyndharis/openwa/resources/SearchResourceTest.java
@@ -1,6 +1,7 @@
package com.rmyndharis.openwa.resources;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -49,6 +50,19 @@ class SearchResourceTest {
assertTrue(tx.lastRequest().url().contains("direction=incoming"));
}
+ @Test
+ void searchKeepsTheConstructorWithoutMatch() {
+ tx.respond(200, RESULTS);
+ SearchQuery query = new SearchQuery(
+ "hello", "s1", "[email protected]", MessageDirection.INCOMING, "text", "[email protected]", 1L, 2L, 10, 0);
+ assertNull(query.match());
+ assertEquals("s1", query.sessionId());
+ client.search.search(query);
+ assertTrue(tx.lastRequest().url().contains("q=hello"));
+ assertTrue(tx.lastRequest().url().contains("sessionId=s1"));
+ assertFalse(tx.lastRequest().url().contains("match="));
+ }
+
@Test
void searchSerializesMatchAsLowercaseWireValue() {
tx.respond(200, RESULTS);