- Add auth handlers (signup, login, logout, account management) with bcrypt - Add client, customer, service, scheduling, payment, question, answer handlers - Add dashboard, monthly report, and lead pipeline pages - Add UTF-8 middleware to force charset on HTML responses - Add config package with env-based overrides for DB path, secrets, endpoints - Add parser package for WhatsApp message ingestion - Add clean-arch layers: pkg/domain, pkg/repo, pkg/usecase for leads - Add cmd/migrate utility for DB migrations - Add Makefile, README, run-tests.sh, and dev scripts - Update docker-compose.yml with memory limits - Update .air.toml to exclude DB files and stop on errors - Update whatsapp-sync dependencies and add src/index.js entrypoint - Add whatsme standalone WhatsApp reader app (source only) - Untrack .opencode-sandbox/data/go-crm.db from git history - Expand root .gitignore: ngrok, tmp dirs, sandbox DBs, compiled binaries
41 lines
912 B
Go
41 lines
912 B
Go
package whatsapp
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
type ConnectionState string
|
|
|
|
const (
|
|
StateDisconnected ConnectionState = "disconnected"
|
|
StateConnecting ConnectionState = "connecting"
|
|
StateWaitingQR ConnectionState = "waiting_qr"
|
|
StateConnected ConnectionState = "connected"
|
|
StateFailed ConnectionState = "failed"
|
|
)
|
|
|
|
type QRFrame struct {
|
|
QR string
|
|
State ConnectionState
|
|
Error string
|
|
}
|
|
|
|
type Contact struct {
|
|
Phone string
|
|
Name string
|
|
Message string // raw text of the first/incoming message
|
|
FromMe bool
|
|
Time time.Time
|
|
}
|
|
|
|
type ContactHandler interface {
|
|
OnContact(ctx context.Context, clientID int64, contact Contact) error
|
|
}
|
|
|
|
type Connector interface {
|
|
Connect(ctx context.Context, clientID int64) (<-chan QRFrame, error)
|
|
Disconnect(ctx context.Context, clientID int64) error
|
|
IsConnected(ctx context.Context, clientID int64) (bool, error)
|
|
SetClientDB(db interface{})
|
|
} |