summaryrefslogtreecommitdiffstats
path: root/vendor/go.mau.fi/whatsmeow/presence.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2022-03-12 23:02:04 +0100
committerWim <wim@42.be>2022-03-20 14:57:48 +0100
commitaefa70891cfd489fccb8a9567b5bdafb0f863ede (patch)
tree90fe7c91d7b33b2a1ed08ea3a94840860adc6fc1 /vendor/go.mau.fi/whatsmeow/presence.go
parent1b9877fda45be021ea6a5677c78648cecc19dcd5 (diff)
downloadmatterbridge-msglm-aefa70891cfd489fccb8a9567b5bdafb0f863ede.tar.gz
matterbridge-msglm-aefa70891cfd489fccb8a9567b5bdafb0f863ede.tar.bz2
matterbridge-msglm-aefa70891cfd489fccb8a9567b5bdafb0f863ede.zip
Update vendor (whatsapp)
Diffstat (limited to 'vendor/go.mau.fi/whatsmeow/presence.go')
-rw-r--r--vendor/go.mau.fi/whatsmeow/presence.go22
1 files changed, 19 insertions, 3 deletions
diff --git a/vendor/go.mau.fi/whatsmeow/presence.go b/vendor/go.mau.fi/whatsmeow/presence.go
index e308717b..8de1969a 100644
--- a/vendor/go.mau.fi/whatsmeow/presence.go
+++ b/vendor/go.mau.fi/whatsmeow/presence.go
@@ -7,6 +7,7 @@
package whatsmeow
import (
+ "sync/atomic"
"time"
waBinary "go.mau.fi/whatsmeow/binary"
@@ -23,12 +24,14 @@ func (cli *Client) handleChatState(node *waBinary.Node) {
} else {
child := node.GetChildren()[0]
presence := types.ChatPresence(child.Tag)
- if presence != types.ChatPresenceComposing && presence != types.ChatPresenceRecording && presence != types.ChatPresencePaused {
+ if presence != types.ChatPresenceComposing && presence != types.ChatPresencePaused {
cli.Log.Warnf("Unrecognized chat presence state %s", child.Tag)
}
+ media := types.ChatPresenceMedia(child.AttrGetter().OptionalString("media"))
cli.dispatchEvent(&events.ChatPresence{
MessageSource: source,
State: presence,
+ Media: media,
})
}
}
@@ -62,6 +65,11 @@ func (cli *Client) SendPresence(state types.Presence) error {
if len(cli.Store.PushName) == 0 {
return ErrNoPushName
}
+ if state == types.PresenceAvailable {
+ atomic.CompareAndSwapUint32(&cli.sendActiveReceipts, 0, 1)
+ } else {
+ atomic.CompareAndSwapUint32(&cli.sendActiveReceipts, 1, 0)
+ }
return cli.sendNode(waBinary.Node{
Tag: "presence",
Attrs: waBinary.Attrs{
@@ -89,13 +97,21 @@ func (cli *Client) SubscribePresence(jid types.JID) error {
}
// SendChatPresence updates the user's typing status in a specific chat.
-func (cli *Client) SendChatPresence(state types.ChatPresence, jid types.JID) error {
+//
+// The media parameter can be set to indicate the user is recording media (like a voice message) rather than typing a text message.
+func (cli *Client) SendChatPresence(jid types.JID, state types.ChatPresence, media types.ChatPresenceMedia) error {
+ content := []waBinary.Node{{Tag: string(state)}}
+ if state == types.ChatPresenceComposing && len(media) > 0 {
+ content[0].Attrs = waBinary.Attrs{
+ "media": string(media),
+ }
+ }
return cli.sendNode(waBinary.Node{
Tag: "chatstate",
Attrs: waBinary.Attrs{
"from": *cli.Store.ID,
"to": jid,
},
- Content: []waBinary.Node{{Tag: string(state)}},
+ Content: content,
})
}