Skip to content

Commit 2ab5c19

Browse files
feat(go): update all dependencies
To incorporate the latest changes in Whatsmeow, I manually modify the SQLITE URLs for WhatsApp logins to enable foreign keys
1 parent 2c67d7f commit 2ab5c19

File tree

8 files changed

+112
-195
lines changed

8 files changed

+112
-195
lines changed

go.mod

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,37 @@
11
module watgbridge
22

3-
go 1.22.3
3+
go 1.23.0
4+
5+
toolchain go1.24.3
46

57
require (
6-
github.com/PaulSonOfLars/gotgbot/v2 v2.0.0-rc.30
8+
github.com/PaulSonOfLars/gotgbot/v2 v2.0.0-rc.33
79
github.com/emersion/go-vcard v0.0.0-20241024213814-c9703dde27ff
8-
github.com/forPelevin/gomoji v1.2.0
10+
github.com/forPelevin/gomoji v1.3.1
911
github.com/go-co-op/gocron v1.37.0
10-
github.com/jackc/pgx/v5 v5.7.2
12+
github.com/jackc/pgx/v5 v5.7.5
1113
github.com/lithammer/fuzzysearch v1.1.8
12-
github.com/mattn/go-sqlite3 v1.14.24
13-
github.com/mdp/qrterminal/v3 v3.2.0
14+
github.com/mattn/go-sqlite3 v1.14.28
15+
github.com/mdp/qrterminal/v3 v3.2.1
1416
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
1517
github.com/watgbridge/tgsconverter v0.0.0-20240710075117-d1c05581b842
1618
github.com/watgbridge/webp v0.0.0-20240709143015-99fb5316f772
17-
go.mau.fi/whatsmeow v0.0.0-20250131212655-c3c6a06399a5
19+
go.mau.fi/whatsmeow v0.0.0-20250708133942-938c7dd5dc51
1820
go.uber.org/zap v1.27.0
19-
golang.org/x/exp v0.0.0-20250103183323-7d7fa50e5329
20-
google.golang.org/protobuf v1.36.4
21+
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b
22+
google.golang.org/protobuf v1.36.6
2123
gopkg.in/yaml.v3 v3.0.1
22-
gorm.io/driver/mysql v1.5.7
23-
gorm.io/driver/postgres v1.5.11
24-
gorm.io/driver/sqlite v1.5.7
25-
gorm.io/gorm v1.25.12
24+
gorm.io/driver/mysql v1.6.0
25+
gorm.io/driver/postgres v1.6.0
26+
gorm.io/driver/sqlite v1.6.0
27+
gorm.io/gorm v1.30.0
2628
)
2729

