Feature: Get Group Info from Invite Link#8
Open
moothz wants to merge 2 commits intoEvolutionAPI:mainfrom
Open
Conversation
Reviewer's GuideAdds a new /group/invite-info endpoint to fetch WhatsApp group metadata from an invite link (or code) without joining, wires it through the HTTP handler and service layer, and documents it in the API guides. Sequence diagram for the new /group/invite-info endpointsequenceDiagram
actor ApiClient
participant GinRouter
participant GroupHandler
participant GroupService
participant LoggerWrapper
participant WhatsAppClient
ApiClient->>GinRouter: POST /group/invite-info { code }
GinRouter->>GroupHandler: GetGroupInfoFromInviteLink(ctx)
GroupHandler->>GroupHandler: ctx.MustGet(instance)
GroupHandler-->>ApiClient: 500 error (instance not found)
note over GroupHandler,ApiClient: Alternative path if instance is missing
GroupHandler->>GroupHandler: ctx.ShouldBindBodyWithJSON(data)
GroupHandler-->>ApiClient: 400 error (invalid body)
note over GroupHandler,ApiClient: Alternative path if body binding fails
GroupHandler->>GroupHandler: validate data.Code not empty
GroupHandler-->>ApiClient: 400 error (code is required)
note over GroupHandler,ApiClient: Alternative path if code is empty
GroupHandler->>GroupService: GetGroupInfoFromInviteLink(data, instance)
GroupService->>GroupService: ensureClientConnected(instance.Id)
GroupService-->>ApiClient: 500 error (client connection error)
note over GroupService,ApiClient: Alternative path if client not connected
GroupService->>GroupService: normalize code (strip chat.whatsapp.com/)
GroupService->>WhatsAppClient: GetGroupInfoFromLink(code)
WhatsAppClient-->>GroupService: GroupInfo or error
GroupService->>LoggerWrapper: LogError on failure
GroupService-->>GroupHandler: GroupInfo or error
GroupHandler-->>ApiClient: 500 error (internal)
note over GroupHandler,ApiClient: Alternative path if service returns error
GroupHandler-->>ApiClient: 200 { message: success, data: GroupInfo }
Updated class diagram for group handler and service with invite-info supportclassDiagram
class GroupHandler {
<<interface>>
ListGroups(ctx)
GetGroupInfo(ctx)
GetGroupInviteLink(ctx)
GetGroupInfoFromInviteLink(ctx)
SetGroupPhoto(ctx)
SetGroupName(ctx)
SetGroupDescription(ctx)
}
class groupHandler {
+groupService GroupService
+GetGroupInfoFromInviteLink(ctx)
}
class GroupService {
<<interface>>
ListGroups(instance)
GetGroupInfo(data, instance)
GetGroupInviteLink(data, instance)
GetGroupInfoFromInviteLink(data, instance)
SetGroupPhoto(data, instance)
SetGroupName(data, instance)
SetGroupDescription(data, instance)
}
class groupService {
+loggerWrapper LoggerWrapper
+ensureClientConnected(instanceId)
+GetGroupInviteLink(data, instance) string
+GetGroupInfoFromInviteLink(data, instance) GroupInfo
}
class GetGroupInfoFromInviteLinkStruct {
+Code string
}
class Instance {
+Id string
}
class LoggerWrapper {
+GetLogger(instanceId) Logger
}
class Logger {
+LogError(format, values)
}
class WhatsAppClient {
+GetGroupInfoFromLink(ctx, code) GroupInfo
}
class GroupInfo {
+JID string
+OwnerJID string
+GroupName GroupNameInfo
+GroupCreated time
}
class GroupNameInfo {
+Name string
+NameSetAt time
+NameSetBy string
}
GroupHandler <|.. groupHandler
GroupService <|.. groupService
groupHandler --> GroupService
groupService --> LoggerWrapper
LoggerWrapper --> Logger
groupService --> Instance
groupService --> WhatsAppClient
groupService --> GetGroupInfoFromInviteLinkStruct
groupService --> GroupInfo
GroupInfo --> GroupNameInfo
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 security issue, and left some high level feedback:
Security issues:
- Discovered a potential authorization token provided in a curl command header, which could compromise the curl accessed resource. (link)
General comments:
- In
GetGroupInfoFromInviteLink, you're declaringvar data *group_service.GetGroupInfoFromInviteLinkStructand then callingShouldBindBodyWithJSON(&data), which results in a pointer to a nil pointer; switch this to a non-pointer struct (e.g.,var data group_service.GetGroupInfoFromInviteLinkStructand bind with&data) to avoid unexpected nil dereferences and to match how other handlers bind request bodies. - The logic that extracts the invite code (
strings.Contains+strings.Splitonchat.whatsapp.com/) is brittle for variant URLs; consider usingnet/urlparsing to robustly handle different URL formats, query parameters, trailing slashes, and potential whitespace around the code. - In
api-groups.md, right after the/group/infocURL example there is a stray}'line left in the document, which should be removed to keep the markdown and JSON examples well-formed.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `GetGroupInfoFromInviteLink`, you're declaring `var data *group_service.GetGroupInfoFromInviteLinkStruct` and then calling `ShouldBindBodyWithJSON(&data)`, which results in a pointer to a nil pointer; switch this to a non-pointer struct (e.g., `var data group_service.GetGroupInfoFromInviteLinkStruct` and bind with `&data`) to avoid unexpected nil dereferences and to match how other handlers bind request bodies.
- The logic that extracts the invite code (`strings.Contains` + `strings.Split` on `chat.whatsapp.com/`) is brittle for variant URLs; consider using `net/url` parsing to robustly handle different URL formats, query parameters, trailing slashes, and potential whitespace around the code.
- In `api-groups.md`, right after the `/group/info` cURL example there is a stray `}'` line left in the document, which should be removed to keep the markdown and JSON examples well-formed.
## Individual Comments
### Comment 1
<location path="docs/wiki/guias-api/api-groups.md" line_range="187-189" />
<code_context>
SUA-CHAVE-API
</code_context>
<issue_to_address>
**security (curl-auth-header):** Discovered a potential authorization token provided in a curl command header, which could compromise the curl accessed resource.
*Source: gitleaks*
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Comment on lines
+187
to
+189
| curl -X POST http://localhost:4000/group/invite-info \ | ||
| -H "Content-Type: application/json" \ | ||
| -H "apikey: SUA-CHAVE-API" \ |
There was a problem hiding this comment.
security (curl-auth-header): Discovered a potential authorization token provided in a curl command header, which could compromise the curl accessed resource.
Source: gitleaks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new endpoint to retrieve detailed group information directly from a WhatsApp invite link without requiring the account to join the group first. Returns name, description, owner JID, and creation timestamp.
This is the same functionality as clicking an invite link to preview the group (view name, photo, members, if contacts are in the group, etc.)
These changes have been in effect in my codebase since december (early acess) - throughly tested.
Type of Change
Testing
Checklist
Summary by Sourcery
Add an endpoint to retrieve WhatsApp group details from an invite link and document its usage alongside existing group APIs.
New Features:
Enhancements:
Documentation: