4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-09-11 01:52:30 +00:00

Update vendor (#1384)

This commit is contained in:
Wim
2021-02-01 21:29:04 +01:00
committed by GitHub
parent 1624f10773
commit 0452be0cb3
37 changed files with 1539 additions and 244 deletions

View File

@@ -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)
}