2830
require (
2931
filippo.io/edwards25519 v1.1.0 // indirect
3032
github.com/Benau/go_rlottie v0.0.0-20210807002906-98c1b2421989 // indirect
31-
github.com/av-elier/go-decimal-to-rational v0.0.0-20191127152832-89e6aad02ecf // indirect
32-
github.com/go-sql-driver/mysql v1.8.1 // indirect
33+
github.com/av-elier/go-decimal-to-rational v0.0.0-20250603203441-f39a07f43ff3 // indirect
34+
github.com/go-sql-driver/mysql v1.9.3 // indirect
3335
github.com/google/uuid v1.6.0 // indirect
3436
github.com/gorilla/websocket v1.5.3 // indirect
3537
github.com/jackc/pgpassfile v1.0.0 // indirect
@@ -40,18 +42,19 @@ require (
4042
github.com/kettek/apng v0.0.0-20220823221153-ff692776a607 // indirect
4143
github.com/mattn/go-colorable v0.1.14 // indirect
4244
github.com/mattn/go-isatty v0.0.20 // indirect
45+
github.com/petermattis/goid v0.0.0-20250508124226-395b08cebbdb // indirect
4346
github.com/rivo/uniseg v0.4.7 // indirect
4447
github.com/robfig/cron/v3 v3.0.1 // indirect
45-
github.com/rs/zerolog v1.33.0 // indirect
46-
go.mau.fi/libsignal v0.1.1 // indirect
47-
go.mau.fi/util v0.8.4 // indirect
48+
github.com/rs/zerolog v1.34.0 // indirect
49+
go.mau.fi/libsignal v0.2.0 // indirect
50+
go.mau.fi/util v0.8.8 // indirect
4851
go.uber.org/atomic v1.11.0 // indirect
4952
go.uber.org/multierr v1.11.0 // indirect
50-
golang.org/x/crypto v0.32.0 // indirect
51-
golang.org/x/net v0.34.0 // indirect
52-
golang.org/x/sync v0.10.0 // indirect
53-
golang.org/x/sys v0.29.0 // indirect
54-
golang.org/x/term v0.28.0 // indirect
55-
golang.org/x/text v0.21.0 // indirect
53+
golang.org/x/crypto v0.39.0 // indirect
54+
golang.org/x/net v0.41.0 // indirect
55+
golang.org/x/sync v0.15.0 // indirect
56+
golang.org/x/sys v0.33.0 // indirect
57+
golang.org/x/term v0.32.0 // indirect
58+
golang.org/x/text v0.26.0 // indirect
5659
rsc.io/qr v0.2.0 // indirect
5760
)

go.sum

Lines changed: 52 additions & 158 deletions
Large diffs are not rendered by default.

main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"context"
45
"errors"
56
"fmt"
67
"os"
@@ -191,7 +192,7 @@ func main() {
191192
s := gocron.NewScheduler(time.UTC)
192193
s.TagsUnique()
193194
_, _ = s.Every(1).Hour().Tag("foo").Do(func() {
194-
contacts, err := state.State.WhatsAppClient.Store.Contacts.GetAllContacts()
195+
contacts, err := state.State.WhatsAppClient.Store.Contacts.GetAllContacts(context.Background())
195196
if err == nil {
196197
_ = database.ContactNameBulkAddOrUpdate(contacts)
197198
}

state/config.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package state
33
import (
44
"fmt"
55
"io"
6+
"net/url"
67
"os"
78

89
"gopkg.in/yaml.v3"
@@ -97,6 +98,24 @@ func (cfg *Config) LoadConfig() error {
9798
return fmt.Errorf("could not parse config file : %s", err)
9899
}
99100

101+
whatsappLoginDB := cfg.WhatsApp.LoginDatabase
102+
if whatsappLoginDB.Type == "sqlite3" {
103+
parsedUrl, err := url.Parse(whatsappLoginDB.URL)
104+
if err != nil {
105+
return fmt.Errorf("whatsapp Login Database URL is not a valid URL")
106+
}
107+
if _, found := parsedUrl.Query()["_foreign_keys"]; !found {
108+
q := parsedUrl.Query()
109+
q.Set("_foreign_keys", "on")
110+
if q.Has("foreign_keys") {
111+
q.Del("foreign_keys")
112+
}
113+
parsedUrl.RawQuery = q.Encode()
114+
cfg.WhatsApp.LoginDatabase.URL = parsedUrl.String()
115+
cfg.SaveConfig()
116+
}
117+
}
118+
100119
return nil
101120
}
102121

telegram/handlers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,12 @@ func SyncContactsHandler(b *gotgbot.Bot, c *ext.Context) error {
375375

376376
waClient := state.State.WhatsAppClient
377377

378-
err := waClient.FetchAppState(appstate.WAPatchCriticalUnblockLow, false, false)
378+
err := waClient.FetchAppState(context.Background(), appstate.WAPatchCriticalUnblockLow, false, false)
379379
if err != nil {
380380
return utils.TgReplyWithErrorByContext(b, c, "Failed to sync contacts", err)
381381
}
382382

383-
contacts, err := waClient.Store.Contacts.GetAllContacts()
383+
contacts, err := waClient.Store.Contacts.GetAllContacts(context.Background())
384384
if err == nil {
385385
database.ContactNameBulkAddOrUpdate(contacts)
386386
}

utils/whatsapp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func WaGetContactName(jid types.JID) string {
126126
}
127127
} else {
128128
waClient := state.State.WhatsAppClient
129-
contact, err := waClient.Store.Contacts.GetContact(jid)
129+
contact, err := waClient.Store.Contacts.GetContact(context.Background(), jid)
130130
if err == nil && contact.Found {
131131
if contact.FullName != "" {
132132
name = contact.FullName

whatsapp/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ func NewWhatsAppClient() error {
8888
SupportCagReactionsAndPolls: proto.Bool(false),
8989
}
9090

91-
container, err := sqlstore.New(state.State.Config.WhatsApp.LoginDatabase.Type,
91+
container, err := sqlstore.New(context.Background(), state.State.Config.WhatsApp.LoginDatabase.Type,
9292
state.State.Config.WhatsApp.LoginDatabase.URL, waDatabaseLogger)
9393
if err != nil {
9494
return fmt.Errorf("could not initialize sqlstore for Whatsapp : %s", err)
9595
}
9696

97-
deviceStore, err := container.GetFirstDevice()
97+
deviceStore, err := container.GetFirstDevice(context.Background())
9898
if err != nil {
9999
return fmt.Errorf("could not initialize device store for Whatsapp : %s", err)
100100
}

whatsapp/handlers.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ func MessageFromOthersEventHandler(text string, v *events.Message, isEdited bool
475475
}
476476
return
477477
} else {
478-
imageBytes, err := waClient.Download(imageMsg)
478+
imageBytes, err := waClient.Download(context.Background(), imageMsg)
479479
if err != nil {
480480
bridgedText += "\n<i>Couldn't download the photo due to some errors</i>"
481481
sentMsg, _ := tgBot.SendMessage(cfg.Telegram.TargetChatID, bridgedText, &gotgbot.SendMessageOpts{
@@ -548,7 +548,7 @@ func MessageFromOthersEventHandler(text string, v *events.Message, isEdited bool
548548
}
549549
return
550550
} else {
551-
gifBytes, err := waClient.Download(gifMsg)
551+
gifBytes, err := waClient.Download(context.Background(), gifMsg)
552552
if err != nil {
553553
bridgedText += "\n<i>Couldn't download the GIF due to some errors</i>"
554554
sentMsg, _ := tgBot.SendMessage(cfg.Telegram.TargetChatID, bridgedText, &gotgbot.SendMessageOpts{
@@ -633,7 +633,7 @@ func MessageFromOthersEventHandler(text string, v *events.Message, isEdited bool
633633
}
634634
return
635635
} else {
636-
videoBytes, err := waClient.Download(videoMsg)
636+
videoBytes, err := waClient.Download(context.Background(), videoMsg)
637637
if err != nil {
638638
bridgedText += "\n<i>Couldn't download the video due to some errors</i>"
639639
sentMsg, _ := tgBot.SendMessage(cfg.Telegram.TargetChatID, bridgedText, &gotgbot.SendMessageOpts{
@@ -722,7 +722,7 @@ func MessageFromOthersEventHandler(text string, v *events.Message, isEdited bool
722722
}
723723
return
724724
} else {
725-
audioBytes, err := waClient.Download(audioMsg)
725+
audioBytes, err := waClient.Download(context.Background(), audioMsg)
726726
if err != nil {
727727
bridgedText += "\n<i>Couldn't download the audio due to some errors</i>"
728728
sentMsg, _ := tgBot.SendMessage(cfg.Telegram.TargetChatID, bridgedText, &gotgbot.SendMessageOpts{
@@ -792,7 +792,7 @@ func MessageFromOthersEventHandler(text string, v *events.Message, isEdited bool
792792
}
793793
return
794794
} else {
795-
audioBytes, err := waClient.Download(audioMsg)
795+
audioBytes, err := waClient.Download(context.Background(), audioMsg)
796796
if err != nil {
797797
bridgedText += "\n<i>Couldn't download the audio due to some errors</i>"
798798
sentMsg, _ := tgBot.SendMessage(cfg.Telegram.TargetChatID, bridgedText, &gotgbot.SendMessageOpts{
@@ -862,7 +862,7 @@ func MessageFromOthersEventHandler(text string, v *events.Message, isEdited bool
862862
}
863863
return
864864
} else {
865-
documentBytes, err := waClient.Download(documentMsg)
865+
documentBytes, err := waClient.Download(context.Background(), documentMsg)
866866
if err != nil {
867867
bridgedText += "\n<i>Couldn't download the document due to some errors</i>"
868868
sentMsg, _ := tgBot.SendMessage(cfg.Telegram.TargetChatID, bridgedText, &gotgbot.SendMessageOpts{
@@ -939,7 +939,7 @@ func MessageFromOthersEventHandler(text string, v *events.Message, isEdited bool
939939
}
940940
return
941941
} else {
942-
stickerBytes, err := waClient.Download(stickerMsg)
942+
stickerBytes, err := waClient.Download(context.Background(), stickerMsg)
943943
if err != nil {
944944
bridgedText += "\n<i>Couldn't download the sticker due to some errors</i>"
945945
sentMsg, _ := tgBot.SendMessage(cfg.Telegram.TargetChatID, bridgedText, &gotgbot.SendMessageOpts{

0 commit comments

Comments
 (0)