Skip to content

Add comprehensive WhatsApp Groups Manager - #77

Merged
asternic merged 7 commits into
asternic:mainfrom
guilhermejansen:new_feats
May 26, 2025
Merged

asternic merged 7 commits into
asternic:mainfrom
guilhermejansen:new_feats

Conversation

@guilhermejansen

Copy link
Copy Markdown
Contributor

🚀 New Feature: Complete WhatsApp Groups Manager

What's Added:

  • Complete Groups Management Interface (2233 lines of JavaScript)
  • Group Operations: Create, list, edit, delete groups
  • Participant Management: Add, remove, promote, demote participants
  • Advanced Settings: Ephemeral messages, invite links, permissions
  • Community Support: Detection and handling of Community vs Normal groups
  • Responsive UI: Search, filters, real-time updates

Files Changed:

  • static/dashboard/js/groups.js - New complete groups manager
  • static/dashboard/index.html - Added groups section
  • static/dashboard/css/app.css - Groups styling
  • static/dashboard/js/app.js - Integration
  • handlers.go - API improvements
  • static/api/spec.yml - Updated documentation
  • API.md - Documentation updates
  • wuzapi_postman.json - Updated collection

Technical Details:

  • Modular JavaScript architecture
  • Full integration with WuzAPI endpoints
  • Community vs Normal group detection
  • Admin permission handling
  • Real-time updates and caching
  • Comprehensive error handling

Testing:

✅ All group operations tested
✅ Responsive design verified
✅ Community/Normal groups working
✅ Permission levels properly handled

Ready for review and merge! 🎉

…ate go.mod and go.sum dependencies to latest versions - Fix function calls in handlers.go and wmiau.go to include context parameter - Resolve compilation errors due to whatsmeow API changes - Maintain compatibility with Go 1.23.1 and latest whatsmeow version
…Group: Create new WhatsApp groups with participants - SetGroupLocked: Configure group as locked (admin-only modifications) - SetDisappearingTimer: Set ephemeral messages (24h, 7d, 90d, off) - RemoveGroupPhoto: Remove group photos - Added 4 new handlers in handlers.go with proper validation - Added corresponding routes in routes.go - Updated API.md, OpenAPI spec.yml and Postman collection - All endpoints validated and ready for production
- Add complete groups.js (2233 lines) with full group management functionality:
  * Group listing with search, filters, and type detection (Community/Normal)
  * Group creation with participant selection and photo upload
  * Detailed group view with participant management (add/remove/promote/demote)
  * Group settings (name, description, photo, announce mode, locked mode)
  * Advanced features (ephemeral messages, invite links, leave group)
  * Contact integration and caching for participant selection

- Update dashboard interface with new groups section:
  * Add groups cards and navigation in index.html
  * Extend CSS with responsive group management styles
  * Integrate groups functionality into main app.js

- Enhance API documentation and endpoints:
  * Update handlers.go with improved group operations
  * Refresh API spec.yml and API.md documentation
  * Update Postman collection with latest group endpoints

Features include community detection, admin permission handling, real-time updates,
error handling, and full integration with existing WuzAPI group

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @guilhermejansen, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

Gemini here, providing a summary for this pull request. This PR introduces a comprehensive WhatsApp Groups Manager feature to the dashboard, along with the necessary backend API endpoints and documentation updates. The goal is to provide users with a full suite of tools to manage their WhatsApp groups directly through the WuzAPI dashboard and API.

Highlights

  • New Dashboard Groups Manager: A complete new section has been added to the dashboard UI (static/dashboard/index.html, static/dashboard/js/groups.js, static/dashboard/css/app.css) allowing users to list, create, join, view details, edit info, manage participants (add, remove, promote, demote), configure settings (announce, locked, disappearing messages), manage group photos, and reset/copy invite links for their WhatsApp groups.
  • New Group Management API Endpoints: Several new API endpoints have been added to the backend (handlers.go, routes.go) to support the new group management features, including /group/create, /group/locked, /group/ephemeral, and /group/photo/remove. Existing endpoints like /group/updateparticipants have been enhanced.
  • API Documentation Updates: The OpenAPI specification (static/api/spec.yml) and the API.md documentation have been updated to include the new group management endpoints, their parameters, and examples. The /group/photo documentation now explicitly mentions the JPEG format requirement.
  • Dependency Updates: Several Go dependencies, including whatsmeow, gorilla/websocket, go.mau.fi/libsignal, go.mau.fi/util, golang.org/x/crypto, golang.org/x/net, golang.org/x/sys, and others, have been updated in go.mod and go.sum.
  • Backend Context Handling: Added context.Background() to various whatsmeow client and sqlstore calls in handlers.go, main.go, and wmiau.go for better context propagation.
  • Improved Group Photo Handling: The /group/photo endpoint handler (handlers.go) now includes stricter validation for the input image data format, specifically checking for the data:image/ prefix and validating that the image is in JPEG format, as required by WhatsApp.
  • Frontend Contact Loading for Groups: The frontend JavaScript (static/dashboard/js/groups.js) now includes logic to load user contacts via the /user/contacts API endpoint to populate dropdowns for selecting participants when creating or managing groups.

