summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/Rhymen/go-whatsapp/contact.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2021-02-01 21:29:04 +0100
committerGitHub <noreply@github.com>2021-02-01 21:29:04 +0100
commit0452be0cb383ff560e340b643b60a35c6e228639 (patch)
tree41b91af43c2e321d6498a6b56594b1d0c71c516e /vendor/github.com/Rhymen/go-whatsapp/contact.go
parent1624f107739b8ed7b142732430e5295764388de2 (diff)
downloadmatterbridge-msglm-0452be0cb383ff560e340b643b60a35c6e228639.tar.gz
matterbridge-msglm-0452be0cb383ff560e340b643b60a35c6e228639.tar.bz2
matterbridge-msglm-0452be0cb383ff560e340b643b60a35c6e228639.zip
Update vendor (#1384)
Diffstat (limited to 'vendor/github.com/Rhymen/go-whatsapp/contact.go')
-rw-r--r--vendor/github.com/Rhymen/go-whatsapp/contact.go47
1 files changed, 46 insertions, 1 deletions
diff --git a/vendor/github.com/Rhymen/go-whatsapp/contact.go b/vendor/github.com/Rhymen/go-whatsapp/contact.go
index 92d0a4ad..e17f724f 100644
--- a/vendor/github.com/Rhymen/go-whatsapp/contact.go
+++ b/vendor/github.com/Rhymen/go-whatsapp/contact.go
@@ -2,9 +2,11 @@ package whatsapp
import (
"fmt"
- "github.com/Rhymen/go-whatsapp/binary"
"strconv"
+ "strings"
"time"
+
+ "github.com/Rhymen/go-whatsapp/binary"
)
type Presence string
@@ -241,3 +243,46 @@ func buildParticipantNodes(participants []string) []binary.Node {
}
return p
}
+
+func (wac *Conn) BlockContact(jid string) (<-chan string, error) {
+ return wac.handleBlockContact("add", jid)
+}
+
+func (wac *Conn) UnblockContact(jid string) (<-chan string, error) {
+ return wac.handleBlockContact("remove", jid)
+}
+
+func (wac *Conn) handleBlockContact(action, jid string) (<-chan string, error) {
+ ts := time.Now().Unix()
+ tag := fmt.Sprintf("%d.--%d", ts, wac.msgCount)
+
+ netsplit := strings.Split(jid, "@")
+ cusjid := netsplit[0] + "@c.us"
+
+ n := binary.Node{
+ Description: "action",
+ Attributes: map[string]string{
+ "type": "set",
+ "epoch": strconv.Itoa(wac.msgCount),
+ },
+ Content: []interface{}{
+ binary.Node{
+ Description: "block",
+ Attributes: map[string]string{
+ "type": action,
+ },
+ Content: []binary.Node{
+ {
+ Description: "user",
+ Attributes: map[string]string{
+ "jid": cusjid,
+ },
+ Content: nil,
+ },
+ },
+ },
+ },
+ }
+
+ return wac.writeBinary(n, contact, ignore, tag)
+}