GOWA - WhatsApp REST API with support for UI, Multi Account, Webhooks, and MCP, and Chatwoot. Built with Golang for efficient memory use.
Go botgogolanggolang-whatsappgolang-whatsapp-apirestrest-apiwhatsappwhatsapp-apiwhatsapp-api-gowhatsapp-multi-devicewhatsapp-web-multi-device
chore: update OpenAPI documentation and improve group participant handling
Aldino Kemal0b8deadfe056
diff --git a/docs/openapi.yaml b/docs/openapi.yamlindex 07f8f978..91ae49ab 100644--- a/docs/openapi.yaml+++ b/docs/openapi.yaml@@ -1,7 +1,7 @@openapi: "3.0.0"info:title: WhatsApp API MultiDevice- version: 8.3.0+ version: 8.3.1description: |This API is used for sending whatsapp via API.@@ -3384,6 +3384,108 @@ components:type: stringexample: Success update group photo+ UserMyGroupItem:+ type: object+ description: |+ One joined group as serialized `whatsmeow/types.GroupInfo`. Embedded structs are flattened; field names stay PascalCase (Go default JSON).+ properties:+ JID:+ type: string+ example: "[email protected]"+ OwnerJID:+ type: string+ OwnerPN:+ type: string+ Name:+ type: string+ NameSetAt:+ type: string+ format: date-time+ NameSetBy:+ type: string+ NameSetByPN:+ type: string+ GroupCreated:+ type: string+ format: date-time+ CreatorCountryCode:+ type: string+ ParticipantVersionID:+ type: string+ ParticipantCount:+ type: integer+ Participants:+ type: array+ items:+ $ref: '#/components/schemas/JoinedGroupParticipant'+ MemberAddMode:+ type: string+ example: "admin_add"+ Suspended:+ type: boolean+ AddressingMode:+ type: string+ IsLocked:+ type: boolean+ IsAnnounce:+ type: boolean+ AnnounceVersionID:+ type: string+ IsEphemeral:+ type: boolean+ DisappearingTimer:+ type: integer+ IsIncognito:+ type: boolean+ IsJoinApprovalRequired:+ type: boolean+ DefaultMembershipApprovalMode:+ type: string+ IsParent:+ type: boolean+ LinkedParentJID:+ type: string+ IsDefaultSubGroup:+ type: boolean+ Topic:+ type: string+ TopicID:+ type: string+ TopicDeleted:+ type: boolean+ TopicSetAt:+ type: string+ format: date-time+ TopicSetBy:+ type: string+ TopicSetByPN:+ type: string++ JoinedGroupParticipant:+ type: object+ description: Serialized `whatsmeow/types.GroupParticipant` in joined-group list payloads.+ properties:+ JID:+ type: string+ description: Primary ID for the member (often `@lid`).+ PhoneNumber:+ type: string+ description: User JID string when known (e.g. `[email protected]`); may be empty in edge cases.+ LID:+ type: string+ IsAdmin:+ type: boolean+ IsSuperAdmin:+ type: boolean+ DisplayName:+ type: string+ description: Set for some anonymous / announcement cases; often empty.+ Error:+ type: integer+ AddRequest:+ type: object+ nullable: true+UserGroupResponse:type: objectproperties:@@ -3399,35 +3501,7 @@ components:data:type: arrayitems:- type: object- properties:- JID:- type: string- OwnerJID:- type: string- Name:- type: string- NameSetAt:- type: string- NameSetBy:- type: string- GroupCreated:- type: string- ParticipantVersionID:- type: string- Participants:- type: array- items:- properties:- JID:- type: string- IsAdmin:- type: boolean- IsSuperAdmin:- type: boolean- Error:- type: number-+ $ref: '#/components/schemas/UserMyGroupItem'UserInfoResponse:type: object@@ -3901,6 +3975,28 @@ components:example: "Aldino Kemal"+ GroupParticipantRequestItem:+ type: object+ properties:+ jid:+ type: string+ description: Requester's JID; often `@lid` until a phone mapping exists locally.+ example: "84198740205822@lid"+ phone_number:+ type: string+ description: |+ Digits from the resolved `@s.whatsapp.net` JID when LID→PN mapping is available.+ Empty when only `@lid` is known — the LID user part is not a phone number and must not be shown here.+ example: "6289685024091"+ display_name:+ type: string+ description: From saved contact, verified business name, or WhatsApp-supplied display (may be omitted when empty).+ example: "John Doe"+ requested_at:+ type: string+ format: date-time+ example: "2026-03-27T23:18:47Z"+GroupParticipantRequestListResponse:type: objectproperties:@@ -3911,26 +4007,10 @@ components:type: stringexample: "Success getting list requested participants"results:- type: object- properties:- data:- type: array- items:- type: object- properties:- jid:- type: string- example: "[email protected]"- phone_number:- type: string- example: "6289685024091"- display_name:- type: string- example: "John Doe"- requested_at:- type: string- format: date-time- example: "2024-10-11T21:27:29+07:00"+ type: array+ description: Pending join requests for the group (not wrapped in `data`).+ items:+ $ref: '#/components/schemas/GroupParticipantRequestItem'UserCheckResponse:type: objectproperties:diff --git a/src/usecase/group.go b/src/usecase/group.goindex cdf3dad5..afedee73 100644--- a/src/usecase/group.go+++ b/src/usecase/group.go@@ -190,42 +190,15 @@ func (service serviceGroup) GetGroupParticipants(ctx context.Context, request doresponse.Name = groupInfo.GroupName.Nameresponse.Participants = make([]domainGroup.GroupParticipant, 0, len(groupInfo.Participants))- // Collect JIDs for batch GetUserInfo call- jids := make([]types.JID, 0, len(groupInfo.Participants))- for _, p := range groupInfo.Participants {- jids = append(jids, p.JID)- }-- // Fetch user info for verified business names (ignore errors)- userInfoMap := make(map[types.JID]types.UserInfo)- if len(jids) > 0 {- userInfoMap, _ = client.GetUserInfo(ctx, jids)- }+ userInfo := userInfoMapForJIDs(ctx, client, jidsForGetUserInfoGroup(ctx, client, groupInfo.Participants))for _, participant := range groupInfo.Participants {- displayName := participant.DisplayName-- // Try contact store first (for known contacts)- if displayName == "" {- if contact, err := client.Store.Contacts.GetContact(ctx, participant.JID); err == nil && contact.FullName != "" {- displayName = contact.FullName- } else if info, ok := userInfoMap[participant.JID]; ok && info.VerifiedName != nil && info.VerifiedName.Details != nil {- // Fall back to verified business name- displayName = info.VerifiedName.Details.GetVerifiedName()- }- }-- // Resolve @lid JIDs to phone-based JIDs before extracting phone number- resolvedJID := utils.ResolveLIDToPhone(ctx, participant.JID, client)- phoneNumber := resolvedJID.User- // If still an LID (resolution failed), try whatsmeow's PhoneNumber field- if resolvedJID.Server == "lid" && !participant.PhoneNumber.IsEmpty() {- phoneNumber = participant.PhoneNumber.User- }+ lookupJID := groupParticipantPhoneJID(ctx, client, participant)+ displayName := resolveParticipantDisplayName(ctx, client, participant.DisplayName, lookupJID, participant.JID, userInfo)participantData := domainGroup.GroupParticipant{JID: participant.JID.String(),- PhoneNumber: phoneNumber,+ PhoneNumber: groupParticipantPhoneUser(ctx, client, participant),LID: participant.LID.String(),DisplayName: displayName,IsAdmin: participant.IsAdmin,@@ -259,36 +232,15 @@ func (service serviceGroup) GetGroupRequestParticipants(ctx context.Context, reqreturn result, err}- // Collect JIDs for batch GetUserInfo call- jids := make([]types.JID, 0, len(participants))- for _, p := range participants {- jids = append(jids, p.JID)- }-- // Fetch user info for verified business names (ignore errors)- userInfoMap := make(map[types.JID]types.UserInfo)- if len(jids) > 0 {- userInfoMap, _ = client.GetUserInfo(ctx, jids)- }+ userInfo := userInfoMapForJIDs(ctx, client, jidsForGetUserInfoWireJIDs(ctx, client, participants))for _, participant := range participants {- displayName := ""-- // Try contact store first (for known contacts)- if contact, err := client.Store.Contacts.GetContact(ctx, participant.JID); err == nil && contact.FullName != "" {- displayName = contact.FullName- } else if info, ok := userInfoMap[participant.JID]; ok && info.VerifiedName != nil && info.VerifiedName.Details != nil {- // Fall back to verified business name- displayName = info.VerifiedName.Details.GetVerifiedName()- }-- // Resolve @lid JIDs to phone-based JIDs before extracting phone number- resolvedJID := utils.ResolveLIDToPhone(ctx, participant.JID, client)- phoneNumber := resolvedJID.User+ lookupJID, phoneDigits := wireParticipantLookupAndPhone(ctx, client, participant.JID)+ displayName := resolveParticipantDisplayName(ctx, client, "", lookupJID, participant.JID, userInfo)result = append(result, domainGroup.GetGroupRequestParticipantsResponse{JID: participant.JID.String(),- PhoneNumber: phoneNumber,+ PhoneNumber: phoneDigits,DisplayName: displayName,RequestedAt: participant.RequestedAt,})@@ -540,3 +492,123 @@ func (service serviceGroup) GetGroupInviteLink(ctx context.Context, request domareturn response, nil}++// --- Group participant display / identity (LID vs phone JIDs; whatsmeow USync keys) ---++func userInfoMapForJIDs(ctx context.Context, client *whatsmeow.Client, jids []types.JID) map[types.JID]types.UserInfo {+ if len(jids) == 0 {+ return nil+ }+ m, _ := client.GetUserInfo(ctx, jids)+ return m+}++func jidsForGetUserInfoGroup(ctx context.Context, client *whatsmeow.Client, participants []types.GroupParticipant) []types.JID {+ uniq := make(map[types.JID]struct{}, len(participants))+ for _, p := range participants {+ addJIDForUSyncQuery(uniq, groupParticipantPhoneJID(ctx, client, p), p.JID)+ }+ return mapKeysToSlice(uniq)+}++func jidsForGetUserInfoWireJIDs(ctx context.Context, client *whatsmeow.Client, participants []types.GroupParticipantRequest) []types.JID {+ uniq := make(map[types.JID]struct{}, len(participants))+ for _, p := range participants {+ addJIDForUSyncQuery(uniq, utils.ResolveLIDToPhone(ctx, p.JID, client), p.JID)+ }+ return mapKeysToSlice(uniq)+}++// addJIDForUSyncQuery registers the JID to send to GetUserInfo. Responses are usually keyed by @s.whatsapp.net;+// if lookup is still @lid, we keep the wire JID so the query can still run.+func addJIDForUSyncQuery(uniq map[types.JID]struct{}, lookup types.JID, wireJID types.JID) {+ if lookup.Server != types.HiddenUserServer {+ uniq[lookup] = struct{}{}+ return+ }+ uniq[wireJID] = struct{}{}+}++func mapKeysToSlice(uniq map[types.JID]struct{}) []types.JID {+ out := make([]types.JID, 0, len(uniq))+ for j := range uniq {+ out = append(out, j)+ }+ return out+}++// groupParticipantPhoneJID is the @s.whatsapp.net (or best-effort) JID for contact / user-info map lookups.+func groupParticipantPhoneJID(ctx context.Context, client *whatsmeow.Client, p types.GroupParticipant) types.JID {+ if !p.PhoneNumber.IsEmpty() {+ return p.PhoneNumber+ }+ return utils.ResolveLIDToPhone(ctx, p.JID, client)+}++// wireParticipantLookupAndPhone returns the JID to use for contact/user-info lookups and the phone user+// string for API output, using a single LID→PN resolution per participant.+func wireParticipantLookupAndPhone(ctx context.Context, client *whatsmeow.Client, wire types.JID) (lookupJID types.JID, phoneDigits string) {+ resolved := utils.ResolveLIDToPhone(ctx, wire, client)+ phoneDigits = resolved.User+ if resolved.Server != types.HiddenUserServer {+ return resolved, phoneDigits+ }+ return wire, phoneDigits+}++// groupParticipantPhoneUser is the numeric phone for API responses (digits), using PhoneNumber when LID resolution fails.+func groupParticipantPhoneUser(ctx context.Context, client *whatsmeow.Client, p types.GroupParticipant) string {+ resolved := utils.ResolveLIDToPhone(ctx, p.JID, client)+ if resolved.Server != types.HiddenUserServer {+ return resolved.User+ }+ if !p.PhoneNumber.IsEmpty() {+ return p.PhoneNumber.User+ }+ return resolved.User+}++func resolveParticipantDisplayName(ctx context.Context, client *whatsmeow.Client, seed string, lookupJID types.JID, wireJID types.JID, userInfo map[types.JID]types.UserInfo) string {+ if seed != "" {+ return seed+ }+ if s := contactDisplayName(ctx, client, lookupJID); s != "" {+ return s+ }+ if s := verifiedNameFromUserInfo(userInfo[lookupJID]); s != "" {+ return s+ }+ if wireJID != lookupJID {+ if s := verifiedNameFromUserInfo(userInfo[wireJID]); s != "" {+ return s+ }+ }+ return ""+}++func contactDisplayName(ctx context.Context, client *whatsmeow.Client, jid types.JID) string {+ if jid.IsEmpty() {+ return ""+ }+ contact, err := client.Store.Contacts.GetContact(ctx, jid)+ if err != nil || !contact.Found {+ return ""+ }+ switch {+ case contact.FullName != "":+ return contact.FullName+ case contact.PushName != "":+ return contact.PushName+ case contact.BusinessName != "":+ return contact.BusinessName+ default:+ return ""+ }+}++func verifiedNameFromUserInfo(info types.UserInfo) string {+ if info.VerifiedName != nil && info.VerifiedName.Details != nil {+ return info.VerifiedName.Details.GetVerifiedName()+ }+ return ""+}diff --git a/src/views/components/GroupList.js b/src/views/components/GroupList.jsindex 64508148..dfff6731 100644--- a/src/views/components/GroupList.js+++ b/src/views/components/GroupList.js@@ -14,13 +14,10 @@ export default {}},computed: {- currentUserId() {+ currentUserJID() {// connected can be array of objects with device/id or may be undefinedif (!this.connected || this.connected.length === 0) return null;- const entry = this.connected[0];- const raw = entry.device || entry.id || '';- if (!raw || typeof raw !== 'string') return null;- return raw.split('@')[0].split(':')[0];+ return this.connected[0].jid;}},methods: {@@ -104,13 +101,12 @@ export default {isAdmin(group) {// Check if current user is the ownerconst owner = group.OwnerJID.split('@')[0];- if (owner === this.currentUserId) {+ if (owner === this.currentUserJID) {return true;}// Check if current user is an admin in participants- const currentUserJID = `${this.currentUserId}@s.whatsapp.net`;- const participant = group.Participants.find(p => p.PhoneNumber === currentUserJID);+ const participant = group.Participants.find(p => p.PhoneNumber === this.currentUserJID);return participant && participant.IsAdmin;},async handleSeeRequestedMember(group_id) {