summaryrefslogtreecommitdiffstats
path: root/vendor/go.mau.fi/whatsmeow/receipt.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/receipt.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/receipt.go')
-rw-r--r--vendor/go.mau.fi/whatsmeow/receipt.go28
1 files changed, 27 insertions, 1 deletions
diff --git a/vendor/go.mau.fi/whatsmeow/receipt.go b/vendor/go.mau.fi/whatsmeow/receipt.go
index dec03c5d..0f74926b 100644
--- a/vendor/go.mau.fi/whatsmeow/receipt.go
+++ b/vendor/go.mau.fi/whatsmeow/receipt.go
@@ -8,6 +8,7 @@ package whatsmeow
import (
"fmt"
+ "sync/atomic"
"time"
waBinary "go.mau.fi/whatsmeow/binary"
@@ -123,13 +124,35 @@ func (cli *Client) MarkRead(ids []types.MessageID, timestamp time.Time, chat, se
return cli.sendNode(node)
}
+// SetForceActiveDeliveryReceipts will force the client to send normal delivery
+// receipts (which will show up as the two gray ticks on WhatsApp), even if the
+// client isn't marked as online.
+//
+// By default, clients that haven't been marked as online will send delivery
+// receipts with type="inactive", which is transmitted to the sender, but not
+// rendered in the official WhatsApp apps. This is consistent with how WhatsApp
+// web works when it's not in the foreground.
+//
+// To mark the client as online, use
+// cli.SendPresence(types.PresenceAvailable)
+//
+// Note that if you turn this off (i.e. call SetForceActiveDeliveryReceipts(false)),
+// receipts will act like the client is offline until SendPresence is called again.
+func (cli *Client) SetForceActiveDeliveryReceipts(active bool) {
+ if active {
+ atomic.StoreUint32(&cli.sendActiveReceipts, 2)
+ } else {
+ atomic.StoreUint32(&cli.sendActiveReceipts, 0)
+ }
+}
+
func (cli *Client) sendMessageReceipt(info *types.MessageInfo) {
attrs := waBinary.Attrs{
"id": info.ID,
}
if info.IsFromMe {
attrs["type"] = "sender"
- } else {
+ } else if atomic.LoadUint32(&cli.sendActiveReceipts) == 0 {
attrs["type"] = "inactive"
}
attrs["to"] = info.Chat
@@ -137,6 +160,9 @@ func (cli *Client) sendMessageReceipt(info *types.MessageInfo) {
attrs["participant"] = info.Sender
} else if info.IsFromMe {
attrs["recipient"] = info.Sender
+ } else {
+ // Override the to attribute with the JID version with a device number
+ attrs["to"] = info.Sender
}
err := cli.sendNode(waBinary.Node{
Tag: "receipt",