aldinokemal / go-whatsapp-web-multidevice

API for Whatsapp Web Multi Device Version, Support UI & Webhook
MIT License
492 stars 216 forks source link

feat: add group participants #132

Closed aldinokemal closed 5 months ago

aldinokemal commented 5 months ago

Context

Test Results

Screenshot 2024-04-10 at 14 45 56
coderabbitai[bot] commented 5 months ago

Walkthrough

This update introduces significant enhancements to group management capabilities within the API, including new endpoints for creating groups and managing participants. The changes streamline group operations such as adding, removing, promoting, and demoting participants. Additionally, the documentation and codebase reflect these advancements, ensuring developers can effectively utilize the new features. This version also includes minor adjustments for improved functionality and user experience.

Changes

File(s) Change Summary
docs/openapi.yaml Updated to version 3.11.0; introduced CreateGroupResponse and GenericResponse; added new endpoints for group operations.
readme.md Updated API documentation to include details on generating an HTTP client and new group management endpoints.
src/config/settings.go Updated AppVersion to "v4.13.0".
src/domains/group/group.go, .../services/group.go, .../validations/group_validation.go Enhanced group management with new methods for adding participants and validations.
src/internal/rest/group.go, src/views/.../GroupAddParticipants.js, src/views/index.html Added functionality for adding participants to a group through the REST API and UI components.
src/pkg/whatsapp/whatsapp.go Optimized code by removing redundant "ephemeral" addition for "view once" events.

"In the land of code and bytes, where groups of chats take flight,
A rabbit hopped, with updates in tow, through the digital night.
🥕 New paths to tread, participants to add, a version fresh and bright,
With every line and function spread, it leaps towards the light.
So here's to groups, both big and small, may they chatter with delight!"
~ @coderabbitai 🐰✨


Recent Review Details **Configuration used: CodeRabbit UI**
Commits Files that changed from the base of the PR and between b62000173358c2ce59ed98a6e299a649655fa9dd and a8016e7a17ca73d3493a40d79721139ee9e813e1.
Files selected for processing (10) * docs/openapi.yaml (4 hunks) * readme.md (1 hunks) * src/config/settings.go (1 hunks) * src/domains/group/group.go (2 hunks) * src/internal/rest/group.go (4 hunks) * src/pkg/whatsapp/whatsapp.go (1 hunks) * src/services/group.go (2 hunks) * src/validations/group_validation.go (1 hunks) * src/views/components/GroupAddParticipants.js (1 hunks) * src/views/index.html (3 hunks)
Files skipped from review due to trivial changes (2) * src/config/settings.go * src/pkg/whatsapp/whatsapp.go
Additional comments not posted (19)
src/domains/group/group.go (3)
`9-9`: Consider documenting the `AddParticipant` method. Adding comments to public methods and interfaces improves code readability and helps other developers understand the purpose and usage of the method. --- `25-28`: Ensure participant IDs are validated. Given the security implications of adding participants to groups, it's crucial to validate participant IDs to prevent unauthorized additions. Consider implementing server-side validation if not already done. --- `30-34`: Review the `ParticipantStatus` structure for extensibility. The `ParticipantStatus` structure currently includes `Participant`, `Status`, and `Message`. Consider if additional fields (e.g., timestamp, action performed by) might be needed in the future for audit or logging purposes.
src/validations/group_validation.go (1)
`48-60`: Ensure comprehensive validation for participant IDs. While the current validation checks for the presence of `GroupID` and `Participants`, consider extending the validation to ensure the format of participant IDs matches expected patterns (e.g., phone numbers with country codes for WhatsApp).
src/internal/rest/group.go (1)
`77-93`: Validate participant data before processing. Before proceeding with adding participants, ensure that the participant data received in the request is validated. This can help prevent issues related to invalid data and improve the robustness of the API.
src/services/group.go (2)
`76-114`: Optimize error handling in `AddParticipant`. Consider consolidating error handling in the `AddParticipant` function to reduce redundancy and improve readability. This could involve creating a helper function for common error responses or using a more structured approach to error handling. --- `116-130`: Verify participant existence before adding. Ensure that the `IsOnWhatsapp` check in `participantToJID` accurately verifies the existence of participants on WhatsApp. This is crucial for preventing attempts to add non-existent users to groups.
src/views/components/GroupAddParticipants.js (3)
`1-119`: Ensure input validation on the client side. For the `GroupAddParticipants` component, consider implementing client-side validation for participant phone numbers to ensure they meet WhatsApp's format requirements before submission. This can improve user experience by catching errors early. --- `39-55`: Handle API response errors gracefully. In the `submitApi` method, ensure that errors from the API response are handled gracefully, providing clear feedback to the user. This could involve parsing error messages from the API and displaying them in a user-friendly manner. --- `63-118`: Review accessibility of the modal interface. For the modal interface used to add participants, review and ensure accessibility standards are met. This includes proper labeling of form elements, keyboard navigability, and screen reader support.
src/views/index.html (1)
`84-84`: Confirm integration of `GroupAddParticipants`. Ensure that the `GroupAddParticipants` component is correctly integrated and functions as expected within the application's UI. This includes verifying that the component is properly loaded and interacts correctly with other components.
readme.md (2)
`126-129`: Ensure documentation accuracy for participant management endpoints. Verify that the documentation for the new endpoints related to managing participants in a group (`/group/participants`, `/group/participants/promote`, etc.) accurately reflects the implemented API behavior and parameters. --- `100-100`: Encourage the use of the OpenAPI generator. Consider providing a brief example or a link to a guide on how to use the OpenAPI generator with the provided `openapi.yaml` file. This can help developers quickly get started with generating client libraries for the API.
docs/openapi.yaml (6)
`4-4`: Version update to 3.11.0 is appropriate for introducing new features. --- `776-788`: The `/group` endpoint for creating groups and adding participants is correctly defined. --- `790-822`: The `/group/participants` endpoint for adding more participants to a group is correctly defined. --- `906-920`: The `CreateGroupResponse` schema is well-defined and aligns with the expected response for group creation. --- `921-942`: The `AddParticipantToGroupResponse` schema is appropriately defined for the response when adding participants to a group. --- `856-856`: The usage of `GenericResponse` schema for standard responses is appropriate and flexible.
--- Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (invoked as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger a review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.