summaryrefslogtreecommitdiffstats
path: root/vendor/go.mau.fi/whatsmeow/receipt.go
diff options
context:
space:
mode:
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",