From c1dbff318d3cb61942cab3d590ef06c7658eeee1 Mon Sep 17 00:00:00 2001 From: Hein Date: Wed, 4 Feb 2026 13:37:38 +0200 Subject: [PATCH] =?UTF-8?q?feat(docker):=20=F0=9F=9A=80=20Update=20server?= =?UTF-8?q?=20port=20to=208025?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Change default server port from 8080 to 8025 across all configurations. - Update Dockerfile, docker-compose.yml, and related documentation. - Ensure all CLI commands and API endpoints reflect the new port. - Adjust example configurations and health check URLs accordingly. --- ACCOUNT_MANAGEMENT.md | 73 ++++++++++----- CLI.md | 40 +++++---- DOCKER.md | 83 +++++++++++++---- Dockerfile | 2 +- MQTT_CONFIG_EXAMPLE.md | 9 +- README.md | 130 +++++++++++++++++++-------- WHATSAPP_BUSINESS.md | 18 ++-- cmd/cli/config.go | 2 +- cmd/cli/main.go | 2 +- config/.whatshooked-cli.example.json | 2 +- config/config.example.json | 16 ++-- docker-compose.yml | 8 +- pkg/config/config.go | 2 +- pkg/whatsapp/businessapi/events.go | 2 +- pkg/whatsapp/whatsmeow/client.go | 4 +- pkg/whatshooked/whatshooked.go | 2 +- 16 files changed, 270 insertions(+), 125 deletions(-) diff --git a/ACCOUNT_MANAGEMENT.md b/ACCOUNT_MANAGEMENT.md index 1283f91..fe0a1ad 100644 --- a/ACCOUNT_MANAGEMENT.md +++ b/ACCOUNT_MANAGEMENT.md @@ -18,6 +18,7 @@ Get a list of all configured WhatsApp accounts. **Endpoint:** `GET /api/accounts` **Response:** + ```json [ { @@ -45,6 +46,7 @@ Add a new WhatsApp account to the system. **Endpoint:** `POST /api/accounts/add` **Request Body (WhatsApp Web/WhatsMe ow):** + ```json { "id": "my-account", @@ -57,6 +59,7 @@ Add a new WhatsApp account to the system. ``` **Request Body (Business API):** + ```json { "id": "business-account", @@ -74,6 +77,7 @@ Add a new WhatsApp account to the system. ``` **Response:** + ```json { "status": "ok", @@ -82,6 +86,7 @@ Add a new WhatsApp account to the system. ``` **Status Codes:** + - `201 Created` - Account added successfully - `400 Bad Request` - Invalid request body - `500 Internal Server Error` - Failed to connect or save config @@ -95,6 +100,7 @@ Update an existing WhatsApp account configuration. **Endpoint:** `POST /api/accounts/update` or `PUT /api/accounts/update` **Request Body:** + ```json { "id": "business-account", @@ -112,6 +118,7 @@ Update an existing WhatsApp account configuration. ``` **Response:** + ```json { "status": "ok", @@ -120,12 +127,14 @@ Update an existing WhatsApp account configuration. ``` **Notes:** + - The `id` field is required to identify which account to update - The `type` field cannot be changed (preserved from original) - If the account is enabled, it will be disconnected and reconnected with new settings - Configuration is saved to disk after successful update **Status Codes:** + - `200 OK` - Account updated successfully - `400 Bad Request` - Invalid request or missing ID - `404 Not Found` - Account not found @@ -140,6 +149,7 @@ Disable a WhatsApp account (disconnect and prevent auto-connect on restart). **Endpoint:** `POST /api/accounts/disable` **Request Body:** + ```json { "id": "my-account" @@ -147,6 +157,7 @@ Disable a WhatsApp account (disconnect and prevent auto-connect on restart). ``` **Response:** + ```json { "status": "ok", @@ -155,12 +166,14 @@ Disable a WhatsApp account (disconnect and prevent auto-connect on restart). ``` **Behavior:** + - Disconnects the account immediately - Sets `disabled: true` in config - Account will not auto-connect on server restart - Account remains in config (can be re-enabled) **Status Codes:** + - `200 OK` - Account disabled successfully - `400 Bad Request` - Invalid request body - `404 Not Found` - Account not found @@ -175,6 +188,7 @@ Enable a previously disabled WhatsApp account. **Endpoint:** `POST /api/accounts/enable` **Request Body:** + ```json { "id": "my-account" @@ -182,6 +196,7 @@ Enable a previously disabled WhatsApp account. ``` **Response:** + ```json { "status": "ok", @@ -190,12 +205,14 @@ Enable a previously disabled WhatsApp account. ``` **Behavior:** + - Sets `disabled: false` in config - Connects the account immediately - Account will auto-connect on server restart - If connection fails, account remains disabled **Status Codes:** + - `200 OK` - Account enabled and connected successfully - `400 Bad Request` - Invalid request body - `404 Not Found` - Account not found @@ -210,6 +227,7 @@ Permanently remove a WhatsApp account from the system. **Endpoint:** `POST /api/accounts/remove` or `DELETE /api/accounts/remove` **Request Body:** + ```json { "id": "my-account" @@ -217,6 +235,7 @@ Permanently remove a WhatsApp account from the system. ``` **Response:** + ```json { "status": "ok" @@ -224,11 +243,13 @@ Permanently remove a WhatsApp account from the system. ``` **Behavior:** + - Disconnects the account - Removes from config permanently - Session data is NOT deleted (manual cleanup required) **Status Codes:** + - `200 OK` - Account removed successfully - `400 Bad Request` - Invalid request body - `404 Not Found` - Account not found @@ -270,25 +291,25 @@ Account settings are stored in `config.json`: ### Configuration Fields -| Field | Type | Required | Description | -|-------|------|----------|-------------| -| `id` | string | Yes | Unique identifier for the account | -| `type` | string | Yes | Account type: `whatsmeow` or `business-api` | -| `phone_number` | string | Yes | Phone number with country code | -| `disabled` | boolean | No | If `true`, account won't connect (default: `false`) | -| `session_path` | string | No | Session storage path (whatsmeow only) | -| `show_qr` | boolean | No | Display QR code in logs (whatsmeow only) | -| `business_api` | object | Conditional | Required for `business-api` type | +| Field | Type | Required | Description | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| `id` | string | Yes | Unique identifier for the account | +| `type` | string | Yes | Account type: `whatsmeow` or `business-api` | +| `phone_number` | string | Yes | Phone number with country code | +| `disabled` | boolean | No | If `true`, account won't connect (default: `false`) | +| `session_path` | string | No | Session storage path (whatsmeow only) | +| `show_qr` | boolean | No | Display QR code in logs (whatsmeow only) | +| `business_api` | object | Conditional | Required for `business-api` type | ### Business API Configuration -| Field | Type | Required | Description | -|-------|------|----------|-------------| -| `phone_number_id` | string | Yes | WhatsApp Business phone number ID | -| `access_token` | string | Yes | Meta Graph API access token | -| `business_account_id` | string | No | Business account ID | -| `api_version` | string | No | API version (default: `v21.0`) | -| `verify_token` | string | No | Webhook verification token | +| Field | Type | Required | Description | +| --------------------- | ------ | -------- | --------------------------------- | +| `phone_number_id` | string | Yes | WhatsApp Business phone number ID | +| `access_token` | string | Yes | Meta Graph API access token | +| `business_account_id` | string | No | Business account ID | +| `api_version` | string | No | API version (default: `v21.0`) | +| `verify_token` | string | No | Webhook verification token | --- @@ -297,11 +318,13 @@ Account settings are stored in `config.json`: ### cURL Examples **List accounts:** + ```bash -curl -u username:password http://localhost:8080/api/accounts +curl -u username:password http://localhost:8025/api/accounts ``` **Add account:** + ```bash curl -u username:password \ -X POST \ @@ -313,10 +336,11 @@ curl -u username:password \ "session_path": "./sessions/new-account", "show_qr": true }' \ - http://localhost:8080/api/accounts/add + http://localhost:8025/api/accounts/add ``` **Update account:** + ```bash curl -u username:password \ -X POST \ @@ -331,34 +355,37 @@ curl -u username:password \ "api_version": "v21.0" } }' \ - http://localhost:8080/api/accounts/update + http://localhost:8025/api/accounts/update ``` **Disable account:** + ```bash curl -u username:password \ -X POST \ -H "Content-Type: application/json" \ -d '{"id": "my-account"}' \ - http://localhost:8080/api/accounts/disable + http://localhost:8025/api/accounts/disable ``` **Enable account:** + ```bash curl -u username:password \ -X POST \ -H "Content-Type: application/json" \ -d '{"id": "my-account"}' \ - http://localhost:8080/api/accounts/enable + http://localhost:8025/api/accounts/enable ``` **Remove account:** + ```bash curl -u username:password \ -X POST \ -H "Content-Type: application/json" \ -d '{"id": "my-account"}' \ - http://localhost:8080/api/accounts/remove + http://localhost:8025/api/accounts/remove ``` --- @@ -419,11 +446,13 @@ All endpoints return proper HTTP status codes and JSON error messages: ``` Or plain text for simple errors: + ``` Account ID required in path ``` Common error scenarios: + - Account already exists (when adding) - Account not found (when updating/removing) - Connection failed (when enabling) diff --git a/CLI.md b/CLI.md index f925324..de43d13 100644 --- a/CLI.md +++ b/CLI.md @@ -52,7 +52,7 @@ Create a configuration file at `~/.whatshooked/cli.json`: ```json { - "server_url": "http://localhost:8080", + "server_url": "http://localhost:8025", "auth_key": "your-api-key-here", "username": "", "password": "" @@ -63,7 +63,7 @@ Or use API key authentication: ```json { - "server_url": "http://localhost:8080", + "server_url": "http://localhost:8025", "auth_key": "your-secure-api-key" } ``` @@ -72,7 +72,7 @@ Or use username/password authentication: ```json { - "server_url": "http://localhost:8080", + "server_url": "http://localhost:8025", "username": "admin", "password": "your-secure-password" } @@ -90,14 +90,14 @@ cp .whatshooked-cli.example.json .whatshooked-cli.json Set environment variables (useful for CI/CD): ```bash -export WHATSHOOKED_SERVER_URL="http://localhost:8080" +export WHATSHOOKED_SERVER_URL="http://localhost:8025" export WHATSHOOKED_AUTH_KEY="your-api-key-here" ``` Or with username/password: ```bash -export WHATSHOOKED_SERVER_URL="http://localhost:8080" +export WHATSHOOKED_SERVER_URL="http://localhost:8025" export WHATSHOOKED_USERNAME="admin" export WHATSHOOKED_PASSWORD="your-password" ``` @@ -107,7 +107,7 @@ export WHATSHOOKED_PASSWORD="your-password" Pass credentials via command-line flags: ```bash -./bin/whatshook-cli --server http://localhost:8080 health +./bin/whatshook-cli --server http://localhost:8025 health ``` Note: Currently, authentication credentials can only be set via config file or environment variables. Command-line flags for auth credentials may be added in future versions. @@ -118,7 +118,7 @@ If your server doesn't require authentication, simply omit the authentication fi ```json { - "server_url": "http://localhost:8080" + "server_url": "http://localhost:8025" } ``` @@ -134,12 +134,12 @@ The CLI looks for configuration files in the following locations (in order): ### Configuration Options -| Option | Type | Default | Description | -|--------|------|---------|-------------| -| `server_url` | string | `http://localhost:8080` | WhatsHooked server URL | -| `auth_key` | string | `""` | API key for authentication | -| `username` | string | `""` | Username for Basic Auth | -| `password` | string | `""` | Password for Basic Auth | +| Option | Type | Default | Description | +| ------------ | ------ | ----------------------- | -------------------------- | +| `server_url` | string | `http://localhost:8025` | WhatsHooked server URL | +| `auth_key` | string | `""` | API key for authentication | +| `username` | string | `""` | Username for Basic Auth | +| `password` | string | `""` | Password for Basic Auth | ## Commands @@ -178,6 +178,7 @@ Add a new webhook interactively: ``` You'll be prompted for: + - Hook ID - Hook Name - Webhook URL @@ -188,6 +189,7 @@ You'll be prompted for: **Available Event Types:** WhatsApp Connection Events: + - `whatsapp.connected` - WhatsApp client connected - `whatsapp.disconnected` - WhatsApp client disconnected - `whatsapp.qr.code` - QR code generated for pairing @@ -198,6 +200,7 @@ WhatsApp Connection Events: - `whatsapp.pair.event` - Generic pairing event Message Events: + - `message.received` - Message received from WhatsApp - `message.sent` - Message sent successfully - `message.failed` - Message sending failed @@ -205,6 +208,7 @@ Message Events: - `message.read` - Message read by recipient Hook Events: + - `hook.triggered` - Hook was triggered - `hook.success` - Hook executed successfully - `hook.failed` - Hook execution failed @@ -239,6 +243,7 @@ Add a new WhatsApp account interactively: ``` You'll be prompted for: + - Account ID - Phone Number (with country code, e.g., +1234567890) - Session Path (where to store session data) @@ -256,6 +261,7 @@ Send a text message interactively: ``` You'll be prompted for: + - Account ID - Recipient (phone number or JID) - Message text @@ -299,7 +305,7 @@ Supported formats: PDF, DOC, DOCX, XLS, XLSX, TXT, ZIP, and more mkdir -p ~/.whatshooked cat > ~/.whatshooked/cli.json < Linked Devices 3. Tap "Link a Device" 4. Scan the QR code from the terminal **Option 2: View in Browser** -1. Look for the line: `Or open in browser: http://localhost:8080/api/qr/{account_id}` + +1. Look for the line: `Or open in browser: http://localhost:8025/api/qr/{account_id}` 2. Open that URL in your web browser to see a larger PNG image 3. Scan the QR code from your browser ### Alternative: Use CLI Tool You can also use the CLI tool outside Docker to link accounts, then mount the session: + ```bash ./bin/whatshook-cli accounts add ``` @@ -183,33 +204,39 @@ The Docker image includes both the server and CLI binaries in the `/app/bin` dir ### Available CLI Commands List all hooks: + ```bash -docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8080 hooks list +docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8025 hooks list ``` Add a new hook: + ```bash -docker exec -it whatshooked-server /app/bin/whatshook-cli --server http://localhost:8080 hooks add +docker exec -it whatshooked-server /app/bin/whatshook-cli --server http://localhost:8025 hooks add ``` Remove a hook: + ```bash -docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8080 hooks remove +docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8025 hooks remove ``` List WhatsApp accounts: + ```bash -docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8080 accounts list +docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8025 accounts list ``` Send a message: + ```bash -docker exec -it whatshooked-server /app/bin/whatshook-cli --server http://localhost:8080 send +docker exec -it whatshooked-server /app/bin/whatshook-cli --server http://localhost:8025 send ``` Check server health: + ```bash -docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8080 health +docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8025 health ``` ### Authentication with CLI @@ -217,9 +244,10 @@ docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost: If your server has authentication enabled, you need to configure it in the CLI: **Option 1: Using command-line flags** + ```bash docker exec whatshooked-server /app/bin/whatshook-cli \ - --server http://localhost:8080 \ + --server http://localhost:8025 \ --api-key your-api-key \ hooks list ``` @@ -227,15 +255,17 @@ docker exec whatshooked-server /app/bin/whatshook-cli \ **Option 2: Create a CLI config file** 1. Access the container: + ```bash docker exec -it whatshooked-server sh ``` 2. Create the CLI config: + ```bash cat > /app/.whatshooked-cli.json < ``` List WhatsApp accounts: + ```bash ./bin/whatshook-cli accounts list # or just @@ -905,11 +948,13 @@ List WhatsApp accounts: ``` Add a WhatsApp account: + ```bash ./bin/whatshook-cli accounts add ``` Send a message: + ```bash ./bin/whatshook-cli send ``` @@ -918,10 +963,10 @@ Send a message: The CLI loads configuration with the following priority (highest to lowest): -1. **Command-line flags**: `--server http://example.com:8080` -2. **Environment variables**: `WHATSHOOKED_SERVER_URL=http://example.com:8080` +1. **Command-line flags**: `--server http://example.com:8025` +2. **Environment variables**: `WHATSHOOKED_SERVER_URL=http://example.com:8025` 3. **Config file**: `.whatshooked-cli.json` in current directory or `$HOME/.whatshooked/cli.json` -4. **Defaults**: `http://localhost:8080` +4. **Defaults**: `http://localhost:8025` ## Webhook Integration @@ -968,6 +1013,7 @@ Or using full JID format: ``` Fields: + - `send_message`: Set to `true` to send a message - `to`: Recipient phone number or JID. Can be: - Plain phone number (e.g., `"0834606792"`) - will be formatted using `default_country_code` @@ -989,6 +1035,7 @@ The server automatically formats phone numbers to WhatsApp JID format: - Appends `@s.whatsapp.net` suffix Examples with `default_country_code: "27"`: + - `0834606792` → `27834606792@s.whatsapp.net` (replaces leading 0 with 27) - `083-460-6792` → `27834606792@s.whatsapp.net` (removes dashes, replaces 0) - `27834606792` → `27834606792@s.whatsapp.net` (already has country code) @@ -1000,12 +1047,14 @@ Examples with `default_country_code: "27"`: The server exposes the following HTTP endpoints: **Public Endpoints:** + - `GET /health` - Health check (no authentication required) - `GET/POST /webhooks/whatsapp/{accountID}` - Business API webhook verification and events (no authentication, validated by Meta's verify_token) **Protected Endpoints (require authentication if enabled):** -*Hooks & Accounts:* +_Hooks & Accounts:_ + - `GET /api/hooks` - List all hooks - `POST /api/hooks/add` - Add a new hook - `POST /api/hooks/remove` - Remove a hook @@ -1016,7 +1065,8 @@ The server exposes the following HTTP endpoints: - `POST /api/accounts/disable` - Disable a WhatsApp account - `POST /api/accounts/enable` - Enable a WhatsApp account -*Send Messages:* +_Send Messages:_ + - `POST /api/send` - Send a text message - `POST /api/send/image` - Send an image - `POST /api/send/video` - Send a video @@ -1031,12 +1081,14 @@ The server exposes the following HTTP endpoints: - `POST /api/send/reaction` - React to a message with an emoji (Business API) - `POST /api/messages/read` - Mark a message as read (Business API) -*Templates (Business API):* +_Templates (Business API):_ + - `POST /api/templates` - List all message templates for an account - `POST /api/templates/upload` - Create a new message template - `POST /api/templates/delete` - Delete a template by name and language -*Flows (Business API):* +_Flows (Business API):_ + - `POST /api/flows` - List all flows for an account - `POST /api/flows/create` - Create a new flow - `POST /api/flows/get` - Get details of a specific flow @@ -1045,28 +1097,33 @@ The server exposes the following HTTP endpoints: - `POST /api/flows/deprecate` - Deprecate a flow (blocks new sessions; existing sessions continue) - `POST /api/flows/delete` - Permanently delete a flow -*Phone Numbers (Business API):* +_Phone Numbers (Business API):_ + - `POST /api/phone-numbers` - List phone numbers for an account - `POST /api/phone-numbers/request-code` - Request a verification code (SMS or VOICE) - `POST /api/phone-numbers/verify-code` - Verify a phone number with the received code -*Business Profile (Business API):* +_Business Profile (Business API):_ + - `POST /api/business-profile` - Retrieve the business profile for an account - `POST /api/business-profile/update` - Update business profile fields (about, address, description, email, websites, vertical) -*Catalog / Commerce (Business API):* +_Catalog / Commerce (Business API):_ + - `POST /api/catalogs` - List product catalogs linked to an account - `POST /api/catalogs/products` - List products in a specific catalog - `POST /api/send/catalog` - Send a catalog message (shares full product catalog) - `POST /api/send/product` - Send a single-product interactive message - `POST /api/send/product-list` - Send a multi-product list message (up to 30 products across 10 sections) -*Media:* +_Media:_ + - `GET /api/media/{accountID}/{filename}` - Serve media files - `POST /api/media/upload` - Upload a media file to Meta and return its media_id (Business API) - `POST /api/media-delete` - Delete a previously uploaded media file from Meta (Business API) -*Message Cache:* +_Message Cache:_ + - `GET /api/cache` - List cached events - `GET /api/cache/stats` - Cache statistics - `POST /api/cache/replay` - Replay all cached events @@ -1135,6 +1192,7 @@ whatshooked/ The system publishes the following event types: **WhatsApp Events:** + - `whatsapp.connected` - WhatsApp client connected - `whatsapp.disconnected` - WhatsApp client disconnected - `whatsapp.pair.success` - Device pairing successful @@ -1145,11 +1203,13 @@ The system publishes the following event types: - `whatsapp.pair.event` - Generic pairing event **Message Events:** + - `message.received` - New message received from WhatsApp - `message.sent` - Message successfully sent to WhatsApp - `message.failed` - Message send failed **Hook Events:** + - `hook.triggered` - Webhook is being called - `hook.success` - Webhook responded successfully - `hook.failed` - Webhook call failed diff --git a/WHATSAPP_BUSINESS.md b/WHATSAPP_BUSINESS.md index 0f35b7e..b09b29c 100644 --- a/WHATSAPP_BUSINESS.md +++ b/WHATSAPP_BUSINESS.md @@ -574,40 +574,40 @@ Events are automatically cached when: **List cached events:** ```bash -curl -u username:password http://localhost:8080/api/cache +curl -u username:password http://localhost:8025/api/cache ``` **Get cache statistics:** ```bash -curl -u username:password http://localhost:8080/api/cache/stats +curl -u username:password http://localhost:8025/api/cache/stats ``` **Replay all cached events:** ```bash -curl -X POST -u username:password http://localhost:8080/api/cache/replay +curl -X POST -u username:password http://localhost:8025/api/cache/replay ``` **Replay specific event:** ```bash curl -X POST -u username:password \ - "http://localhost:8080/api/cache/event/replay?id=EVENT_ID" + "http://localhost:8025/api/cache/event/replay?id=EVENT_ID" ``` **Delete cached event:** ```bash curl -X DELETE -u username:password \ - "http://localhost:8080/api/cache/event/delete?id=EVENT_ID" + "http://localhost:8025/api/cache/event/delete?id=EVENT_ID" ``` **Clear all cache:** ```bash curl -X DELETE -u username:password \ - "http://localhost:8080/api/cache/clear?confirm=true" + "http://localhost:8025/api/cache/clear?confirm=true" ``` ### Cache Workflow Example @@ -662,7 +662,7 @@ curl -X DELETE -u username:password \ 1. `message_cache.enabled` is `true` in config 2. Hooks are actually inactive or not matching events -3. Check cache stats: `curl -u user:pass http://localhost:8080/api/cache/stats` +3. Check cache stats: `curl -u user:pass http://localhost:8025/api/cache/stats` ### No Hooks Configured Error @@ -715,7 +715,7 @@ Enable debug logging to trace the issue: "type": "image", "mime_type": "image/jpeg", "filename": "wamid.xxx_a1b2c3d4.jpg", - "url": "http://localhost:8080/api/media/business/wamid.xxx_a1b2c3d4.jpg", + "url": "http://localhost:8025/api/media/business/wamid.xxx_a1b2c3d4.jpg", "base64": "..." // Only if media.mode is "base64" or "both" } } @@ -776,7 +776,7 @@ Here's a complete `config.json` with all Business API features: { "server": { "host": "0.0.0.0", - "port": 8080, + "port": 8025, "default_country_code": "1", "username": "admin", "password": "secure_password", diff --git a/cmd/cli/config.go b/cmd/cli/config.go index dc8b61e..91a1427 100644 --- a/cmd/cli/config.go +++ b/cmd/cli/config.go @@ -20,7 +20,7 @@ func LoadCLIConfig(configFile string, serverFlag string) (*CLIConfig, error) { v := viper.New() // Set defaults - v.SetDefault("server_url", "http://localhost:8080") + v.SetDefault("server_url", "http://localhost:8025") v.SetDefault("auth_key", "") v.SetDefault("username", "") v.SetDefault("password", "") diff --git a/cmd/cli/main.go b/cmd/cli/main.go index bd4e71e..22b8432 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -36,7 +36,7 @@ var rootCmd = &cobra.Command{ func init() { rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default: $HOME/.whatshooked/cli.json)") - rootCmd.PersistentFlags().StringVar(&serverURL, "server", "", "server URL (default: http://localhost:8080)") + rootCmd.PersistentFlags().StringVar(&serverURL, "server", "", "server URL (default: http://localhost:8025)") // Add all command groups rootCmd.AddCommand(healthCmd) diff --git a/config/.whatshooked-cli.example.json b/config/.whatshooked-cli.example.json index f8815b1..fa2287b 100644 --- a/config/.whatshooked-cli.example.json +++ b/config/.whatshooked-cli.example.json @@ -1,5 +1,5 @@ { - "server_url": "http://localhost:8080", + "server_url": "http://localhost:8025", "auth_key": "", "username": "", "password": "" diff --git a/config/config.example.json b/config/config.example.json index d4a3e62..0731407 100644 --- a/config/config.example.json +++ b/config/config.example.json @@ -1,7 +1,7 @@ { "server": { "host": "localhost", - "port": 8080, + "port": 8025, "default_country_code": "27", "username": "", "password": "", @@ -66,10 +66,7 @@ "Authorization": "Bearer your-token-here" }, "active": true, - "events": [ - "whatsapp.connected", - "whatsapp.disconnected" - ], + "events": ["whatsapp.connected", "whatsapp.disconnected"], "description": "Monitors WhatsApp connection status changes" }, { @@ -100,7 +97,7 @@ "media": { "data_path": "./data/media", "mode": "link", - "base_url": "http://localhost:8080" + "base_url": "http://localhost:8025" }, "database": { "type": "postgres", @@ -113,12 +110,9 @@ }, "event_logger": { "enabled": false, - "targets": [ - "file", - "sqlite" - ], + "targets": ["file", "sqlite"], "file_dir": "./data/events", "table_name": "event_logs" }, "log_level": "info" -} \ No newline at end of file +} diff --git a/docker-compose.yml b/docker-compose.yml index b7f4319..9a94c67 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: dockerfile: Dockerfile container_name: whatshooked-server ports: - - "8080:8080" + - "8025:8025" volumes: # Mount config file - ./bin/config.json:/app/config.json:ro @@ -15,14 +15,14 @@ services: # Mount sessions directory for WhatsApp authentication persistence - ./bin/sessions:/app/sessions - # Mount media directory for storing downloaded media files - - ./bin/data/media:/app/data/media + # Mount data directory for storing data files + - ./bin/data/:/app/data/ restart: unless-stopped # Health check healthcheck: - test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8080/health"] + test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8025/health"] interval: 30s timeout: 10s retries: 3 diff --git a/pkg/config/config.go b/pkg/config/config.go index f491d6a..3ede490 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -152,7 +152,7 @@ func Load(path string) (*Config, error) { cfg.Server.Host = "localhost" } if cfg.Server.Port == 0 { - cfg.Server.Port = 8080 + cfg.Server.Port = 8025 } if cfg.Media.DataPath == "" { cfg.Media.DataPath = "./data/media" diff --git a/pkg/whatsapp/businessapi/events.go b/pkg/whatsapp/businessapi/events.go index c5cbea2..67811e0 100644 --- a/pkg/whatsapp/businessapi/events.go +++ b/pkg/whatsapp/businessapi/events.go @@ -432,7 +432,7 @@ func (c *Client) saveMediaFile(messageID string, data []byte, mimeType string) ( func (c *Client) generateMediaURL(messageID, filename string) string { baseURL := c.mediaConfig.BaseURL if baseURL == "" { - baseURL = "http://localhost:8080" + baseURL = "http://localhost:8025" } return fmt.Sprintf("%s/api/media/%s/%s", baseURL, c.id, filename) } diff --git a/pkg/whatsapp/whatsmeow/client.go b/pkg/whatsapp/whatsmeow/client.go index 308e2e1..c559bfe 100644 --- a/pkg/whatsapp/whatsmeow/client.go +++ b/pkg/whatsapp/whatsmeow/client.go @@ -678,7 +678,7 @@ func (c *Client) saveMediaFile(messageID string, data []byte, mimeType string) ( func (c *Client) generateMediaURL(messageID, filename string) string { baseURL := c.mediaConfig.BaseURL if baseURL == "" { - baseURL = "http://localhost:8080" + baseURL = "http://localhost:8025" } return fmt.Sprintf("%s/api/media/%s/%s", baseURL, c.id, filename) } @@ -737,7 +737,7 @@ func getExtensionFromMimeType(mimeType string) string { func (c *Client) generateQRCodeURL() string { baseURL := c.mediaConfig.BaseURL if baseURL == "" { - baseURL = "http://localhost:8080" + baseURL = "http://localhost:8025" } return fmt.Sprintf("%s/api/qr/%s", baseURL, c.id) } diff --git a/pkg/whatshooked/whatshooked.go b/pkg/whatshooked/whatshooked.go index cdcf4df..5849ded 100644 --- a/pkg/whatshooked/whatshooked.go +++ b/pkg/whatshooked/whatshooked.go @@ -45,7 +45,7 @@ func New(opts ...Option) (*WhatsHooked, error) { cfg := &config.Config{ Server: config.ServerConfig{ Host: "localhost", - Port: 8080, + Port: 8025, }, Media: config.MediaConfig{ DataPath: "./data/media",