mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-06-26 13:09:24 +00:00
Fix go mod issue by removing whatsapp-ext
This commit is contained in:
@ -5,10 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/42wim/matterbridge/bridge/config"
|
||||
|
||||
"github.com/Rhymen/go-whatsapp"
|
||||
|
||||
whatsappExt "maunium.net/go/mautrix-whatsapp/whatsapp-ext"
|
||||
)
|
||||
|
||||
/*
|
||||
@ -57,7 +54,7 @@ func (b *Bwhatsapp) HandleTextMessage(message whatsapp.TextMessage) {
|
||||
|
||||
// mentions comes as telephone numbers and we don't want to expose it to other bridges
|
||||
// replace it with something more meaninful to others
|
||||
mention := b.getSenderNotify(numberAndSuffix[0] + whatsappExt.NewUserSuffix)
|
||||
mention := b.getSenderNotify(numberAndSuffix[0] + "@s.whatsapp.net")
|
||||
if mention == "" {
|
||||
mention = "someone"
|
||||
}
|
||||
|
@ -2,13 +2,22 @@ package bwhatsapp
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
qrcodeTerminal "github.com/Baozisoftware/qrcode-terminal-go"
|
||||
"github.com/Rhymen/go-whatsapp"
|
||||
)
|
||||
|
||||
type ProfilePicInfo struct {
|
||||
URL string `json:"eurl"`
|
||||
Tag string `json:"tag"`
|
||||
|
||||
Status int16 `json:"status"`
|
||||
}
|
||||
|
||||
func qrFromTerminal(invert bool) chan string {
|
||||
qr := make(chan string)
|
||||
go func() {
|
||||
@ -82,3 +91,17 @@ func (b *Bwhatsapp) getSenderNotify(senderJid string) string {
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (b *Bwhatsapp) GetProfilePicThumb(jid string) (*ProfilePicInfo, error) {
|
||||
data, err := b.conn.GetProfilePicThumb(jid)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get avatar: %v", err)
|
||||
}
|
||||
content := <-data
|
||||
info := &ProfilePicInfo{}
|
||||
err = json.Unmarshal([]byte(content), info)
|
||||
if err != nil {
|
||||
return info, fmt.Errorf("failed to unmarshal avatar info: %v", err)
|
||||
}
|
||||
return info, nil
|
||||
}
|
||||
|
@ -12,8 +12,6 @@ import (
|
||||
"github.com/42wim/matterbridge/bridge"
|
||||
"github.com/42wim/matterbridge/bridge/config"
|
||||
"github.com/Rhymen/go-whatsapp"
|
||||
|
||||
whatsappExt "maunium.net/go/mautrix-whatsapp/whatsapp-ext"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -28,10 +26,8 @@ type Bwhatsapp struct {
|
||||
*bridge.Config
|
||||
|
||||
// https://github.com/Rhymen/go-whatsapp/blob/c31092027237441cffba1b9cb148eadf7c83c3d2/session.go#L18-L21
|
||||
session *whatsapp.Session
|
||||
conn *whatsapp.Conn
|
||||
// https://github.com/tulir/mautrix-whatsapp/blob/master/whatsapp-ext/whatsapp.go
|
||||
connExt *whatsappExt.ExtendedConn
|
||||
session *whatsapp.Session
|
||||
conn *whatsapp.Conn
|
||||
startedAt uint64
|
||||
|
||||
users map[string]whatsapp.Contact
|
||||
@ -73,8 +69,6 @@ func (b *Bwhatsapp) Connect() error {
|
||||
}
|
||||
|
||||
b.conn = conn
|
||||
b.connExt = whatsappExt.ExtendConn(b.conn)
|
||||
// TODO do we want to use it? b.connExt.SetClientName("Matterbridge WhatsApp bridge", "mb-wa")
|
||||
|
||||
b.conn.AddHandler(b)
|
||||
b.Log.Debugln("WhatsApp connection successful")
|
||||
@ -129,7 +123,7 @@ func (b *Bwhatsapp) Connect() error {
|
||||
b.Log.Debug("Getting user avatars..")
|
||||
|
||||
for jid := range b.users {
|
||||
info, err := b.connExt.GetProfilePicThumb(jid)
|
||||
info, err := b.GetProfilePicThumb(jid)
|
||||
if err != nil {
|
||||
b.Log.Warnf("Could not get profile photo of %s: %v", jid, err)
|
||||
|
||||
|
Reference in New Issue
Block a user