Skip to content

GOWA - WhatsApp REST API with support for UI, Multi Account, Webhooks, and MCP, and Chatwoot. Built with Golang for efficient memory use.

Fix issue 353 in go-whatsapp-web-multidevice (#358)

cursor[bot]4bac7e3d08b9
diff --git a/src/views/components/GroupCreate.js b/src/views/components/GroupCreate.js
index af14d03f..81fc4d30 100644
--- a/src/views/components/GroupCreate.js
+++ b/src/views/components/GroupCreate.js
@@ -16,16 +16,27 @@ export default {
}).modal('show');
},
isValidForm() {
- if (!this.title.trim()) {
+ // title must contain at least one non-whitespace char
+ if (!String(this.title ?? '').trim()) {
return false;
}
- if (this.participants.length < 1 || this.participants.every(participant => !participant.trim())) {
+ // must have at least one valid participant
+ if (
+ this.participants.length < 1 ||
+ this.participants.every(p => this.isEmpty(p))
+ ) {
return false;
}
return true;
},
+ // Helper: returns true when param is empty/blank
+ isEmpty(value) {
+ // If the element is an object coming from the picker, use its jid field
+ const str = String(value?.jid ?? value).trim();
+ return !str;
+ },
handleAddParticipant() {
this.participants.push('')
},
@@ -49,8 +60,10 @@ export default {
try {
let response = await window.http.post(`/group`, {
title: this.title,
- // convert participant become list of string
- participants: this.participants.filter(participant => participant !== '').map(participant => `${participant}`)
+ // sanitize participants list
+ participants: this.participants
+ .filter(p => !this.isEmpty(p))
+ .map(p => `${p?.jid ?? p}`)
})
this.handleReset();
return response.data.message;
diff --git a/src/views/components/GroupManageParticipants.js b/src/views/components/GroupManageParticipants.js
index 483b0d9c..0c2ef45b 100644
--- a/src/views/components/GroupManageParticipants.js
+++ b/src/views/components/GroupManageParticipants.js
@@ -22,12 +22,20 @@ export default {
}).modal('show');
},
isValidForm() {
- if (this.participants.length < 1 || this.participants.every(participant => !participant.trim())) {
+ if (
+ this.participants.length < 1 ||
+ this.participants.every(p => this.isEmpty(p))
+ ) {
return false;
}
return true;
},
+ // Helper to determine if participant value is empty
+ isEmpty(value) {
+ const str = String(value?.jid ?? value).trim();
+ return !str;
+ },
handleAddParticipant() {
this.participants.push('');
},
@@ -53,7 +61,9 @@ export default {
const payload = {
group_id: this.group_id,
// convert participant become list of string
- participants: this.participants.filter(participant => participant !== '').map(participant => `${participant}`),
+ participants: this.participants
+ .filter(p => !this.isEmpty(p))
+ .map(p => `${p?.jid ?? p}`),
};
let response;