mirror of
https://github.com/42wim/matterbridge.git
synced 2025-09-11 13:25:09 -04:00
Updated to whatsmeow commit 0b502af
This commit is contained in:
parent
89b0fa90cd
commit
1fb3ba8723
@ -4,6 +4,7 @@
|
|||||||
package bwhatsapp
|
package bwhatsapp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"mime"
|
"mime"
|
||||||
"strings"
|
"strings"
|
||||||
@ -242,7 +243,8 @@ func (b *Bwhatsapp) handleImageMessage(msg *events.Message) {
|
|||||||
|
|
||||||
b.Log.Debugf("Trying to download %s with type %s", filename, imsg.GetMimetype())
|
b.Log.Debugf("Trying to download %s with type %s", filename, imsg.GetMimetype())
|
||||||
|
|
||||||
data, err := b.wc.Download(imsg)
|
// Fix: Add context.Background() as first parameter
|
||||||
|
data, err := b.wc.Download(context.Background(), imsg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Log.Errorf("Download image failed: %s", err)
|
b.Log.Errorf("Download image failed: %s", err)
|
||||||
|
|
||||||
@ -309,7 +311,8 @@ func (b *Bwhatsapp) handleVideoMessage(msg *events.Message) {
|
|||||||
|
|
||||||
b.Log.Debugf("Trying to download %s with size %#v and type %s", filename, imsg.GetFileLength(), imsg.GetMimetype())
|
b.Log.Debugf("Trying to download %s with size %#v and type %s", filename, imsg.GetFileLength(), imsg.GetMimetype())
|
||||||
|
|
||||||
data, err := b.wc.Download(imsg)
|
// Fix: Add context.Background() as first parameter
|
||||||
|
data, err := b.wc.Download(context.Background(), imsg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Log.Errorf("Download video failed: %s", err)
|
b.Log.Errorf("Download video failed: %s", err)
|
||||||
|
|
||||||
@ -366,7 +369,8 @@ func (b *Bwhatsapp) handleAudioMessage(msg *events.Message) {
|
|||||||
|
|
||||||
b.Log.Debugf("Trying to download %s with size %#v and type %s", filename, imsg.GetFileLength(), imsg.GetMimetype())
|
b.Log.Debugf("Trying to download %s with size %#v and type %s", filename, imsg.GetFileLength(), imsg.GetMimetype())
|
||||||
|
|
||||||
data, err := b.wc.Download(imsg)
|
// Fix: Add context.Background() as first parameter
|
||||||
|
data, err := b.wc.Download(context.Background(), imsg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Log.Errorf("Download video failed: %s", err)
|
b.Log.Errorf("Download video failed: %s", err)
|
||||||
|
|
||||||
@ -420,7 +424,8 @@ func (b *Bwhatsapp) handleDocumentMessage(msg *events.Message) {
|
|||||||
|
|
||||||
b.Log.Debugf("Trying to download %s with extension %s and type %s", filename, fileExt, imsg.GetMimetype())
|
b.Log.Debugf("Trying to download %s with extension %s and type %s", filename, fileExt, imsg.GetMimetype())
|
||||||
|
|
||||||
data, err := b.wc.Download(imsg)
|
// Fix: Add context.Background() as first parameter
|
||||||
|
data, err := b.wc.Download(context.Background(), imsg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Log.Errorf("Download document message failed: %s", err)
|
b.Log.Errorf("Download document message failed: %s", err)
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
package bwhatsapp
|
package bwhatsapp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -14,6 +15,7 @@ import (
|
|||||||
"go.mau.fi/whatsmeow/store"
|
"go.mau.fi/whatsmeow/store"
|
||||||
"go.mau.fi/whatsmeow/store/sqlstore"
|
"go.mau.fi/whatsmeow/store/sqlstore"
|
||||||
"go.mau.fi/whatsmeow/types"
|
"go.mau.fi/whatsmeow/types"
|
||||||
|
waLog "go.mau.fi/whatsmeow/util/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ProfilePicInfo struct {
|
type ProfilePicInfo struct {
|
||||||
@ -23,11 +25,13 @@ type ProfilePicInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bwhatsapp) reloadContacts() {
|
func (b *Bwhatsapp) reloadContacts() {
|
||||||
if _, err := b.wc.Store.Contacts.GetAllContacts(); err != nil {
|
// Fix: Add context.Background() as first parameter
|
||||||
|
if _, err := b.wc.Store.Contacts.GetAllContacts(context.Background()); err != nil {
|
||||||
b.Log.Errorf("error on update of contacts: %v", err)
|
b.Log.Errorf("error on update of contacts: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
allcontacts, err := b.wc.Store.Contacts.GetAllContacts()
|
// Fix: Add context.Background() as first parameter
|
||||||
|
allcontacts, err := b.wc.Store.Contacts.GetAllContacts(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Log.Errorf("error on update of contacts: %v", err)
|
b.Log.Errorf("error on update of contacts: %v", err)
|
||||||
}
|
}
|
||||||
@ -134,18 +138,20 @@ func isGroupJid(identifier string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func isPrivateJid(identifier string) bool {
|
func isPrivateJid(identifier string) bool {
|
||||||
return strings.HasSuffix(identifier, "@s.whatsapp.net")
|
return strings.HasSuffix(identifier, "@s.whatsapp.net")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bwhatsapp) getDevice() (*store.Device, error) {
|
func (b *Bwhatsapp) getDevice() (*store.Device, error) {
|
||||||
device := &store.Device{}
|
device := &store.Device{}
|
||||||
|
|
||||||
storeContainer, err := sqlstore.New("sqlite", "file:"+b.Config.GetString("sessionfile")+".db?_pragma=foreign_keys(1)&_pragma=busy_timeout=10000", nil)
|
// Fix: Add context.Background() as first parameter and waLog.Noop logger
|
||||||
|
storeContainer, err := sqlstore.New(context.Background(), "sqlite", "file:"+b.Config.GetString("sessionfile")+".db?_pragma=foreign_keys(1)&_pragma=busy_timeout=10000", waLog.Noop)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return device, fmt.Errorf("failed to connect to database: %v", err)
|
return device, fmt.Errorf("failed to connect to database: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
device, err = storeContainer.GetFirstDevice()
|
// Fix: Add context.Background() as first parameter
|
||||||
|
device, err = storeContainer.GetFirstDevice(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return device, fmt.Errorf("failed to get device: %v", err)
|
return device, fmt.Errorf("failed to get device: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,8 @@ func (b *Bwhatsapp) Connect() error {
|
|||||||
|
|
||||||
b.Log.Infoln("WhatsApp connection successful")
|
b.Log.Infoln("WhatsApp connection successful")
|
||||||
|
|
||||||
b.contacts, err = b.wc.Store.Contacts.GetAllContacts()
|
// Fix: Add context.Background() as first parameter
|
||||||
|
b.contacts, err = b.wc.Store.Contacts.GetAllContacts(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("failed to get contacts: " + err.Error())
|
return errors.New("failed to get contacts: " + err.Error())
|
||||||
}
|
}
|
||||||
@ -176,7 +177,6 @@ func (b *Bwhatsapp) Disconnect() error {
|
|||||||
// Required implementation of the Bridger interface
|
// Required implementation of the Bridger interface
|
||||||
// https://github.com/42wim/matterbridge/blob/2cfd880cdb0df29771bf8f31df8d990ab897889d/bridge/bridge.go#L11-L16
|
// https://github.com/42wim/matterbridge/blob/2cfd880cdb0df29771bf8f31df8d990ab897889d/bridge/bridge.go#L11-L16
|
||||||
func (b *Bwhatsapp) JoinChannel(channel config.ChannelInfo) error {
|
func (b *Bwhatsapp) JoinChannel(channel config.ChannelInfo) error {
|
||||||
|
|
||||||
// Check if this is a private chat JID
|
// Check if this is a private chat JID
|
||||||
if isPrivateJid(channel.Name) {
|
if isPrivateJid(channel.Name) {
|
||||||
// For private chats, validate the JID format but don't require group membership
|
// For private chats, validate the JID format but don't require group membership
|
||||||
|
2
go.mod
2
go.mod
@ -46,7 +46,7 @@ require (
|
|||||||
github.com/writeas/go-strip-markdown v2.0.1+incompatible
|
github.com/writeas/go-strip-markdown v2.0.1+incompatible
|
||||||
github.com/yaegashi/msgraph.go v0.1.4
|
github.com/yaegashi/msgraph.go v0.1.4
|
||||||
github.com/zfjagann/golang-ring v0.0.0-20220330170733-19bcea1b6289
|
github.com/zfjagann/golang-ring v0.0.0-20220330170733-19bcea1b6289
|
||||||
go.mau.fi/whatsmeow v0.0.0-20240821142752-3d63c6fcc1a7
|
go.mau.fi/whatsmeow v0.0.0-20250527134344-0b502af800ee
|
||||||
golang.org/x/image v0.19.0
|
golang.org/x/image v0.19.0
|
||||||
golang.org/x/oauth2 v0.22.0
|
golang.org/x/oauth2 v0.22.0
|
||||||
golang.org/x/text v0.17.0
|
golang.org/x/text v0.17.0
|
||||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -490,7 +490,7 @@ go.mau.fi/libsignal/util/optional
|
|||||||
go.mau.fi/util/jsontime
|
go.mau.fi/util/jsontime
|
||||||
go.mau.fi/util/random
|
go.mau.fi/util/random
|
||||||
go.mau.fi/util/retryafter
|
go.mau.fi/util/retryafter
|
||||||
# go.mau.fi/whatsmeow v0.0.0-20240821142752-3d63c6fcc1a7
|
# go.mau.fi/whatsmeow v0.0.0-20250527134344-0b502af800ee
|
||||||
## explicit; go 1.21
|
## explicit; go 1.21
|
||||||
go.mau.fi/whatsmeow
|
go.mau.fi/whatsmeow
|
||||||
go.mau.fi/whatsmeow/appstate
|
go.mau.fi/whatsmeow/appstate
|
||||||
|
Loading…
x
Reference in New Issue
Block a user