summaryrefslogtreecommitdiffstats
path: root/bridge/whatsapp/helpers.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2019-06-01 00:53:49 +0200
committerWim <wim@42.be>2019-06-02 09:35:20 +0100
commit40f1d35415f5e3638a1972b4aa56365070d5ccb3 (patch)
treee7ec1cd0638436c61367448736f94e7fc0793a1e /bridge/whatsapp/helpers.go
parentb79bf7d4143f7a962faa00e10c2d6705524607ee (diff)
downloadmatterbridge-msglm-40f1d35415f5e3638a1972b4aa56365070d5ccb3.tar.gz
matterbridge-msglm-40f1d35415f5e3638a1972b4aa56365070d5ccb3.tar.bz2
matterbridge-msglm-40f1d35415f5e3638a1972b4aa56365070d5ccb3.zip
Fix go mod issue by removing whatsapp-ext
Diffstat (limited to 'bridge/whatsapp/helpers.go')
-rw-r--r--bridge/whatsapp/helpers.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/bridge/whatsapp/helpers.go b/bridge/whatsapp/helpers.go
index 5268ba3e..f45d6246 100644
--- a/bridge/whatsapp/helpers.go
+++ b/bridge/whatsapp/helpers.go
@@ -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
+}