Refactor port again
This commit is contained in:
@@ -320,7 +320,7 @@ Account settings are stored in `config.json`:
|
|||||||
**List accounts:**
|
**List accounts:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -u username:password http://localhost:8025/api/accounts
|
curl -u username:password http://localhost:8825/api/accounts
|
||||||
```
|
```
|
||||||
|
|
||||||
**Add account:**
|
**Add account:**
|
||||||
@@ -336,7 +336,7 @@ curl -u username:password \
|
|||||||
"session_path": "./sessions/new-account",
|
"session_path": "./sessions/new-account",
|
||||||
"show_qr": true
|
"show_qr": true
|
||||||
}' \
|
}' \
|
||||||
http://localhost:8025/api/accounts/add
|
http://localhost:8825/api/accounts/add
|
||||||
```
|
```
|
||||||
|
|
||||||
**Update account:**
|
**Update account:**
|
||||||
@@ -355,7 +355,7 @@ curl -u username:password \
|
|||||||
"api_version": "v21.0"
|
"api_version": "v21.0"
|
||||||
}
|
}
|
||||||
}' \
|
}' \
|
||||||
http://localhost:8025/api/accounts/update
|
http://localhost:8825/api/accounts/update
|
||||||
```
|
```
|
||||||
|
|
||||||
**Disable account:**
|
**Disable account:**
|
||||||
@@ -365,7 +365,7 @@ curl -u username:password \
|
|||||||
-X POST \
|
-X POST \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{"id": "my-account"}' \
|
-d '{"id": "my-account"}' \
|
||||||
http://localhost:8025/api/accounts/disable
|
http://localhost:8825/api/accounts/disable
|
||||||
```
|
```
|
||||||
|
|
||||||
**Enable account:**
|
**Enable account:**
|
||||||
@@ -375,7 +375,7 @@ curl -u username:password \
|
|||||||
-X POST \
|
-X POST \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{"id": "my-account"}' \
|
-d '{"id": "my-account"}' \
|
||||||
http://localhost:8025/api/accounts/enable
|
http://localhost:8825/api/accounts/enable
|
||||||
```
|
```
|
||||||
|
|
||||||
**Remove account:**
|
**Remove account:**
|
||||||
@@ -385,7 +385,7 @@ curl -u username:password \
|
|||||||
-X POST \
|
-X POST \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{"id": "my-account"}' \
|
-d '{"id": "my-account"}' \
|
||||||
http://localhost:8025/api/accounts/remove
|
http://localhost:8825/api/accounts/remove
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
24
CLI.md
24
CLI.md
@@ -52,7 +52,7 @@ Create a configuration file at `~/.whatshooked/cli.json`:
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"server_url": "http://localhost:8025",
|
"server_url": "http://localhost:8825",
|
||||||
"auth_key": "your-api-key-here",
|
"auth_key": "your-api-key-here",
|
||||||
"username": "",
|
"username": "",
|
||||||
"password": ""
|
"password": ""
|
||||||
@@ -63,7 +63,7 @@ Or use API key authentication:
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"server_url": "http://localhost:8025",
|
"server_url": "http://localhost:8825",
|
||||||
"auth_key": "your-secure-api-key"
|
"auth_key": "your-secure-api-key"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -72,7 +72,7 @@ Or use username/password authentication:
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"server_url": "http://localhost:8025",
|
"server_url": "http://localhost:8825",
|
||||||
"username": "admin",
|
"username": "admin",
|
||||||
"password": "your-secure-password"
|
"password": "your-secure-password"
|
||||||
}
|
}
|
||||||
@@ -90,14 +90,14 @@ cp .whatshooked-cli.example.json .whatshooked-cli.json
|
|||||||
Set environment variables (useful for CI/CD):
|
Set environment variables (useful for CI/CD):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export WHATSHOOKED_SERVER_URL="http://localhost:8025"
|
export WHATSHOOKED_SERVER_URL="http://localhost:8825"
|
||||||
export WHATSHOOKED_AUTH_KEY="your-api-key-here"
|
export WHATSHOOKED_AUTH_KEY="your-api-key-here"
|
||||||
```
|
```
|
||||||
|
|
||||||
Or with username/password:
|
Or with username/password:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export WHATSHOOKED_SERVER_URL="http://localhost:8025"
|
export WHATSHOOKED_SERVER_URL="http://localhost:8825"
|
||||||
export WHATSHOOKED_USERNAME="admin"
|
export WHATSHOOKED_USERNAME="admin"
|
||||||
export WHATSHOOKED_PASSWORD="your-password"
|
export WHATSHOOKED_PASSWORD="your-password"
|
||||||
```
|
```
|
||||||
@@ -107,7 +107,7 @@ export WHATSHOOKED_PASSWORD="your-password"
|
|||||||
Pass credentials via command-line flags:
|
Pass credentials via command-line flags:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./bin/whatshook-cli --server http://localhost:8025 health
|
./bin/whatshook-cli --server http://localhost:8825 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.
|
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
|
```json
|
||||||
{
|
{
|
||||||
"server_url": "http://localhost:8025"
|
"server_url": "http://localhost:8825"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ The CLI looks for configuration files in the following locations (in order):
|
|||||||
|
|
||||||
| Option | Type | Default | Description |
|
| Option | Type | Default | Description |
|
||||||
| ------------ | ------ | ----------------------- | -------------------------- |
|
| ------------ | ------ | ----------------------- | -------------------------- |
|
||||||
| `server_url` | string | `http://localhost:8025` | WhatsHooked server URL |
|
| `server_url` | string | `http://localhost:8825` | WhatsHooked server URL |
|
||||||
| `auth_key` | string | `""` | API key for authentication |
|
| `auth_key` | string | `""` | API key for authentication |
|
||||||
| `username` | string | `""` | Username for Basic Auth |
|
| `username` | string | `""` | Username for Basic Auth |
|
||||||
| `password` | string | `""` | Password for Basic Auth |
|
| `password` | string | `""` | Password for Basic Auth |
|
||||||
@@ -305,7 +305,7 @@ Supported formats: PDF, DOC, DOCX, XLS, XLSX, TXT, ZIP, and more
|
|||||||
mkdir -p ~/.whatshooked
|
mkdir -p ~/.whatshooked
|
||||||
cat > ~/.whatshooked/cli.json <<EOF
|
cat > ~/.whatshooked/cli.json <<EOF
|
||||||
{
|
{
|
||||||
"server_url": "http://localhost:8025",
|
"server_url": "http://localhost:8825",
|
||||||
"auth_key": "my-secure-api-key"
|
"auth_key": "my-secure-api-key"
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
@@ -321,7 +321,7 @@ EOF
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Set environment variables
|
# Set environment variables
|
||||||
export WHATSHOOKED_SERVER_URL="https://my-server.com:8025"
|
export WHATSHOOKED_SERVER_URL="https://my-server.com:8825"
|
||||||
export WHATSHOOKED_AUTH_KEY="production-api-key"
|
export WHATSHOOKED_AUTH_KEY="production-api-key"
|
||||||
|
|
||||||
# Use CLI without config file
|
# Use CLI without config file
|
||||||
@@ -381,7 +381,7 @@ export WHATSHOOKED_AUTH_KEY="production-api-key"
|
|||||||
{
|
{
|
||||||
"server": {
|
"server": {
|
||||||
"host": "0.0.0.0",
|
"host": "0.0.0.0",
|
||||||
"port": 8025,
|
"port": 8825,
|
||||||
"auth_key": "super-secret-production-key"
|
"auth_key": "super-secret-production-key"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -458,7 +458,7 @@ cp .whatshooked-cli.example.json ~/.whatshooked/cli.json
|
|||||||
Verify the server is running:
|
Verify the server is running:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl http://localhost:8025/health
|
curl http://localhost:8825/health
|
||||||
```
|
```
|
||||||
|
|
||||||
### Authentication Required
|
### Authentication Required
|
||||||
|
|||||||
30
DOCKER.md
30
DOCKER.md
@@ -43,7 +43,7 @@ This guide explains how to run WhatsHooked using Docker and Docker Compose.
|
|||||||
|
|
||||||
6. **Check server health:**
|
6. **Check server health:**
|
||||||
```bash
|
```bash
|
||||||
curl http://localhost:8025/health
|
curl http://localhost:8825/health
|
||||||
```
|
```
|
||||||
|
|
||||||
## Docker Commands
|
## Docker Commands
|
||||||
@@ -98,7 +98,7 @@ These volumes ensure your data persists across container restarts.
|
|||||||
|
|
||||||
### Port Mapping
|
### Port Mapping
|
||||||
|
|
||||||
By default, the server runs on port 8025. To change the port:
|
By default, the server runs on port 8825. To change the port:
|
||||||
|
|
||||||
**Option 1: Update config.json**
|
**Option 1: Update config.json**
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ ports:
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
ports:
|
ports:
|
||||||
- "3000:8025" # Access via localhost:3000, server still runs on 8025 internally
|
- "3000:8825" # Access via localhost:3000, server still runs on 8825 internally
|
||||||
```
|
```
|
||||||
|
|
||||||
### Authentication
|
### Authentication
|
||||||
@@ -185,7 +185,7 @@ The QR code will be displayed in ASCII art in the terminal along with a browser
|
|||||||
|
|
||||||
**Option 2: View in Browser**
|
**Option 2: View in Browser**
|
||||||
|
|
||||||
1. Look for the line: `Or open in browser: http://localhost:8025/api/qr/{account_id}`
|
1. Look for the line: `Or open in browser: http://localhost:8825/api/qr/{account_id}`
|
||||||
2. Open that URL in your web browser to see a larger PNG image
|
2. Open that URL in your web browser to see a larger PNG image
|
||||||
3. Scan the QR code from your browser
|
3. Scan the QR code from your browser
|
||||||
|
|
||||||
@@ -206,37 +206,37 @@ The Docker image includes both the server and CLI binaries in the `/app/bin` dir
|
|||||||
List all hooks:
|
List all hooks:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8025 hooks list
|
docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8825 hooks list
|
||||||
```
|
```
|
||||||
|
|
||||||
Add a new hook:
|
Add a new hook:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker exec -it whatshooked-server /app/bin/whatshook-cli --server http://localhost:8025 hooks add
|
docker exec -it whatshooked-server /app/bin/whatshook-cli --server http://localhost:8825 hooks add
|
||||||
```
|
```
|
||||||
|
|
||||||
Remove a hook:
|
Remove a hook:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8025 hooks remove <hook_id>
|
docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8825 hooks remove <hook_id>
|
||||||
```
|
```
|
||||||
|
|
||||||
List WhatsApp accounts:
|
List WhatsApp accounts:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8025 accounts list
|
docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8825 accounts list
|
||||||
```
|
```
|
||||||
|
|
||||||
Send a message:
|
Send a message:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker exec -it whatshooked-server /app/bin/whatshook-cli --server http://localhost:8025 send
|
docker exec -it whatshooked-server /app/bin/whatshook-cli --server http://localhost:8825 send
|
||||||
```
|
```
|
||||||
|
|
||||||
Check server health:
|
Check server health:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8025 health
|
docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8825 health
|
||||||
```
|
```
|
||||||
|
|
||||||
### Authentication with CLI
|
### Authentication with CLI
|
||||||
@@ -247,7 +247,7 @@ If your server has authentication enabled, you need to configure it in the CLI:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker exec whatshooked-server /app/bin/whatshook-cli \
|
docker exec whatshooked-server /app/bin/whatshook-cli \
|
||||||
--server http://localhost:8025 \
|
--server http://localhost:8825 \
|
||||||
--api-key your-api-key \
|
--api-key your-api-key \
|
||||||
hooks list
|
hooks list
|
||||||
```
|
```
|
||||||
@@ -265,7 +265,7 @@ docker exec whatshooked-server /app/bin/whatshook-cli \
|
|||||||
```bash
|
```bash
|
||||||
cat > /app/.whatshooked-cli.json <<EOF
|
cat > /app/.whatshooked-cli.json <<EOF
|
||||||
{
|
{
|
||||||
"server_url": "http://localhost:8025",
|
"server_url": "http://localhost:8825",
|
||||||
"api_key": "your-api-key"
|
"api_key": "your-api-key"
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
@@ -281,7 +281,7 @@ docker exec whatshooked-server /app/bin/whatshook-cli \
|
|||||||
Create an alias on your host machine for easier CLI access:
|
Create an alias on your host machine for easier CLI access:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
alias whatshook-cli='docker exec -it whatshooked-server /app/bin/whatshook-cli --server http://localhost:8025'
|
alias whatshook-cli='docker exec -it whatshooked-server /app/bin/whatshook-cli --server http://localhost:8825'
|
||||||
```
|
```
|
||||||
|
|
||||||
Then use it like:
|
Then use it like:
|
||||||
@@ -388,7 +388,7 @@ services:
|
|||||||
- whatshooked-net
|
- whatshooked-net
|
||||||
# Don't expose ports to host, only to network
|
# Don't expose ports to host, only to network
|
||||||
# ports:
|
# ports:
|
||||||
# - "8025:8025"
|
# - "8825:8825"
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
whatshooked-net:
|
whatshooked-net:
|
||||||
@@ -406,7 +406,7 @@ server {
|
|||||||
ssl_certificate_key /path/to/key.pem;
|
ssl_certificate_key /path/to/key.pem;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://whatshooked:8025;
|
proxy_pass http://whatshooked:8825;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ COPY --from=builder /build/bin ./bin
|
|||||||
RUN mkdir -p /app/sessions /app/data/media /app/data/certs
|
RUN mkdir -p /app/sessions /app/data/media /app/data/certs
|
||||||
|
|
||||||
# Expose the default server port
|
# Expose the default server port
|
||||||
EXPOSE 8025
|
EXPOSE 8825
|
||||||
|
|
||||||
# Run the server
|
# Run the server
|
||||||
ENTRYPOINT ["/app/bin/whatshook-server"]
|
ENTRYPOINT ["/app/bin/whatshook-server"]
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ script:
|
|||||||
{
|
{
|
||||||
"server": {
|
"server": {
|
||||||
"host": "0.0.0.0",
|
"host": "0.0.0.0",
|
||||||
"port": 8025
|
"port": 8825
|
||||||
},
|
},
|
||||||
"whatsapp": [
|
"whatsapp": [
|
||||||
{
|
{
|
||||||
|
|||||||
40
README.md
40
README.md
@@ -60,7 +60,7 @@ Or with programmatic configuration:
|
|||||||
|
|
||||||
```go
|
```go
|
||||||
wh, err := whatshooked.New(
|
wh, err := whatshooked.New(
|
||||||
whatshooked.WithServer("0.0.0.0", 8025),
|
whatshooked.WithServer("0.0.0.0", 8825),
|
||||||
whatshooked.WithAuth("my-api-key", "", ""),
|
whatshooked.WithAuth("my-api-key", "", ""),
|
||||||
whatshooked.WithWhatsmeowAccount("personal", "+1234567890", "./session", true),
|
whatshooked.WithWhatsmeowAccount("personal", "+1234567890", "./session", true),
|
||||||
)
|
)
|
||||||
@@ -92,7 +92,7 @@ Scan this QR code with WhatsApp on your phone:
|
|||||||
|
|
||||||
[ASCII QR Code displayed here]
|
[ASCII QR Code displayed here]
|
||||||
|
|
||||||
Or open in browser: http://localhost:8025/api/qr/personal
|
Or open in browser: http://localhost:8825/api/qr/personal
|
||||||
========================================
|
========================================
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ Or open in browser: http://localhost:8025/api/qr/personal
|
|||||||
|
|
||||||
For easier scanning, open the provided URL in your browser to view a larger PNG image:
|
For easier scanning, open the provided URL in your browser to view a larger PNG image:
|
||||||
|
|
||||||
- URL format: `http://localhost:8025/api/qr/{account_id}`
|
- URL format: `http://localhost:8825/api/qr/{account_id}`
|
||||||
- No authentication required for this endpoint
|
- No authentication required for this endpoint
|
||||||
- The QR code updates automatically when a new code is generated
|
- The QR code updates automatically when a new code is generated
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ The QR code URL is also included in the `whatsapp.qr.code` event:
|
|||||||
"data": {
|
"data": {
|
||||||
"account_id": "personal",
|
"account_id": "personal",
|
||||||
"qr_code": "2@...",
|
"qr_code": "2@...",
|
||||||
"qr_url": "http://localhost:8025/api/qr/personal"
|
"qr_url": "http://localhost:8825/api/qr/personal"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -210,7 +210,7 @@ func main() {
|
|||||||
// Your own handlers
|
// Your own handlers
|
||||||
mux.HandleFunc("/api/v1/custom", yourCustomHandler)
|
mux.HandleFunc("/api/v1/custom", yourCustomHandler)
|
||||||
|
|
||||||
http.ListenAndServe(":8025", mux)
|
http.ListenAndServe(":8825", mux)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -220,7 +220,7 @@ Configure WhatsHooked entirely in code without a config file:
|
|||||||
|
|
||||||
```go
|
```go
|
||||||
wh, err := whatshooked.New(
|
wh, err := whatshooked.New(
|
||||||
whatshooked.WithServer("0.0.0.0", 8025),
|
whatshooked.WithServer("0.0.0.0", 8825),
|
||||||
whatshooked.WithAuth("my-api-key", "", ""),
|
whatshooked.WithAuth("my-api-key", "", ""),
|
||||||
whatshooked.WithWhatsmeowAccount(
|
whatshooked.WithWhatsmeowAccount(
|
||||||
"personal",
|
"personal",
|
||||||
@@ -389,7 +389,7 @@ Edit the configuration file to add your WhatsApp accounts and webhooks:
|
|||||||
{
|
{
|
||||||
"server": {
|
"server": {
|
||||||
"host": "localhost",
|
"host": "localhost",
|
||||||
"port": 8025,
|
"port": 8825,
|
||||||
"default_country_code": "27"
|
"default_country_code": "27"
|
||||||
},
|
},
|
||||||
"whatsapp": [
|
"whatsapp": [
|
||||||
@@ -435,7 +435,7 @@ Edit the configuration file to add your WhatsApp accounts and webhooks:
|
|||||||
**Server Configuration:**
|
**Server Configuration:**
|
||||||
|
|
||||||
- `host`: Server hostname (default: "localhost")
|
- `host`: Server hostname (default: "localhost")
|
||||||
- `port`: Server port (default: 8025)
|
- `port`: Server port (default: 8825)
|
||||||
- `default_country_code`: Default country code for phone number formatting (e.g., "27" for South Africa, "1" for US/Canada)
|
- `default_country_code`: Default country code for phone number formatting (e.g., "27" for South Africa, "1" for US/Canada)
|
||||||
- `username`: Username for HTTP Basic Authentication (optional)
|
- `username`: Username for HTTP Basic Authentication (optional)
|
||||||
- `password`: Password for HTTP Basic Authentication (optional)
|
- `password`: Password for HTTP Basic Authentication (optional)
|
||||||
@@ -637,7 +637,7 @@ To disable HTTPS and use HTTP, set `enabled: false` or omit the `tls` section en
|
|||||||
{
|
{
|
||||||
"server": {
|
"server": {
|
||||||
"host": "localhost",
|
"host": "localhost",
|
||||||
"port": 8025
|
"port": 8825
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -654,7 +654,7 @@ Set both `username` and `password` in the server configuration:
|
|||||||
{
|
{
|
||||||
"server": {
|
"server": {
|
||||||
"host": "localhost",
|
"host": "localhost",
|
||||||
"port": 8025,
|
"port": 8825,
|
||||||
"username": "admin",
|
"username": "admin",
|
||||||
"password": "secure_password"
|
"password": "secure_password"
|
||||||
}
|
}
|
||||||
@@ -664,7 +664,7 @@ Set both `username` and `password` in the server configuration:
|
|||||||
Clients must provide credentials in the Authorization header:
|
Clients must provide credentials in the Authorization header:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -u admin:secure_password http://localhost:8025/api/hooks
|
curl -u admin:secure_password http://localhost:8825/api/hooks
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 2. API Key Authentication
|
#### 2. API Key Authentication
|
||||||
@@ -675,7 +675,7 @@ Set `auth_key` in the server configuration:
|
|||||||
{
|
{
|
||||||
"server": {
|
"server": {
|
||||||
"host": "localhost",
|
"host": "localhost",
|
||||||
"port": 8025,
|
"port": 8825,
|
||||||
"auth_key": "your-secret-api-key"
|
"auth_key": "your-secret-api-key"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -685,11 +685,11 @@ Clients can provide the API key using either:
|
|||||||
|
|
||||||
- **x-api-key header**:
|
- **x-api-key header**:
|
||||||
```bash
|
```bash
|
||||||
curl -H "x-api-key: your-secret-api-key" http://localhost:8025/api/hooks
|
curl -H "x-api-key: your-secret-api-key" http://localhost:8825/api/hooks
|
||||||
```
|
```
|
||||||
- **Authorization Bearer token**:
|
- **Authorization Bearer token**:
|
||||||
```bash
|
```bash
|
||||||
curl -H "Authorization: Bearer your-secret-api-key" http://localhost:8025/api/hooks
|
curl -H "Authorization: Bearer your-secret-api-key" http://localhost:8825/api/hooks
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Authentication Notes
|
#### Authentication Notes
|
||||||
@@ -755,7 +755,7 @@ To receive incoming messages from WhatsApp Business API, you must register your
|
|||||||
1. **Start the WhatsHooked server** with your Business API configuration
|
1. **Start the WhatsHooked server** with your Business API configuration
|
||||||
2. **Ensure your server is publicly accessible** (use ngrok for testing):
|
2. **Ensure your server is publicly accessible** (use ngrok for testing):
|
||||||
```bash
|
```bash
|
||||||
ngrok http 8025
|
ngrok http 8825
|
||||||
```
|
```
|
||||||
3. **In Meta for Developers**, go to **WhatsApp** → **Configuration**
|
3. **In Meta for Developers**, go to **WhatsApp** → **Configuration**
|
||||||
4. **Add Webhook URL**:
|
4. **Add Webhook URL**:
|
||||||
@@ -895,13 +895,13 @@ cp .whatshooked-cli.example.json .whatshooked-cli.json
|
|||||||
Or set via environment variable:
|
Or set via environment variable:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export WHATSHOOKED_SERVER_URL=http://localhost:8025
|
export WHATSHOOKED_SERVER_URL=http://localhost:8825
|
||||||
```
|
```
|
||||||
|
|
||||||
Or use command-line flag:
|
Or use command-line flag:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./bin/whatshook-cli --server http://localhost:8025 health
|
./bin/whatshook-cli --server http://localhost:8825 health
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Commands
|
#### Commands
|
||||||
@@ -963,10 +963,10 @@ Send a message:
|
|||||||
|
|
||||||
The CLI loads configuration with the following priority (highest to lowest):
|
The CLI loads configuration with the following priority (highest to lowest):
|
||||||
|
|
||||||
1. **Command-line flags**: `--server http://example.com:8025`
|
1. **Command-line flags**: `--server http://example.com:8825`
|
||||||
2. **Environment variables**: `WHATSHOOKED_SERVER_URL=http://example.com:8025`
|
2. **Environment variables**: `WHATSHOOKED_SERVER_URL=http://example.com:8825`
|
||||||
3. **Config file**: `.whatshooked-cli.json` in current directory or `$HOME/.whatshooked/cli.json`
|
3. **Config file**: `.whatshooked-cli.json` in current directory or `$HOME/.whatshooked/cli.json`
|
||||||
4. **Defaults**: `http://localhost:8025`
|
4. **Defaults**: `http://localhost:8825`
|
||||||
|
|
||||||
## Webhook Integration
|
## Webhook Integration
|
||||||
|
|
||||||
|
|||||||
@@ -574,40 +574,40 @@ Events are automatically cached when:
|
|||||||
**List cached events:**
|
**List cached events:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -u username:password http://localhost:8025/api/cache
|
curl -u username:password http://localhost:8825/api/cache
|
||||||
```
|
```
|
||||||
|
|
||||||
**Get cache statistics:**
|
**Get cache statistics:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -u username:password http://localhost:8025/api/cache/stats
|
curl -u username:password http://localhost:8825/api/cache/stats
|
||||||
```
|
```
|
||||||
|
|
||||||
**Replay all cached events:**
|
**Replay all cached events:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -X POST -u username:password http://localhost:8025/api/cache/replay
|
curl -X POST -u username:password http://localhost:8825/api/cache/replay
|
||||||
```
|
```
|
||||||
|
|
||||||
**Replay specific event:**
|
**Replay specific event:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -X POST -u username:password \
|
curl -X POST -u username:password \
|
||||||
"http://localhost:8025/api/cache/event/replay?id=EVENT_ID"
|
"http://localhost:8825/api/cache/event/replay?id=EVENT_ID"
|
||||||
```
|
```
|
||||||
|
|
||||||
**Delete cached event:**
|
**Delete cached event:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -X DELETE -u username:password \
|
curl -X DELETE -u username:password \
|
||||||
"http://localhost:8025/api/cache/event/delete?id=EVENT_ID"
|
"http://localhost:8825/api/cache/event/delete?id=EVENT_ID"
|
||||||
```
|
```
|
||||||
|
|
||||||
**Clear all cache:**
|
**Clear all cache:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -X DELETE -u username:password \
|
curl -X DELETE -u username:password \
|
||||||
"http://localhost:8025/api/cache/clear?confirm=true"
|
"http://localhost:8825/api/cache/clear?confirm=true"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Cache Workflow Example
|
### Cache Workflow Example
|
||||||
@@ -662,7 +662,7 @@ curl -X DELETE -u username:password \
|
|||||||
|
|
||||||
1. `message_cache.enabled` is `true` in config
|
1. `message_cache.enabled` is `true` in config
|
||||||
2. Hooks are actually inactive or not matching events
|
2. Hooks are actually inactive or not matching events
|
||||||
3. Check cache stats: `curl -u user:pass http://localhost:8025/api/cache/stats`
|
3. Check cache stats: `curl -u user:pass http://localhost:8825/api/cache/stats`
|
||||||
|
|
||||||
### No Hooks Configured Error
|
### No Hooks Configured Error
|
||||||
|
|
||||||
@@ -715,7 +715,7 @@ Enable debug logging to trace the issue:
|
|||||||
"type": "image",
|
"type": "image",
|
||||||
"mime_type": "image/jpeg",
|
"mime_type": "image/jpeg",
|
||||||
"filename": "wamid.xxx_a1b2c3d4.jpg",
|
"filename": "wamid.xxx_a1b2c3d4.jpg",
|
||||||
"url": "http://localhost:8025/api/media/business/wamid.xxx_a1b2c3d4.jpg",
|
"url": "http://localhost:8825/api/media/business/wamid.xxx_a1b2c3d4.jpg",
|
||||||
"base64": "..." // Only if media.mode is "base64" or "both"
|
"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": {
|
"server": {
|
||||||
"host": "0.0.0.0",
|
"host": "0.0.0.0",
|
||||||
"port": 8025,
|
"port": 8825,
|
||||||
"default_country_code": "1",
|
"default_country_code": "1",
|
||||||
"username": "admin",
|
"username": "admin",
|
||||||
"password": "secure_password",
|
"password": "secure_password",
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ func LoadCLIConfig(configFile string, serverFlag string) (*CLIConfig, error) {
|
|||||||
v := viper.New()
|
v := viper.New()
|
||||||
|
|
||||||
// Set defaults
|
// Set defaults
|
||||||
v.SetDefault("server_url", "http://localhost:8025")
|
v.SetDefault("server_url", "http://localhost:8825")
|
||||||
v.SetDefault("auth_key", "")
|
v.SetDefault("auth_key", "")
|
||||||
v.SetDefault("username", "")
|
v.SetDefault("username", "")
|
||||||
v.SetDefault("password", "")
|
v.SetDefault("password", "")
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ var rootCmd = &cobra.Command{
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default: $HOME/.whatshooked/cli.json)")
|
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default: $HOME/.whatshooked/cli.json)")
|
||||||
rootCmd.PersistentFlags().StringVar(&serverURL, "server", "", "server URL (default: http://localhost:8025)")
|
rootCmd.PersistentFlags().StringVar(&serverURL, "server", "", "server URL (default: http://localhost:8825)")
|
||||||
|
|
||||||
// Add all command groups
|
// Add all command groups
|
||||||
rootCmd.AddCommand(healthCmd)
|
rootCmd.AddCommand(healthCmd)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"server_url": "http://localhost:8025",
|
"server_url": "http://localhost:8825",
|
||||||
"auth_key": "",
|
"auth_key": "",
|
||||||
"username": "",
|
"username": "",
|
||||||
"password": ""
|
"password": ""
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"server": {
|
"server": {
|
||||||
"host": "localhost",
|
"host": "localhost",
|
||||||
"port": 8025,
|
"port": 8825,
|
||||||
"default_country_code": "27",
|
"default_country_code": "27",
|
||||||
"username": "",
|
"username": "",
|
||||||
"password": "",
|
"password": "",
|
||||||
@@ -97,7 +97,7 @@
|
|||||||
"media": {
|
"media": {
|
||||||
"data_path": "./data/media",
|
"data_path": "./data/media",
|
||||||
"mode": "link",
|
"mode": "link",
|
||||||
"base_url": "http://localhost:8025"
|
"base_url": "http://localhost:8825"
|
||||||
},
|
},
|
||||||
"database": {
|
"database": {
|
||||||
"type": "postgres",
|
"type": "postgres",
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ services:
|
|||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: whatshooked-server
|
container_name: whatshooked-server
|
||||||
ports:
|
ports:
|
||||||
- "0.0.0.0:8025:8025"
|
- "0.0.0.0:8825:8825"
|
||||||
volumes:
|
volumes:
|
||||||
# Mount config file
|
# Mount config file
|
||||||
- type: bind
|
- type: bind
|
||||||
@@ -25,7 +25,7 @@ services:
|
|||||||
|
|
||||||
# Health check
|
# Health check
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8025/health"]
|
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8825/health"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 3
|
retries: 3
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ func Load(path string) (*Config, error) {
|
|||||||
cfg.Server.Host = "0.0.0.0"
|
cfg.Server.Host = "0.0.0.0"
|
||||||
}
|
}
|
||||||
if cfg.Server.Port == 0 {
|
if cfg.Server.Port == 0 {
|
||||||
cfg.Server.Port = 8025
|
cfg.Server.Port = 8825
|
||||||
}
|
}
|
||||||
if cfg.Media.DataPath == "" {
|
if cfg.Media.DataPath == "" {
|
||||||
cfg.Media.DataPath = "./data/media"
|
cfg.Media.DataPath = "./data/media"
|
||||||
|
|||||||
@@ -432,7 +432,7 @@ func (c *Client) saveMediaFile(messageID string, data []byte, mimeType string) (
|
|||||||
func (c *Client) generateMediaURL(messageID, filename string) string {
|
func (c *Client) generateMediaURL(messageID, filename string) string {
|
||||||
baseURL := c.mediaConfig.BaseURL
|
baseURL := c.mediaConfig.BaseURL
|
||||||
if baseURL == "" {
|
if baseURL == "" {
|
||||||
baseURL = "http://localhost:8025"
|
baseURL = "http://localhost:8825"
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%s/api/media/%s/%s", baseURL, c.id, filename)
|
return fmt.Sprintf("%s/api/media/%s/%s", baseURL, c.id, filename)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -678,7 +678,7 @@ func (c *Client) saveMediaFile(messageID string, data []byte, mimeType string) (
|
|||||||
func (c *Client) generateMediaURL(messageID, filename string) string {
|
func (c *Client) generateMediaURL(messageID, filename string) string {
|
||||||
baseURL := c.mediaConfig.BaseURL
|
baseURL := c.mediaConfig.BaseURL
|
||||||
if baseURL == "" {
|
if baseURL == "" {
|
||||||
baseURL = "http://localhost:8025"
|
baseURL = "http://localhost:8825"
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%s/api/media/%s/%s", baseURL, c.id, filename)
|
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 {
|
func (c *Client) generateQRCodeURL() string {
|
||||||
baseURL := c.mediaConfig.BaseURL
|
baseURL := c.mediaConfig.BaseURL
|
||||||
if baseURL == "" {
|
if baseURL == "" {
|
||||||
baseURL = "http://localhost:8025"
|
baseURL = "http://localhost:8825"
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%s/api/qr/%s", baseURL, c.id)
|
return fmt.Sprintf("%s/api/qr/%s", baseURL, c.id)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ func New(opts ...Option) (*WhatsHooked, error) {
|
|||||||
cfg := &config.Config{
|
cfg := &config.Config{
|
||||||
Server: config.ServerConfig{
|
Server: config.ServerConfig{
|
||||||
Host: "0.0.0.0",
|
Host: "0.0.0.0",
|
||||||
Port: 8025,
|
Port: 8825,
|
||||||
},
|
},
|
||||||
Media: config.MediaConfig{
|
Media: config.MediaConfig{
|
||||||
DataPath: "./data/media",
|
DataPath: "./data/media",
|
||||||
|
|||||||
Reference in New Issue
Block a user