Compare commits
1
Commits
main
...
upstream-sync
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80d7c72c07 |
No files matched your search
@@ -1,5 +1,47 @@
|
||||
# Evolution GO - Changelog
|
||||
|
||||
## v0.7.3
|
||||
|
||||
**Docker:** `evoapicloud/evolution-go:0.7.3`
|
||||
|
||||
### 🐛 Bug Fixes
|
||||
- **`Client outdated (405)` on every connect.** Since 2026-11-02 WhatsApp
|
||||
rejects the client version sent by 0.7.2 (`2.3000.1042386815`), so every
|
||||
instance dropped and could not reconnect. whatsmeow moves to `54038813c47f`,
|
||||
which sends `2.3000.1052556849`. Paired sessions reconnect without a new QR
|
||||
code.
|
||||
- **Postgres connection leak on every connect and reconnect.** `StartClient`
|
||||
called `sqlstore.New` on each run, so every connect, reconnect and client
|
||||
restart opened a new connection pool that was never closed: one more
|
||||
connection to `POSTGRES_AUTH_DB` per call. It now uses a single auth container
|
||||
per process, built with `sqlstore.NewWithDB` on the pool `main.go` already
|
||||
opens and caps (25 open / 5 idle). Against a real Postgres, 40 `StartClient`
|
||||
calls grew the backend connections by 40 on 0.7.2 and by 1 on 0.7.3.
|
||||
- **Auth store upgrade bounded by a deadline.** The container upgrade runs
|
||||
under a mutex; it now gives up after 60s instead of stalling every
|
||||
`StartClient` behind a database that accepts TCP but never answers. A failed
|
||||
creation is retried on the next call instead of being cached.
|
||||
- **`postgres` driver registered explicitly** in `pkg/config`, with a test, so
|
||||
`sql.Open("postgres")` cannot start failing at boot after an import cleanup.
|
||||
|
||||
### ⚠️ Breaking Changes
|
||||
- **Blocklist responses changed shape.** The `data` returned by
|
||||
`POST /user/block`, `POST /user/unblock` and `GET /user/blocklist` follows
|
||||
the new whatsmeow blocklist: `JIDs` is replaced by `Items`, a list of
|
||||
`{LID, PN, Active}`, and `AddressingMode` is added. `DHash` stays. Blocking a
|
||||
number that has no LID on WhatsApp now returns an error.
|
||||
|
||||
### ⬆️ Upgrade notes
|
||||
- No configuration change. With SQLite (no `POSTGRES_AUTH_DB`), all instances
|
||||
now share one auth database connection.
|
||||
- Building from source requires Go 1.26. The Docker image builds with
|
||||
`golang:1.26.10-alpine`.
|
||||
- The whatsmeow store gets two new columns on startup (schema v16). The
|
||||
migration is backwards compatible, so going back to the 0.7.2 image keeps
|
||||
working.
|
||||
- A `CONNECTION LIMIT` set on the database role to contain the leak can stay;
|
||||
this service now keeps its connections within its own pool.
|
||||
|
||||
## v0.7.2
|
||||
|
||||
**Docker:** `evoapicloud/evolution-go:0.7.2`
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
FROM golang:1.25.0-alpine AS build
|
||||
FROM golang:1.26.10-alpine AS build
|
||||
|
||||
RUN apk update && apk add --no-cache git build-base libjpeg-turbo-dev libwebp-dev
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
module github.com/evolution-foundation/evolution-go
|
||||
|
||||
go 1.25.0
|
||||
go 1.26.0
|
||||
|
||||
require (
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.2
|
||||
@@ -21,11 +21,11 @@ require (
|
||||
github.com/swaggo/gin-swagger v1.6.0
|
||||
github.com/swaggo/swag v1.16.3
|
||||
github.com/vincent-petithory/dataurl v1.0.0
|
||||
go.mau.fi/whatsmeow v0.0.0-20260630180629-b572e5bcb92b
|
||||
golang.org/x/exp v0.0.0-20260611194520-c48552f49976
|
||||
go.mau.fi/whatsmeow v0.0.0-20261102152715-54038813c47f
|
||||
golang.org/x/exp v0.0.0-20261014143641-f0251eb4aa3e
|
||||
golang.org/x/image v0.0.0-20211028202545-6944b10bf410
|
||||
golang.org/x/net v0.56.0
|
||||
google.golang.org/protobuf v1.36.11
|
||||
golang.org/x/net v0.61.0
|
||||
google.golang.org/protobuf v1.36.12
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||
gorm.io/driver/postgres v1.5.9
|
||||
gorm.io/gorm v1.25.10
|
||||
@@ -75,7 +75,7 @@ require (
|
||||
github.com/nats-io/nuid v1.0.1 // indirect
|
||||
github.com/ncruces/go-strftime v0.1.9 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
|
||||
github.com/petermattis/goid v0.0.0-20260330135022-df67b199bc81 // indirect
|
||||
github.com/petermattis/goid v0.0.0-20260918085751-abfca077860b // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
github.com/rogpeppe/go-internal v1.12.0 // indirect
|
||||
github.com/rs/xid v1.6.0 // indirect
|
||||
@@ -84,13 +84,13 @@ require (
|
||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
github.com/vektah/gqlparser/v2 v2.5.27 // indirect
|
||||
go.mau.fi/libsignal v0.2.2 // indirect
|
||||
go.mau.fi/util v0.9.10 // indirect
|
||||
go.mau.fi/util v0.11.0 // indirect
|
||||
golang.org/x/arch v0.10.0 // indirect
|
||||
golang.org/x/crypto v0.53.0 // indirect
|
||||
golang.org/x/sync v0.21.0 // indirect
|
||||
golang.org/x/sys v0.46.0 // indirect
|
||||
golang.org/x/text v0.38.0 // indirect
|
||||
golang.org/x/tools v0.46.0 // indirect
|
||||
golang.org/x/crypto v0.58.0 // indirect
|
||||
golang.org/x/sync v0.24.0 // indirect
|
||||
golang.org/x/sys v0.49.0 // indirect
|
||||
golang.org/x/text v0.43.0 // indirect
|
||||
golang.org/x/tools v0.52.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
|
||||
modernc.org/libc v1.55.3 // indirect
|
||||
|
||||
@@ -111,8 +111,8 @@ github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHP
|
||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.45 h1:6KA/spDguL3KV8rnybG7ezSaE4SeMR3KC9VbUoAQaIk=
|
||||
github.com/mattn/go-sqlite3 v1.14.45/go.mod h1:pjEuOr8IwzLJP2MfGeTb0A35jauH+C2kbHKBr7yXKVQ=
|
||||
github.com/mattn/go-sqlite3 v1.14.52 h1:wVbm2Qnf4OXkqhBTSPuCRZDRnxfbVrrmiCEroVdog8U=
|
||||
github.com/mattn/go-sqlite3 v1.14.52/go.mod h1:6JTjA44L93a0QCyJef5YvlPoKXntQPjzWv5gtm9sB6w=
|
||||
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
||||
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
|
||||
github.com/minio/minio-go/v7 v7.0.80 h1:2mdUHXEykRdY/BigLt3Iuu1otL0JTogT0Nmltg0wujk=
|
||||
@@ -134,8 +134,8 @@ github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaR
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
|
||||
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
|
||||
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
|
||||
github.com/petermattis/goid v0.0.0-20260330135022-df67b199bc81 h1:WDsQxOJDy0N1VRAjXLpi8sCEZRSGarLWQevDxpTBRrM=
|
||||
github.com/petermattis/goid v0.0.0-20260330135022-df67b199bc81/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4=
|
||||
github.com/petermattis/goid v0.0.0-20260918085751-abfca077860b h1:OzNsuVdSWGwXvWKTtChx9ve89k4cFJ6NxYM4Aw4/f+E=
|
||||
github.com/petermattis/goid v0.0.0-20260918085751-abfca077860b/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rabbitmq/amqp091-go v1.10.0 h1:STpn5XsHlHGcecLmMFCtg7mqq0RnD+zFr4uzukfVhBw=
|
||||
@@ -160,8 +160,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/stretchr/testify v1.12.0 h1:K6Mr6jO9JICuend/5xzTM03ydSV3vdNRYAdPSukj8uI=
|
||||
github.com/stretchr/testify v1.12.0/go.mod h1:bOYBZb5qJ00vPzWfIqBUZPaxK8jWiXc6d3ErP4Ca9Gw=
|
||||
github.com/swaggo/files v1.0.1 h1:J1bVJ4XHZNq0I46UU90611i9/YzdrF7x92oX1ig5IdE=
|
||||
github.com/swaggo/files v1.0.1/go.mod h1:0qXmMNH6sXNf+73t65aKeB+ApmgxdnkQzVTAj2uaMUg=
|
||||
github.com/swaggo/gin-swagger v1.6.0 h1:y8sxvQ3E20/RCyrXeFfg60r6H0Z+SwpTjMYsMm+zy8M=
|
||||
@@ -179,35 +179,35 @@ github.com/vincent-petithory/dataurl v1.0.0/go.mod h1:FHafX5vmDzyP+1CQATJn7WFKc9
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
go.mau.fi/libsignal v0.2.2 h1:QV+XdzQkm3x3aSG7FcqfGSZuFXz83pRZPBFaPygHbOU=
|
||||
go.mau.fi/libsignal v0.2.2/go.mod h1:CRlIQg2J8uYTfDFvNoO8/KcZjs5cey0vbc6oj/bssY0=
|
||||
go.mau.fi/util v0.9.10 h1:wzvz5iDHyqDXB8vgisD4d3SzucLXNM3iNY+1O1RoHtg=
|
||||
go.mau.fi/util v0.9.10/go.mod h1:YQOxySn+ZE3qSYqNxvyX7Yi3suA8YK17PS6QqBREW7A=
|
||||
go.mau.fi/whatsmeow v0.0.0-20260630180629-b572e5bcb92b h1:ZUk1ErarDNpnbosXR/MeOz2gkqA4S1bh8zjaSRj7N+Y=
|
||||
go.mau.fi/whatsmeow v0.0.0-20260630180629-b572e5bcb92b/go.mod h1:9dmNTYZ/1pHjPw/bz+azBsGjAkcrZbqzMrKcvG5bJ8U=
|
||||
go.mau.fi/util v0.11.0 h1:JNEpkVRxfTdJUC0DIGKiRlLKzl4G/qLX/eVzoP7QuwY=
|
||||
go.mau.fi/util v0.11.0/go.mod h1:04AEFVsc4zNdIkDC1gkdqbg/nZFolHY50pyXh2DSy7s=
|
||||
go.mau.fi/whatsmeow v0.0.0-20261102152715-54038813c47f h1:UFm189GiALMSjhuywDHDQhRdhH6y8AD+eaGn5C75B1w=
|
||||
go.mau.fi/whatsmeow v0.0.0-20261102152715-54038813c47f/go.mod h1:iY4lm61nTLWsNiIE1EmHUZwhKGBeoV4dhnVE2uMtNoQ=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||
golang.org/x/arch v0.10.0 h1:S3huipmSclq3PJMNe76NGwkBR504WFkQ5dhzWzP8ZW8=
|
||||
golang.org/x/arch v0.10.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.53.0 h1:QZ4Muo8THX6CizN2vPPd5fBGHyogrdK9fG4wLPFUsto=
|
||||
golang.org/x/crypto v0.53.0/go.mod h1:DNLU434OwVakk9PzuwV8w62mAJpRJL3vsgcfp4Qnsio=
|
||||
golang.org/x/exp v0.0.0-20260611194520-c48552f49976 h1:X8Hz2ImujgbmetVuW+w2YkyZChE3cBpZi2P158rTG9M=
|
||||
golang.org/x/exp v0.0.0-20260611194520-c48552f49976/go.mod h1:vnf4pv9iKZXY58sQE1L86zmNWJ4159e1RkcWiLCkeEY=
|
||||
golang.org/x/crypto v0.58.0 h1:COkYLr4k7nDI4r6QtMML2AfzeIswWHAJthLS6K/M/54=
|
||||
golang.org/x/crypto v0.58.0/go.mod h1:Xh+kl5A+M0gMiWDytH2Hhr5Z7WbNCpv/eB/EFgfSk+w=
|
||||
golang.org/x/exp v0.0.0-20261014143641-f0251eb4aa3e h1:HgI6W1OolKK6tcV74is+rl9SMT0njsHlp0TbQiGXI/A=
|
||||
golang.org/x/exp v0.0.0-20261014143641-f0251eb4aa3e/go.mod h1:DBoxwWhjaW8DJJw/YeM4zpeOKMC1FMXSblsYy+1mFSw=
|
||||
golang.org/x/image v0.0.0-20211028202545-6944b10bf410 h1:hTftEOvwiOq2+O8k2D5/Q7COC7k5Qcrgc2TFURJYnvQ=
|
||||
golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.37.0 h1:vF1DjpVEshcIqoEaauuHebaLk1O1forxjxBaVn884JQ=
|
||||
golang.org/x/mod v0.37.0/go.mod h1:m8S8VeM9r4dzDwjrKO0a1sZP3YjeMamRRlD+fmR2Q/0=
|
||||
golang.org/x/mod v0.42.0 h1:ICeL3t2L30ljSPHHxDnR4fqVcBt/zR2zJAb9juavmQg=
|
||||
golang.org/x/mod v0.42.0/go.mod h1:u5fzIrRInkL8MaO1cbRkUHT64v303YIT5KEqpNr7jRs=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o=
|
||||
golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec=
|
||||
golang.org/x/net v0.61.0 h1:RR+6j/BTBCrggOLugxa+66R8FvoN6MHlzDlZIbN9YFw=
|
||||
golang.org/x/net v0.61.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM=
|
||||
golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sync v0.24.0 h1:iqiDrGoDgyuvAKrhLQthUEzU/R378N78gXbBjxed7oA=
|
||||
golang.org/x/sync v0.24.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
@@ -215,8 +215,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
|
||||
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA=
|
||||
golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
@@ -225,16 +225,16 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE=
|
||||
golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4=
|
||||
golang.org/x/text v0.43.0 h1:1QivrlhwAsnMOcqgOdl9my7s9OyZl8O5/UGUTJVXoWc=
|
||||
golang.org/x/text v0.43.0/go.mod h1:hbSIYA/amXcRXTFSZqh8tWHEoqRvvbKPJ2uz/KU+a+s=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.46.0 h1:7jTurBkPZu4moS/Uy4OQT1M+QBlsj3wejyZwsT8Z7rk=
|
||||
golang.org/x/tools v0.46.0/go.mod h1:FrD85F8l+NWL+9XWBSyVSHO6Ne4jutsfIFba7AWQ5Ys=
|
||||
golang.org/x/tools v0.52.0 h1:ryxg4U63oaUYk7uOLTF37n43f4qgtGvqV4Ioit1BaEs=
|
||||
golang.org/x/tools v0.52.0/go.mod h1:ItcP5UNaVGG+Yc4eIYmaFLNJ4soEopkx5Y2d4lcEurs=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
|
||||
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
|
||||
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
|
||||
@@ -10,6 +10,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gomessguii/logger"
|
||||
// The binary's only registration of the "postgres" driver. Without it the
|
||||
// build still passes and sql.Open("postgres") fails at boot.
|
||||
_ "github.com/lib/pq"
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"slices"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// The only guard for the lib/pq import: build and vet pass without it.
|
||||
func TestPostgresDriverRegistered(t *testing.T) {
|
||||
if !slices.Contains(sql.Drivers(), "postgres") {
|
||||
t.Fatalf("driver \"postgres\" not registered; sql.Drivers() = %v", sql.Drivers())
|
||||
}
|
||||
}
|
||||
+248
-248
File diff suppressed because it is too large.
Load diff
@@ -444,7 +444,7 @@ func (u *userService) BlockContact(data *BlockStruct, instance *instance_model.I
|
||||
return nil, errors.New("invalid phone number")
|
||||
}
|
||||
|
||||
resp, err := client.UpdateBlocklist(context.Background(), jid, events.BlocklistChangeActionBlock)
|
||||
resp, err := client.UpdateBlocklist(context.Background(), jid, events.BlocklistChangeActionBlock, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -463,7 +463,7 @@ func (u *userService) UnlockContact(data *BlockStruct, instance *instance_model.
|
||||
return nil, errors.New("invalid phone number")
|
||||
}
|
||||
|
||||
resp, err := client.UpdateBlocklist(context.Background(), jid, events.BlocklistChangeActionUnblock)
|
||||
resp, err := client.UpdateBlocklist(context.Background(), jid, events.BlocklistChangeActionUnblock, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -477,7 +477,7 @@ func (u *userService) GetBlockList(instance *instance_model.Instance) (*types.Bl
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := client.GetBlocklist(context.Background())
|
||||
resp, err := client.GetBlocklist(context.Background(), "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -532,7 +532,7 @@ func (u *userService) SetProfileStatus(data *SetProfileStatusStruct, instance *i
|
||||
return false, err
|
||||
}
|
||||
|
||||
err = client.SetStatusMessage(context.Background(), data.Status)
|
||||
err = client.SetStatusMessage(context.Background(), types.SetStatusInput{Text: &data.Status})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package whatsmeow_service
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
_ "modernc.org/sqlite"
|
||||
|
||||
"github.com/evolution-foundation/evolution-go/pkg/config"
|
||||
)
|
||||
|
||||
// Exercised through SQLite only. Closing ownDB on the Upgrade error path is not
|
||||
// covered: the handle is local to getAuthContainer.
|
||||
func TestGetAuthContainerRetryAndReuse(t *testing.T) {
|
||||
// TempDirs first: cleanups run LIFO, so reset closes the *sql.DB before
|
||||
// RemoveAll, which fails on Windows while the file is still open.
|
||||
badPath := filepath.Join(t.TempDir(), "does-not-exist")
|
||||
goodPath := t.TempDir()
|
||||
|
||||
reset := func() {
|
||||
sharedAuthContainerMu.Lock()
|
||||
if sharedAuthContainer != nil {
|
||||
_ = sharedAuthContainer.Close()
|
||||
sharedAuthContainer = nil
|
||||
}
|
||||
sharedAuthContainerMu.Unlock()
|
||||
}
|
||||
reset()
|
||||
t.Cleanup(reset)
|
||||
|
||||
// SQLite does not create missing directories, so Upgrade fails here.
|
||||
bad := whatsmeowService{
|
||||
config: &config.Config{},
|
||||
exPath: badPath,
|
||||
}
|
||||
if _, err := bad.getAuthContainer(); err == nil {
|
||||
t.Fatal("expected an error for a missing directory, got nil")
|
||||
}
|
||||
sharedAuthContainerMu.Lock()
|
||||
if sharedAuthContainer != nil {
|
||||
sharedAuthContainerMu.Unlock()
|
||||
t.Fatalf("failed container should not be memoized (sharedAuthContainer = %#v)", sharedAuthContainer)
|
||||
}
|
||||
sharedAuthContainerMu.Unlock()
|
||||
|
||||
// The DSN expects a dbdata subdirectory.
|
||||
if err := os.MkdirAll(filepath.Join(goodPath, "dbdata"), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
good := whatsmeowService{
|
||||
config: &config.Config{},
|
||||
exPath: goodPath,
|
||||
}
|
||||
c1, err := good.getAuthContainer()
|
||||
if err != nil {
|
||||
t.Fatalf("retry after a failure should succeed instead of returning a cached error: %v", err)
|
||||
}
|
||||
if c1 == nil {
|
||||
t.Fatal("nil container after success")
|
||||
}
|
||||
|
||||
c2, err := good.getAuthContainer()
|
||||
if err != nil {
|
||||
t.Fatalf("second call failed: %v", err)
|
||||
}
|
||||
if c1 != c2 {
|
||||
t.Fatal("container was not reused; expected the shared instance")
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"golang.org/x/image/webp"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
_ "github.com/lib/pq"
|
||||
"github.com/patrickmn/go-cache"
|
||||
"github.com/skip2/go-qrcode"
|
||||
"go.mau.fi/whatsmeow"
|
||||
@@ -301,6 +300,65 @@ func (w whatsmeowService) ForceUpdateJid(instanceId string, number string) error
|
||||
return nil
|
||||
}
|
||||
|
||||
// Shared by every StartClient: a container per call opens a pool that is never
|
||||
// closed. Only success is memoized, so a failed creation is retried next call.
|
||||
var (
|
||||
sharedAuthContainer *sqlstore.Container
|
||||
sharedAuthContainerMu sync.Mutex
|
||||
)
|
||||
|
||||
func (w whatsmeowService) getAuthContainer() (*sqlstore.Container, error) {
|
||||
sharedAuthContainerMu.Lock()
|
||||
defer sharedAuthContainerMu.Unlock()
|
||||
|
||||
if sharedAuthContainer != nil {
|
||||
return sharedAuthContainer, nil
|
||||
}
|
||||
|
||||
var dbLog waLog.Logger
|
||||
if w.config.WaDebug != "" {
|
||||
dbLog = waLog.Stdout("Database", w.config.WaDebug, true)
|
||||
}
|
||||
|
||||
var container *sqlstore.Container
|
||||
var ownDB *sql.DB
|
||||
|
||||
if w.config.PostgresAuthDB != "" {
|
||||
// Reuse the pool main.go opened and capped; a second pool on the same
|
||||
// DSN would raise the connection ceiling.
|
||||
if w.authDB == nil {
|
||||
return nil, fmt.Errorf("POSTGRES_AUTH_DB is set but the auth database pool was not initialized")
|
||||
}
|
||||
container = sqlstore.NewWithDB(w.authDB, "postgres", dbLog)
|
||||
} else {
|
||||
dsn := fmt.Sprintf("file:%s/dbdata/main.db?_pragma=foreign_keys(1)&_busy_timeout=5000&cache=shared&mode=rwc&_journal_mode=WAL", w.exPath)
|
||||
db, err := sql.Open("sqlite", dsn)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to open auth database: %w", err)
|
||||
}
|
||||
// Process-wide cap shared by all instances. Fix the DSN before raising it:
|
||||
// modernc ignores _journal_mode and _busy_timeout, so WAL is never enabled.
|
||||
db.SetMaxOpenConns(1)
|
||||
ownDB = db
|
||||
container = sqlstore.NewWithDB(db, "sqlite", dbLog)
|
||||
}
|
||||
|
||||
// Upgrade runs under the mutex: without a deadline, a server that accepts TCP
|
||||
// but never answers would stall every StartClient behind it.
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
|
||||
defer cancel()
|
||||
if err := container.Upgrade(ctx); err != nil {
|
||||
// Close only what this call opened; the Postgres pool belongs to main.
|
||||
if ownDB != nil {
|
||||
_ = ownDB.Close()
|
||||
}
|
||||
return nil, fmt.Errorf("failed to upgrade auth database: %w", err)
|
||||
}
|
||||
|
||||
sharedAuthContainer = container
|
||||
return container, nil
|
||||
}
|
||||
|
||||
func (w whatsmeowService) StartClient(cd *ClientData) {
|
||||
|
||||
w.loggerWrapper.GetLogger(cd.Instance.Id).LogInfo("Starting websocket connection to Whatsapp for user '%s'", cd.Instance.Id)
|
||||
@@ -314,27 +372,9 @@ func (w whatsmeowService) StartClient(cd *ClientData) {
|
||||
}
|
||||
}
|
||||
|
||||
var container *sqlstore.Container
|
||||
|
||||
if w.config.WaDebug != "" {
|
||||
dbLog := waLog.Stdout("Database", w.config.WaDebug, true)
|
||||
if w.config.PostgresAuthDB != "" {
|
||||
container, err = sqlstore.New(context.Background(), "postgres", w.config.PostgresAuthDB, dbLog)
|
||||
} else {
|
||||
dsn := fmt.Sprintf("file:%s/dbdata/main.db?_pragma=foreign_keys(1)&_busy_timeout=5000&cache=shared&mode=rwc&_journal_mode=WAL", w.exPath)
|
||||
container, err = sqlstore.New(context.Background(), "sqlite", dsn, dbLog)
|
||||
}
|
||||
} else {
|
||||
if w.config.PostgresAuthDB != "" {
|
||||
container, err = sqlstore.New(context.Background(), "postgres", w.config.PostgresAuthDB, nil)
|
||||
} else {
|
||||
dsn := fmt.Sprintf("file:%s/dbdata/main.db?_pragma=foreign_keys(1)&_busy_timeout=5000&cache=shared&mode=rwc&_journal_mode=WAL", w.exPath)
|
||||
container, err = sqlstore.New(context.Background(), "sqlite", dsn, nil)
|
||||
}
|
||||
}
|
||||
|
||||
container, err := w.getAuthContainer()
|
||||
if err != nil {
|
||||
w.loggerWrapper.GetLogger(cd.Instance.Id).LogError("[%s] Failed to create container: %v", cd.Instance.Id, err)
|
||||
w.loggerWrapper.GetLogger(cd.Instance.Id).LogError("[%s] Failed to get auth container: %v", cd.Instance.Id, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user