Changelog

Click here to see the changelog
  • .env
    • Removed the .env file.
  • .gitignore
    • Added new entries for logs, node_modules, editor files (.idea, .vscode, etc.), OS files (.DS_Store), and various task/script files.
  • API.md
    • Corrected a markdown typo from `````` to ````` (L737).
    • Added detailed notes and parameters for the /group/photo endpoint, specifying JPEG format requirement and image processing details (L876-890).
    • Added documentation for the new /group/create endpoint (L939-976).
    • Added documentation for the new /group/locked endpoint (L980-1002).
    • Added documentation for the new /group/ephemeral endpoint, including valid duration values (L1007-1034).
    • Added documentation for the new /group/photo/remove endpoint (L1039-1060).
  • go.mod
    • Updated go.mau.fi/whatsmeow dependency from v0.0.0-20250501130609-4c93ee4e6efa to v0.0.0-20250521125706-91ac75c2f61a (L14).
    • Updated github.com/petermattis/goid dependency (L29).
    • Updated golang.org/x/exp dependency (L32).
    • Added golang.org/x/text dependency (L33).
    • Updated github.com/gorilla/websocket dependency from v1.5.0 to v1.5.3 (L43).
    • Updated go.mau.fi/libsignal dependency from v0.1.2 to v0.2.0 (L48).
    • Updated go.mau.fi/util dependency from v0.8.6 to v0.8.7 (L49).
    • Updated golang.org/x/crypto dependency from v0.37.0 to v0.38.0 (L50).
    • Updated golang.org/x/net dependency from v0.39.0 to v0.40.0 (L51).
    • Updated golang.org/x/sys dependency from v0.32.0 to v0.33.0 (L52).
  • go.sum
    • Added checksums for github.com/gorilla/websocket v1.5.3 (L25-26).
    • Added checksum for github.com/mattn/go-sqlite3 v1.14.28 (L47).
    • Added checksums for github.com/petermattis/goid v0.0.0-20250508124226-395b08cebbdb (L59-60).
    • Added checksums for go.mau.fi/libsignal v0.2.0 (L79-80).
    • Added checksums for go.mau.fi/util v0.8.7 (L83-84).
    • Added checksums for go.mau.fi/whatsmeow v0.0.0-20250521125706-91ac75c2f61a (L87-88).
    • Added checksums for golang.org/x/crypto v0.38.0 (L94-95).
    • Added checksums for golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 (L98-99).
    • Added checksums for golang.org/x/net v0.40.0 (L112-113).
    • Added checksum for golang.org/x/sync v0.14.0 (L119).
    • Added checksums for golang.org/x/sys v0.33.0 (L134-135).
    • Added checksums for golang.org/x/text v0.25.0 (L147-148).
    • Added checksum for golang.org/x/tools v0.33.0 (L158).
  • handlers.go
    • Added context.Background() to client.Logout() call (L513).
    • Added context.Background() to client.PairPhone() call (L583).
    • Removed empty line (L1500).
    • Removed empty line (L2225).
    • Added comment // Sets global presence status (L2359).
    • Added context.Background() to client.Store.Contacts.GetAllContacts() call (L2495).
    • Added context.Background() to client.Download() call for image (L2628).
    • Added context.Background() to client.Download() call for document (L2707).
    • Added context.Background() to client.Download() call for video (L2786).
    • Added context.Background() to client.Download() call for audio (L2865).
    • Added new handler function CreateGroup for /group/create endpoint (L3241-3310).
    • Added new handler function SetGroupLocked for /group/locked endpoint (L3314-3363).
    • Added new handler function SetDisappearingTimer for /group/ephemeral endpoint (L3367-3436).
    • Added new handler function RemoveGroupPhoto for /group/photo/remove endpoint (L3440-3489).
    • Modified SetGroupPhoto handler to check for data:image/ prefix instead of data:image/jp (L3671).
    • Added validation in SetGroupPhoto to ensure image data is present and is in JPEG format (L3684-3694).
    • Added comment // Leave group (L3834).
    • Added comment // Add user (L4081).
    • Added comment // Delete user (L4208).
    • Added comment // Delete user complete (L4255).
    • Added context.Background() to client.Logout() call (L4307).
    • Added comment // Respond to client (L4356).
    • Added comment // Validate message fields (L4387).
    • Added comment // Set proxy (L4410).
  • main.go
    • Added context.Background() to sqlstore.New calls for both postgres and sqlite (L178, L181).
  • routes.go
    • Added route for /group/create (L117).
    • Added route for /group/photo/remove (L122).
    • Added routes for /group/locked and /group/ephemeral (L127-128).
  • static/api/spec.yml
    • Updated openapi version from '3.0' to '3.0.0' (L5).
    • Added servers section (L10-12).
    • Fixed $ref paths from #definitions/... to #/definitions/... in various places (e.g., L230, L298, L378, L401, L424, L452, L490, L512, L534, L556, L645, L667, L689, L711, L733, L755, L777, L799, L821, L842, L864, L886, L908, L1080).
    • Added new path /group/create with summary, description, security, request body schema (#/definitions/CreateGroup), and response example (L917-937).
    • Added new path /group/locked with summary, description, security, request body schema (#/definitions/GroupLocked), and response example (L938-958).
    • Added new path /group/ephemeral with summary, description, security, request body schema (#/definitions/GroupEphemeral), and response example (L959-979).
    • Added new path /group/photo/remove with summary, description, security, request body schema (#/definitions/RemoveGroupPhoto), and response example (L980-1000).
    • Added description to Image property in GroupPhoto definition (L1275).
    • Changed required property name from groupJID to GroupJID in GroupLeave definition (L1770).
    • Changed required property names from groupJID, name to GroupJID, Name in GroupName definition (L1780-1781).
    • Changed required property names from groupJID, topic to GroupJID, Topic in GroupTopic definition (L1795-1796).
    • Changed required property names from groupJID, announce to GroupJID, Announce in GroupAnnounce definition (L1810-1811).
    • Changed required property name from inviteCode to Code in GroupJoin definition (L1825).
    • Changed required property name from inviteCode to Code in GroupInviteInfo definition (L1835).
    • Changed required property names from groupJID, action, participants to GroupJID, Action, Phone in UpdateGroupParticipants definition (L1845-1847).
    • Updated Action enum in UpdateGroupParticipants to include promote and demote (L1856).
    • Updated description and example for Phone property in UpdateGroupParticipants to clarify phone number format (L1862-1863).
    • Added new definition CreateGroup for creating groups (L1865-1880).
    • Added new definition GroupLocked for setting group locked status (L1882-1895).
    • Added new definition GroupEphemeral for setting disappearing timer (L1897-1911).
    • Added new definition RemoveGroupPhoto for removing group photo (L1913-1921).
  • static/dashboard/css/app.css
    • Added extensive CSS styles for the new groups manager UI, including styles for group cards, participants, badges, modals, and responsiveness (L284-1054).
  • static/dashboard/index.html
    • Added id="mainDashboard" to the main dashboard container div (L120).
    • Added a new 'Groups' section to the dashboard with cards for 'List Groups', 'Create Group', and 'Join Group' (L161-181).
    • Added a new main container div groupsMainContainer for the groups manager page, including header, search/filter section, loading indicator, groups list container, and 'no groups' message (L186-261).
    • Added several new modal structures for Group Details (modalGroupDetails), Create Group (modalCreateGroup), Join Group (modalJoinGroup), Edit Group (modalEditGroup), Group Settings (modalGroupSettings), Manage Participants (modalManageParticipants), Confirmation (confirmationModal), Edit Group Info (modalEditGroupInfo), and Group Invite Link (modalGroupInviteLink) (L440-874).
    • Included the new js/groups.js script (L879).
  • static/dashboard/js/app.js
    • Modified handleRegularLogin function to store the user's JID in local storage and window.currentUserJID upon successful login (L320-324).
    • Modified updateUser function to store the user's JID in local storage and window.currentUserJID when updating user status (L346-350).
  • static/dashboard/js/groups.js
    • Added a new JavaScript file (groups.js) containing all the frontend logic for the comprehensive WhatsApp Groups Manager. This includes functions for initializing events and modals, showing/hiding the manager, loading and displaying groups, filtering groups, showing group details, handling modal interactions (create, join, edit, settings, participants, invite link), loading contacts, performing group actions via API calls (create, join, update name/topic/announce/locked/ephemeral/participants/photo/invite link, leave), and utility functions for JID parsing, admin checks, text truncation, base64 conversion for photos, and error/success messages (L1-2233).
  • wmiau.go
    • Added context.Background() to container.GetDevice() calls (L135, L169).
    • Added context.Background() to mycli.WAClient.Download() calls for image, audio, document, and video messages (L410, L463, L522, L586).
  • wuzapi_postman.json
    • Added new Postman requests for 'Create Group', 'Set Group Locked', 'Set Disappearing Timer', and 'Remove Group Photo' under the 'Group' folder (L844-927).
    • Updated the 'Set Group Photo' request body example (L1044).
    • Updated the 'Update Group Participants' request body key from Participants to Phone and updated the description to include 'promote' and 'demote' actions (L1149, L1156).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


Groups gather 'round,
API calls abound,
Manage with ease,
Across the seas,
New features now are found.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a comprehensive WhatsApp Groups Manager, a significant and well-implemented feature. The changes span the backend API, frontend UI, and documentation, demonstrating a well-rounded feature implementation.

Summary of Findings

  • API Specification Typo: A typo was found in static/api/spec.yml where promete should likely be promote in an enum definition.
  • Postman Collection Inconsistency: The Postman collection (wuzapi_postman.json) has a description and example request body for UpdateGroupParticipants that are slightly out of sync with the updated API definition (action types and field name Phone vs Participants).
  • JPEG Validation in Backend: The backend JPEG validation in handlers.go for group photos is a good robustness measure.
  • Context Propagation: Multiple whatsmeow library calls across handlers.go and wmiau.go have been updated to include context.Background(). This is a necessary change due to library updates and ensures correct context propagation. (Not an issue, positive observation)
  • Frontend Group Management Logic: The new static/dashboard/js/groups.js file provides extensive client-side logic for the new group features, including API interactions, DOM manipulation, and image processing. The implementation appears comprehensive. (Not an issue, positive observation)

Merge Readiness

This pull request is in good shape and introduces significant new functionality. The core logic for group management on both backend and frontend seems solid.

I recommend addressing the medium-severity issues identified in static/api/spec.yml and wuzapi_postman.json to ensure API consistency and ease of use for developers and testers. The JPEG validation in handlers.go is good as is.

Once these minor refinements are made, the PR should be ready for merging after further review and approval by other team members. I am not authorized to approve pull requests.

Comment thread static/api/spec.yml
description: Action to perform ("add" to add participants, "remove" to remove participants)
enum: [add, remove]
description: Action to perform ("add" to add participants, "remove" to remove participants, "promote" to promote participants, "demote" to demote participants.)
enum: [add, remove, promete, demote]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There seems to be a typo in the enum value for the Action field. Should promete be promote to align with the description "promote to promote participants"?

Ensuring enum values are correct is important for API clients.

        enum: [add, remove, promote, demote]

Comment thread wuzapi_postman.json
Comment on lines +1149 to +1156
"raw": "{\n \"GroupJID\": \"[email protected]\",\n \"Action\": \"add\",\n \"Phone\": [\"[email protected]\", \"[email protected]\"]\n}"
},
"url": {
"raw": "{{baseUrl}}/group/updateparticipants",
"host": ["{{baseUrl}}"],
"path": ["group", "updateparticipants"]
},
"description": "Add or remove participants from a group. Action can be 'add' or 'remove'."
"description": "Add, remove, promote or demote participants from a group. Action can be 'add', 'remove', 'promote','demote'."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The description for the UpdateGroupParticipants endpoint (line 1156) mentions actions 'add' or 'remove', but the API now supports 'promote' and 'demote' as well, as indicated in spec.yml.

Additionally, the example request body (line 1149) uses "Participants" as the key for the list of phone numbers, but the spec.yml (and likely the backend implementation) now uses "Phone" for this field (as seen in UpdateGroupParticipants definition in spec.yml lines 1847 and 1858).

Could we update the description to include all supported actions and change "Participants" to "Phone" in the example body for consistency with the API definition?

              "raw": "{\n  \"GroupJID\": \"[email protected]\",\n  \"Action\": \"add\",\n  \"Phone\": [\"[email protected]\", \"[email protected]\"]\n}",
            "url": {
              "raw": "{{baseUrl}}/group/updateparticipants",
              "host": ["{{baseUrl}}"],
              "path": ["group", "updateparticipants"]
            },
            "description": "Add, remove, promote or demote participants from a group. Action can be 'add', 'remove', 'promote', 'demote'."

…compatible) and webhook JSON format option (no breaking changes)

- Introduce S3Manager for generic S3 operations (upload, public URL, retention)
- Add per-user S3 configuration fields (enabled, endpoint, region, bucket, keys, path style, public URL, delivery mode, retention days) via DB migration
- Implement API endpoints for S3 config management (POST/GET/DELETE/test)
- Update event handlers to upload incoming media to S3 and include public preview URL in webhook payload, according to user config (base64, S3 URL, or both)
- Update outgoing media (SendDocument, SendImage, SendAudio, SendVideo, etc.) to also upload to S3 if enabled
- Ensure all S3 logic is opt-in and does not affect users without S3 enabled (full backward compatibility)
- Media is stored in S3 by user, type, contact, and date for structured organization
- Retention period for media in S3 is user-configurable at integration setup
- Add support for WEBHOOK_FORMAT=json, allowing webhook payloads to be sent as JSON
- Update documentation (API.md, README.md, spec.yml, Postman collection) to reflect new S3 and webhook format features
- Add and update Go module dependencies as needed

This implementation is production-ready, scalable for multiple WhatsApp instances, and avoids unnecessary complexity. All changes are fully backward compatible: no breaking changes, and existing users and integrations continue to work as before.
…on in docker-compose

- Remove wuzapi_dbdata and wuzapi_files volumes from docker-compose
- Add WEBHOOK_FORMAT=json environment variable to service configuration
…webhooks and complete event support

Major Features Added:
- S3-compatible storage integration for media files with configurable retention
- Proxy support for WhatsApp connections with SOCKS5 protocol
- Global webhook system with support for ALL whatsmeow library events
- Complete event type coverage including calls, newsletters, presence, and identity changes
- Enhanced webhook system with comprehensive event type validation and "All" event subscription
- Improved dashboard UI with configuration management panels
- Comprehensive API documentation updates

Core Improvements:
- Added constants.go with complete event type definitions and validation for 50+ WhatsApp events
- Implemented global webhook support with "All" event type for comprehensive monitoring
- Added support for advanced events: calls, newsletters, presence, identity changes, app state sync
- Implemented S3Manager with upload, download, and lifecycle management
- Added proxy configuration endpoints and connection handling
- Enhanced user creation with optional S3 and proxy configurations
- Improved error handling and validation across all endpoints
- Complete whatsmeow library event coverage including Facebook bridge and CAT refresh errors

Dashboard Enhancements:
- New configuration panels for S3, proxy, and webhook settings
- Improved user interface with better navigation and visual feedback
- Enhanced admin panel with instance management capabilities
- Better responsive design and user experience improvements

API Documentation:
- Updated OpenAPI specification with new endpoints
- Enhanced README with configuration examples
- Added comprehensive endpoint documentation
- Updated Postman collection with new API calls

Technical Improvements:
- Better code organization with separated constants
- Enhanced error handling and logging
- Improved database migrations for new features
- Better security and validation throughout the application

Breaking Changes: None - all changes are backward compatible
@asternic
asternic merged commit 4cb8b6a into asternic:main May 26, 2025
maxHSG pushed a commit to maxHSG/wuzapi that referenced this pull request Jan 28, 2026
Add comprehensive WhatsApp Groups Manager

This branch had an error being deployed

1 failed deployment
DOCKER — fc2afd50 Deployed May 26, 2025 by asternic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants