Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(sdk): carry mentions on the Go and Java audio request

Yudhi Armyndharis2a62e9387fe7
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 261a29ad1..9f2b24eb3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
+- The Go and Java SDKs can @mention on an audio send. `SendAudioRequest` was flattened off the shared media type and lost the field, so the typed path could not set it while every other client could.
- Plugin config fields bind their caption to the control for every field type, not just booleans. Clicking the caption of a text, number, secret, enum or textarea field focused nothing, and screen readers announced those inputs with no name.
- Dashboard toggles expose an accessible name and, for the message-type and recipient groups, their selected state. Their captions sit outside the control, so a screen reader announced anonymous checkboxes and unlabelled buttons.
- The PostgreSQL signing key is committed instead of fetched during the image build, so the one build input nothing pinned is now reviewable and diffable, and a release build makes one fewer uncached network call.
@@ -20,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
+- The JavaScript SDK narrows two request types to the values the contract declares: a webhook filter `operator` and a status `font`. A `string` or `number` variable assigned to either now fails to compile.
- whatsapp-web.js block and unblock work again. WhatsApp Web removed the contact resolver both calls used, so every id answered an opaque `500`; its replacement helpers are modal-driven UI wrappers that block nothing headless, and the server now refuses a phone-keyed block because individual chats are keyed by LID while the library folds every id back to a phone number. An install-time patch resolves through the chat-owning identity and calls the block action directly.
- block and unblock accept a privacy id (`@lid`), the only id a contact without a known phone number has. The blocklist read answers those ids verbatim, so refusing them on the write left such a contact listed as blocked with no way to unblock it; ids that name no individual (group, newsletter, broadcast, free text) are still refused with `400`.
- whatsapp-web.js `deleteChannel` classifies a dead browser page as the documented `503` plus an early death signal, like every other channel call; it reached the client directly, so a crash there answered an opaque `500` while the session still reported READY.
diff --git a/sdk/go/client_test.go b/sdk/go/client_test.go
index 0f0bf0d60..90d419394 100644
--- a/sdk/go/client_test.go
+++ b/sdk/go/client_test.go
@@ -1073,6 +1073,31 @@ func TestCallReceivedPayloadDecodes(t *testing.T) {
}
}
+// SendAudioRequest is flattened rather than embedding SendMediaRequest, because ptt is accepted on
+// this route alone. The flattening is what dropped mentions here while every other send carried it,
+// so this asserts the wire body rather than the call.
+func TestSendAudioForwardsMentions(t *testing.T) {
+ rt := &recordTransport{status: 200, body: `{"messageId":"m1","timestamp":1}`}
+ c := newTestClient(t, rt)
+
+ if _, err := c.Messages.SendAudio(context.Background(), "s1", SendAudioRequest{
+ ChatID: "[email protected]",
+ URL: "http://u",
+ Mentions: []string{"[email protected]"},
+ }); err != nil {
+ t.Fatalf("SendAudio: %v", err)
+ }
+
+ var sent map[string]any
+ if err := json.Unmarshal(rt.lastRaw, &sent); err != nil {
+ t.Fatalf("body not JSON: %v", err)
+ }
+ mentions, ok := sent["mentions"].([]any)
+ if !ok || len(mentions) != 1 || mentions[0] != "[email protected]" {
+ t.Fatalf("sent body = %v", sent)
+ }
+}
+
func TestSendTextForwardsMentions(t *testing.T) {
rt := &recordTransport{status: 200, body: `{"messageId":"m1","timestamp":1}`}
c := newTestClient(t, rt)
diff --git a/sdk/go/types_message.go b/sdk/go/types_message.go
index a58651d57..91538ef40 100644
--- a/sdk/go/types_message.go
+++ b/sdk/go/types_message.go
@@ -63,6 +63,9 @@ type SendAudioRequest struct {
// whatsapp-web.js matches the serialized message id, Baileys the raw key id of a message it has
// already stored. Omitted when empty, so an ordinary send carries no quote key.
QuotedMessageID string `json:"quotedMessageId,omitempty"`
+ // WIDs to @mention; the caption must also contain the @<number> token. Kept here as well as on
+ // SendMediaRequest because this struct is flattened rather than embedding it.
+ Mentions []string `json:"mentions,omitempty"`
}
// SendLocationRequest sends a location pin. ChatID/Latitude/Longitude required.
diff --git a/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendAudioRequest.java b/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendAudioRequest.java
index 5a4261944..090651d07 100644
--- a/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendAudioRequest.java
+++ b/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendAudioRequest.java
@@ -9,7 +9,8 @@ public record SendAudioRequest(
String filename,
String caption,
Boolean ptt,
- String quotedMessageId) {
+ String quotedMessageId,
+ java.util.List<String> mentions) {
public static Builder builder() {
return new Builder();
@@ -24,6 +25,7 @@ public record SendAudioRequest(
private String caption;
private Boolean ptt;
private String quotedMessageId;
+ private java.util.List<String> mentions;
public Builder chatId(String v) { this.chatId = v; return this; }
public Builder url(String v) { this.url = v; return this; }
@@ -40,8 +42,12 @@ public record SendAudioRequest(
*/
public Builder quotedMessageId(String v) { this.quotedMessageId = v; return this; }
+ /** WIDs to @mention; the caption must also contain the @&lt;number&gt; token. */
+ public Builder mentions(java.util.List<String> v) { this.mentions = v; return this; }
+
public SendAudioRequest build() {
- return new SendAudioRequest(chatId, url, base64, mimetype, filename, caption, ptt, quotedMessageId);
+ return new SendAudioRequest(
+ chatId, url, base64, mimetype, filename, caption, ptt, quotedMessageId, mentions);
}
}
}
diff --git a/sdk/java/src/test/java/com/rmyndharis/openwa/resources/MessagesResourceTest.java b/sdk/java/src/test/java/com/rmyndharis/openwa/resources/MessagesResourceTest.java
index 4f461b0c1..488548b0b 100644
--- a/sdk/java/src/test/java/com/rmyndharis/openwa/resources/MessagesResourceTest.java
+++ b/sdk/java/src/test/java/com/rmyndharis/openwa/resources/MessagesResourceTest.java
@@ -195,6 +195,19 @@ class MessagesResourceTest {
"s", SendAudioRequest.builder().chatId("[email protected]").url("http://u").quotedMessageId("q-audio").build());
assertTrue(tx.lastRequest().body().contains("q-audio"));
+ // Same flattening cost the audio route its mentions: the field lives on SendMediaRequest,
+ // which this record cannot inherit, so it has to be declared here too or the typed path can
+ // never tag anyone on a voice note.
+ tx.respond(200, MSG);
+ client.messages.sendAudio(
+ "s",
+ SendAudioRequest.builder()
+ .chatId("[email protected]")
+ .url("http://u")
+ .mentions(java.util.List.of("[email protected]"))
+ .build());
+ assertTrue(tx.lastRequest().body().contains("[email protected]"));
+
tx.respond(200, MSG);
client.messages.sendLocation(
"s",