-
-
Notifications
You must be signed in to change notification settings - Fork 380
Smart JID validation, Session UI controls & Local Dev Infrastructure #249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Refactor RabbitMQ configuration to use environment variables. - Expose PostgreSQL ports to the host for local access. - Update .env.sample with new configuration options.
- Add logic to switch between local relative path and binary path. - Add GO_ENV variable to .env to enable local development mode with Air.
…sOnWhatsApp" -m "- Replace basic parsing with online WhatsApp API check.\n- Automatically normalize regional formats (e.g., fix Mexico +52 to +521).\n- Validate existence of the number before sending.
- Introduce 'GetFormattedPhone' handler to verify numbers via WhatsApp API.\n- Register POST /misc/phone route.\n- Allow JID normalization (e.g., Mexico +521) without sending messages.
- Add MinIO container exposing ports 9000 (API) and 9001 (Console).\n- Configure default credentials and persistence volume.\n- Enable S3-compatible media storage for WuzAPI.
… logout) - Add Session section cards to dashboard.\n- Implement Semantic UI modals for session actions.\n- Add JS logic to consume /session/* endpoints with auth token.\n- Fix modal buttons with 'approve' class for event triggering.
- Add 'proxy-http' service (TinyProxy) on port 8888 for HTTP testing.\n- Add 'proxy-socks' service (Go-Socks5) on port 1080 for SOCKS5 auth testing.\n- Facilitate local development and testing of WuzAPI proxy configurations.
Summary of ChangesHello @lomeliDev, 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! This pull request significantly enhances the application's core messaging capabilities by introducing intelligent phone number validation and formatting, improving the reliability of message delivery. It also expands the administrative dashboard with new session control features, offering a more intuitive user experience. Furthermore, the local development environment has been substantially upgraded with additional Docker services, streamlining the testing of various system components like S3 storage and proxy configurations. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe 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 by creating a comment using either
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 Limitations & Feedback Gemini Code Assist 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. 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. Footnotes
|
There was a problem hiding this comment.
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 valuable features, including smart JID validation, new session management controls in the UI, and a significantly improved local development infrastructure with Docker. The backend changes, especially the new validateMessageFields function, are a great step towards more robust message handling. The Docker setup with MinIO and proxies will certainly streamline testing.
I've identified a critical logic bug in the new /misc/phone endpoint's error handling that needs to be addressed. Additionally, there are a few medium-severity issues related to Docker image pinning for reproducibility and misleading error messages. While the PR aimed to standardize logging, I noticed some older logging patterns remain; it would be great to update these for consistency.
…de injection - Implemented 'SendInteractiveButtons' to support Quick Reply, URL, Copy, and Call buttons. - Utilizes 'whatsmeow.SendRequestExtra' to inject the <biz> node (containing native_flow/mixed), replicating Baileys relayMessage behavior. - Fixes compatibility issues with WhatsApp Web rendering. - Updated 'spec.yml' for '/chat/send/buttons' with correct requestBody structure and examples. - Replaced legacy button handling logic.
- Implemented SendList handler using manual 'product_list' biz node injection. - Updated go.mod to use local whatsmeow fork to bypass auto 'single_select' injection (Fixes Error 479). - Added support for header images in List Messages. - Replicates Baileys' behavior for full compatibility.
- Added SendCarousel handler for multi-card interactive messages. - Implemented automatic thumbnail generation using 'nfnt/resize' to fix video playback on iOS. - Added support for both Image and Video headers in carousel cards. - Registered '/chat/send/carousel' endpoint in routes. - Updated OpenAPI spec with FFmpeg requirements and full schema definitions.
- Updated SendInteractiveButtons to support 'video' headers with MP4 uploads. - Implemented automatic JpegThumbnail generation using 'nfnt/resize' to fix rendering issues on iOS. - Updated spec.yml for '/chat/send/buttons' with new video schema and FFmpeg documentation. - Refactored media upload logic to share thumbnail creation helper.
- Implemented fallback logic in main.go to read WA_DEBUG and WA_COLOR_LOGS from environment variables if CLI flags are not provided. - Added new WA_DEBUG_HTTP flag to separate HTTP request debugging from core WhatsApp debugging.
- Implemented handling for LabelEdit, LabelAssociationChat, and LabelAssociationMessage events. - Standardized webhook payloads with clear action types.
- Removed unreachable duplicate error check in newSafeHTTPClient. - Simplified nil map check in executeHTTPHandler. - Optimized error formatting using fmt.Errorf. - Removed redundant return statement in SendImage.
- Removed remaining redundant return statements. - Translated and refined code comments to English. - Finalized static analysis fixes.
- Implemented HandleLabelEdit for creating, updating, and deleting labels using waSyncAction. - Implemented HandleLabelAssign for assigning/removing labels from chats and messages. - Refactored imports to replace deprecated binary/proto with appstate and proto/waSyncAction. - Added Swagger documentation in spec.yml for new endpoints. - Verified AppStateSync functionality with WhatsApp Web.
- feat(media): Added support for sending Media by URL (Image, Video, Audio, Document, Sticker) with auto-download. - feat(video): Implemented Circular Video Notes (PTV) and GIF playback support. - feat(audio): Added automatic FFmpeg conversion to OGG Opus for native Voice Notes (PTT). - feat(audio): Implemented visual waveform generation for audio messages. - feat(presence): Added 'duration' parameter to simulate human behavior (auto-pause typing/recording). - refactor: Created 'fillContextInfo' helper to centralize reply/mention logic and fix copylocks. - fix(handlers): Resolved panic issues in HTTP response handling. - docs(openapi): Updated spec.yml with new media parameters and fixed duplication errors.
- feat(location): Added 'name' and 'address' support to send rich business location cards. - feat(poll): Implemented 'max_selectable' parameter to allow Single Choice polls (strict voting). - fix(handlers): Applied anti-panic JSON marshaling response pattern to Location and Poll handlers. - refactor(handlers): Fixed copylocks warning by passing ContextInfo as a pointer in Location and Polls. - docs(openapi): Updated spec.yml definitions for MessageLocation and MessagePoll.
- feat(chat): Implemented Pin/Unpin chat functionality using AppState sync. - feat(message): Added Star/Unstar message support (Favorites) with correct senderJID calculation. - refactor(chat): Updated ArchiveChat handler to use anti-panic JSON response pattern. - feat(routes): Registered /chat/pin and /chat/star endpoints. - docs(openapi): Added Swagger definitions for CRM features (ChatPin, MessageStar, ChatArchive).
- feat(product): Implemented 'SendProduct' for native single-product cards with price and currency. - feat(carousel): Added 'SendCarousel' to support multi-card horizontal scrolling messages. - fix(proto): Corrected Protobuf field mappings (ProductID, URL) and type mismatches (uint32). - feat(routes): Registered /chat/send/product and /chat/send/carousel endpoints. - docs(openapi): Added MessageProduct and MessageCarousel definitions to spec.yml.
- Removed SendGhostCall implementation due to stability issues. - Kept local library modifications (hacks). - Enabled events.CallOffer handler to log incoming calls and trigger webhooks.
This PR introduces significant improvements to the core message handling, extends the Dashboard UI, and enhances the local development environment with Docker.
🚀 Key Changes
Smart JID Validation: Implemented a robust validation mechanism using IsOnWhatsApp.
Fix: Automatically corrects regional JID formats before sending messages. This specifically resolves issues with Mexican numbers (converting +52 to +521 when required by WhatsApp) and prevents sending messages to non-existent numbers.
New Endpoint (POST /misc/phone): Added a utility endpoint to validate and format phone numbers (returns the correct JID and existence status) without sending a message.
Code Cleanup: Fixed variable shadowing in handlers.go (MarkRead) and standardized logging to use zerolog for better consistency.
Session Management: Added a new "Session" widget section to the Dashboard.
Features: UI cards for Connect, Disconnect, and Logout.
UX: Implemented Semantic UI confirmation modals and toast notifications for success/error states.
Logic: Javascript functions now properly handle auth tokens and interact with /session/* endpoints.
Local S3 (MinIO): Added a minio service to docker-compose.yml (ports 9000/9001) to facilitate local testing of S3 media storage.
Proxy Testing: Added proxy-http (TinyProxy) and proxy-socks (Go-Socks5) services to the compose file to allow easy testing of WuzAPI's proxy configurations in a local environment.
Env Variables: Updated environment configuration to support these new services (RabbitMQ, MinIO, Adminer).
🧪 How to Test
Phone Validation:
POST to /misc/phone with a payload like {"phone": "521234567890"}.
Response should return the corrected JID (e.g., adding the '1' for Mexico if needed) and exists: true.
Dashboard:
Go to /dashboard.
Use the new Session cards to Disconnect and Reconnect the session.
Docker Infra:
Run docker-compose up -d minio proxy-http.
Verify MinIO console at http://localhost:9001.
📸 Screenshots
Checklist
[x] Code compiles correctly
[x] New endpoint /misc/phone tested
[x] Dashboard UI functional
[x] Docker containers build and run