slidge-whatsapp 0.2.6__cp312-cp312-manylinux_2_36_aarch64.whl → 0.2.7__cp312-cp312-manylinux_2_36_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of slidge-whatsapp might be problematic. Click here for more details.
- slidge_whatsapp/event.go +8 -2
- slidge_whatsapp/generated/_whatsapp.cpython-312-aarch64-linux-gnu.h +164 -164
- slidge_whatsapp/generated/_whatsapp.cpython-312-aarch64-linux-gnu.so +0 -0
- slidge_whatsapp/generated/build.py +130 -130
- slidge_whatsapp/generated/whatsapp.c +1504 -1504
- slidge_whatsapp/generated/whatsapp.go +1021 -1021
- slidge_whatsapp/generated/whatsapp.py +1209 -1209
- slidge_whatsapp/generated/whatsapp_go.h +164 -164
- slidge_whatsapp/go.mod +6 -6
- slidge_whatsapp/go.sum +12 -18
- slidge_whatsapp/media/media.go +5 -1
- slidge_whatsapp/vendor/go.mau.fi/util/exhttp/json.go +1 -6
- slidge_whatsapp/vendor/go.mau.fi/util/exstrings/stringutil.go +76 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/armadillomessage.go +38 -6
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/binary/encoder.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/call.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/client.go +64 -27
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/connectionevents.go +8 -6
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/download-to-file.go +19 -12
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/download.go +22 -6
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/group.go +2 -2
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/internals.go +33 -17
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/keepalive.go +1 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/message.go +198 -48
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/notification.go +12 -7
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/extra.go +7 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloAddMessage/InstamadilloAddMessage.pb.go +983 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloAddMessage/InstamadilloAddMessage.proto +85 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloAddMessage/extra.go +3 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeActionLog/InstamadilloCoreTypeActionLog.pb.go +197 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeActionLog/InstamadilloCoreTypeActionLog.proto +13 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeAdminMessage/InstamadilloCoreTypeAdminMessage.pb.go +279 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeAdminMessage/InstamadilloCoreTypeAdminMessage.proto +21 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeCollection/InstamadilloCoreTypeCollection.pb.go +137 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeCollection/InstamadilloCoreTypeCollection.proto +10 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeLink/InstamadilloCoreTypeLink.pb.go +313 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeLink/InstamadilloCoreTypeLink.proto +27 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeMedia/InstamadilloCoreTypeMedia.pb.go +1299 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeMedia/InstamadilloCoreTypeMedia.proto +112 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeText/InstamadilloCoreTypeText.pb.go +514 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeText/InstamadilloCoreTypeText.proto +47 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloDeleteMessage/InstamadilloDeleteMessage.pb.go +123 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloDeleteMessage/InstamadilloDeleteMessage.proto +7 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloDeleteMessage/extra.go +3 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloSupplementMessage/InstamadilloSupplementMessage.pb.go +720 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloSupplementMessage/InstamadilloSupplementMessage.proto +59 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloSupplementMessage/extra.go +3 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloTransportPayload/InstamadilloTransportPayload.pb.go +365 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloTransportPayload/InstamadilloTransportPayload.proto +33 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloXmaContentRef/InstamadilloXmaContentRef.pb.go +1238 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloXmaContentRef/InstamadilloXmaContentRef.proto +105 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waArmadilloXMA/WAArmadilloXMA.pb.go +16 -4
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waArmadilloXMA/WAArmadilloXMA.proto +3 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCompanionReg/WACompanionReg.pb.go +16 -7
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCompanionReg/WACompanionReg.proto +1 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.pb.go +2436 -1676
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.proto +85 -7
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waLidMigrationSyncPayload/WAWebProtobufLidMigrationSyncPayload.pb.go +198 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waLidMigrationSyncPayload/WAWebProtobufLidMigrationSyncPayload.proto +14 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMsgTransport/extra.go +7 -6
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.pb.go +800 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.proto +72 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.pb.go +678 -441
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.proto +20 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWeb/WAWebProtobufsWeb.pb.go +11 -3
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWeb/WAWebProtobufsWeb.proto +2 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/receipt.go +13 -7
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/reportingfields.json +1 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/reportingtoken.go +176 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/retry.go +10 -2
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/send.go +32 -17
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/sendfb.go +1 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/clientpayload.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/container.go +9 -6
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrades/00-latest-schema.sql +4 -2
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrades/10-chat-db-lid-migration-ts.sql +2 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/store.go +2 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/events/events.go +5 -2
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/message.go +1 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/user.go +2 -0
- slidge_whatsapp/vendor/golang.org/x/net/http2/frame.go +8 -8
- slidge_whatsapp/vendor/modules.txt +20 -6
- {slidge_whatsapp-0.2.6.dist-info → slidge_whatsapp-0.2.7.dist-info}/METADATA +1 -1
- {slidge_whatsapp-0.2.6.dist-info → slidge_whatsapp-0.2.7.dist-info}/RECORD +87 -54
- {slidge_whatsapp-0.2.6.dist-info → slidge_whatsapp-0.2.7.dist-info}/LICENSE +0 -0
- {slidge_whatsapp-0.2.6.dist-info → slidge_whatsapp-0.2.7.dist-info}/WHEEL +0 -0
- {slidge_whatsapp-0.2.6.dist-info → slidge_whatsapp-0.2.7.dist-info}/entry_points.txt +0 -0
|
@@ -16,6 +16,7 @@ import (
|
|
|
16
16
|
"fmt"
|
|
17
17
|
"io"
|
|
18
18
|
"runtime/debug"
|
|
19
|
+
"strconv"
|
|
19
20
|
"time"
|
|
20
21
|
|
|
21
22
|
"github.com/rs/zerolog"
|
|
@@ -30,6 +31,7 @@ import (
|
|
|
30
31
|
waBinary "go.mau.fi/whatsmeow/binary"
|
|
31
32
|
"go.mau.fi/whatsmeow/proto/waE2E"
|
|
32
33
|
"go.mau.fi/whatsmeow/proto/waHistorySync"
|
|
34
|
+
"go.mau.fi/whatsmeow/proto/waLidMigrationSyncPayload"
|
|
33
35
|
"go.mau.fi/whatsmeow/proto/waWeb"
|
|
34
36
|
"go.mau.fi/whatsmeow/store"
|
|
35
37
|
"go.mau.fi/whatsmeow/types"
|
|
@@ -39,7 +41,7 @@ import (
|
|
|
39
41
|
var pbSerializer = store.SignalProtobufSerializer
|
|
40
42
|
|
|
41
43
|
func (cli *Client) handleEncryptedMessage(node *waBinary.Node) {
|
|
42
|
-
ctx :=
|
|
44
|
+
ctx := cli.BackgroundEventCtx
|
|
43
45
|
info, err := cli.parseMessageInfo(node)
|
|
44
46
|
if err != nil {
|
|
45
47
|
cli.Log.Warnf("Failed to parse message: %v", err)
|
|
@@ -50,16 +52,17 @@ func (cli *Client) handleEncryptedMessage(node *waBinary.Node) {
|
|
|
50
52
|
cli.StoreLIDPNMapping(ctx, info.RecipientAlt, info.Chat)
|
|
51
53
|
}
|
|
52
54
|
if info.VerifiedName != nil && len(info.VerifiedName.Details.GetVerifiedName()) > 0 {
|
|
53
|
-
go cli.updateBusinessName(
|
|
55
|
+
go cli.updateBusinessName(cli.BackgroundEventCtx, info.Sender, info, info.VerifiedName.Details.GetVerifiedName())
|
|
54
56
|
}
|
|
55
|
-
if len(info.PushName) > 0 && info.PushName != "-" {
|
|
56
|
-
go cli.updatePushName(
|
|
57
|
+
if len(info.PushName) > 0 && info.PushName != "-" && (cli.MessengerConfig == nil || info.PushName != "username") {
|
|
58
|
+
go cli.updatePushName(cli.BackgroundEventCtx, info.Sender, info, info.PushName)
|
|
57
59
|
}
|
|
58
|
-
|
|
60
|
+
var cancelled bool
|
|
61
|
+
defer cli.maybeDeferredAck(ctx, node)(&cancelled)
|
|
59
62
|
if info.Sender.Server == types.NewsletterServer {
|
|
60
|
-
cli.handlePlaintextMessage(ctx, info, node)
|
|
63
|
+
cancelled = cli.handlePlaintextMessage(ctx, info, node)
|
|
61
64
|
} else {
|
|
62
|
-
cli.decryptMessages(ctx, info, node)
|
|
65
|
+
cancelled = cli.decryptMessages(ctx, info, node)
|
|
63
66
|
}
|
|
64
67
|
}
|
|
65
68
|
}
|
|
@@ -106,8 +109,8 @@ func (cli *Client) parseMessageSource(node *waBinary.Node, requireParticipant bo
|
|
|
106
109
|
} else {
|
|
107
110
|
source.Chat = from.ToNonAD()
|
|
108
111
|
}
|
|
109
|
-
if source.
|
|
110
|
-
source.RecipientAlt = ag.OptionalJIDOrEmpty("peer_recipient_pn")
|
|
112
|
+
if source.Chat.Server == types.HiddenUserServer {
|
|
113
|
+
source.RecipientAlt = ag.OptionalJIDOrEmpty("peer_recipient_pn")
|
|
111
114
|
} else {
|
|
112
115
|
source.RecipientAlt = ag.OptionalJIDOrEmpty("peer_recipient_lid")
|
|
113
116
|
}
|
|
@@ -124,7 +127,7 @@ func (cli *Client) parseMessageSource(node *waBinary.Node, requireParticipant bo
|
|
|
124
127
|
} else {
|
|
125
128
|
source.Chat = from.ToNonAD()
|
|
126
129
|
source.Sender = from
|
|
127
|
-
if source.
|
|
130
|
+
if source.Sender.Server == types.HiddenUserServer {
|
|
128
131
|
source.SenderAlt = ag.OptionalJIDOrEmpty("sender_pn")
|
|
129
132
|
} else {
|
|
130
133
|
source.SenderAlt = ag.OptionalJIDOrEmpty("sender_lid")
|
|
@@ -156,6 +159,7 @@ func (cli *Client) parseMsgMetaInfo(node waBinary.Node) (metaInfo types.MsgMetaI
|
|
|
156
159
|
ag := metaNode.AttrGetter()
|
|
157
160
|
metaInfo.TargetID = types.MessageID(ag.OptionalString("target_id"))
|
|
158
161
|
metaInfo.TargetSender = ag.OptionalJIDOrEmpty("target_sender_jid")
|
|
162
|
+
metaInfo.TargetChat = ag.OptionalJIDOrEmpty("target_chat_jid")
|
|
159
163
|
deprecatedLIDSession, ok := ag.GetBool("deprecated_lid_session", false)
|
|
160
164
|
if ok {
|
|
161
165
|
metaInfo.DeprecatedLIDSession = &deprecatedLIDSession
|
|
@@ -218,7 +222,7 @@ func (cli *Client) parseMessageInfo(node *waBinary.Node) (*types.MessageInfo, er
|
|
|
218
222
|
return &info, nil
|
|
219
223
|
}
|
|
220
224
|
|
|
221
|
-
func (cli *Client) handlePlaintextMessage(ctx context.Context, info *types.MessageInfo, node *waBinary.Node) {
|
|
225
|
+
func (cli *Client) handlePlaintextMessage(ctx context.Context, info *types.MessageInfo, node *waBinary.Node) (handlerFailed bool) {
|
|
222
226
|
// TODO edits have an additional <meta msg_edit_t="1696321271735" original_msg_t="1696321248"/> node
|
|
223
227
|
plaintext, ok := node.GetOptionalChildByTag("plaintext")
|
|
224
228
|
if !ok {
|
|
@@ -249,7 +253,7 @@ func (cli *Client) handlePlaintextMessage(ctx context.Context, info *types.Messa
|
|
|
249
253
|
OriginalTS: meta.AttrGetter().UnixTime("original_msg_t"),
|
|
250
254
|
}
|
|
251
255
|
}
|
|
252
|
-
cli.dispatchEvent(evt.UnwrapRaw())
|
|
256
|
+
return cli.dispatchEvent(evt.UnwrapRaw())
|
|
253
257
|
}
|
|
254
258
|
|
|
255
259
|
func (cli *Client) migrateSessionStore(ctx context.Context, pn, lid types.JID) {
|
|
@@ -259,12 +263,16 @@ func (cli *Client) migrateSessionStore(ctx context.Context, pn, lid types.JID) {
|
|
|
259
263
|
}
|
|
260
264
|
}
|
|
261
265
|
|
|
262
|
-
func (cli *Client) decryptMessages(ctx context.Context, info *types.MessageInfo, node *waBinary.Node) {
|
|
266
|
+
func (cli *Client) decryptMessages(ctx context.Context, info *types.MessageInfo, node *waBinary.Node) (handlerFailed bool) {
|
|
263
267
|
unavailableNode, ok := node.GetOptionalChildByTag("unavailable")
|
|
264
268
|
if ok && len(node.GetChildrenByTag("enc")) == 0 {
|
|
265
269
|
uType := events.UnavailableType(unavailableNode.AttrGetter().String("type"))
|
|
266
270
|
cli.Log.Warnf("Unavailable message %s from %s (type: %q)", info.ID, info.SourceString(), uType)
|
|
267
|
-
|
|
271
|
+
if cli.SynchronousAck {
|
|
272
|
+
cli.immediateRequestMessageFromPhone(ctx, info)
|
|
273
|
+
} else {
|
|
274
|
+
go cli.delayedRequestMessageFromPhone(info)
|
|
275
|
+
}
|
|
268
276
|
cli.dispatchEvent(&events.UndecryptableMessage{Info: *info, IsUnavailable: true, UnavailableType: uType})
|
|
269
277
|
return
|
|
270
278
|
}
|
|
@@ -342,12 +350,20 @@ func (cli *Client) decryptMessages(ctx context.Context, info *types.MessageInfo,
|
|
|
342
350
|
cli.Log.Debugf("Ignoring message %s from %s: %v", info.ID, info.SourceString(), err)
|
|
343
351
|
return
|
|
344
352
|
} else if err != nil {
|
|
345
|
-
cli.Log.Warnf("Error decrypting message from %s: %v", info.SourceString(), err)
|
|
353
|
+
cli.Log.Warnf("Error decrypting message %s from %s: %v", info.ID, info.SourceString(), err)
|
|
354
|
+
if ctx.Err() != nil {
|
|
355
|
+
handlerFailed = true
|
|
356
|
+
return
|
|
357
|
+
}
|
|
346
358
|
isUnavailable := encType == "skmsg" && !containsDirectMsg && errors.Is(err, signalerror.ErrNoSenderKeyForUser)
|
|
347
359
|
if encType != "msmsg" {
|
|
348
|
-
|
|
360
|
+
if cli.SynchronousAck {
|
|
361
|
+
cli.sendRetryReceipt(ctx, node, info, isUnavailable)
|
|
362
|
+
} else {
|
|
363
|
+
go cli.sendRetryReceipt(context.WithoutCancel(ctx), node, info, isUnavailable)
|
|
364
|
+
}
|
|
349
365
|
}
|
|
350
|
-
cli.dispatchEvent(&events.UndecryptableMessage{
|
|
366
|
+
handlerFailed = cli.dispatchEvent(&events.UndecryptableMessage{
|
|
351
367
|
Info: *info,
|
|
352
368
|
IsUnavailable: isUnavailable,
|
|
353
369
|
DecryptFailMode: events.DecryptFailMode(ag.OptionalString("decrypt-fail")),
|
|
@@ -365,10 +381,10 @@ func (cli *Client) decryptMessages(ctx context.Context, info *types.MessageInfo,
|
|
|
365
381
|
cli.Log.Warnf("Error unmarshaling decrypted message from %s: %v", info.SourceString(), err)
|
|
366
382
|
continue
|
|
367
383
|
}
|
|
368
|
-
cli.handleDecryptedMessage(ctx, info, &msg, retryCount)
|
|
384
|
+
handlerFailed = cli.handleDecryptedMessage(ctx, info, &msg, retryCount)
|
|
369
385
|
handled = true
|
|
370
386
|
case 3:
|
|
371
|
-
handled = cli.handleDecryptedArmadillo(ctx, info, decrypted, retryCount)
|
|
387
|
+
handled, handlerFailed = cli.handleDecryptedArmadillo(ctx, info, decrypted, retryCount)
|
|
372
388
|
default:
|
|
373
389
|
cli.Log.Warnf("Unknown version %d in decrypted message from %s", ag.Int("v"), info.SourceString())
|
|
374
390
|
}
|
|
@@ -385,7 +401,7 @@ func (cli *Client) decryptMessages(ctx context.Context, info *types.MessageInfo,
|
|
|
385
401
|
Msg("Deleted event plaintext from buffer")
|
|
386
402
|
}
|
|
387
403
|
|
|
388
|
-
if time.Since(cli.lastDecryptedBufferClear) > 12*time.Hour {
|
|
404
|
+
if time.Since(cli.lastDecryptedBufferClear) > 12*time.Hour && ctx.Err() == nil {
|
|
389
405
|
cli.lastDecryptedBufferClear = time.Now()
|
|
390
406
|
go func() {
|
|
391
407
|
err := cli.Store.EventBuffer.DeleteOldBufferedHashes(context.WithoutCancel(ctx))
|
|
@@ -399,6 +415,7 @@ func (cli *Client) decryptMessages(ctx context.Context, info *types.MessageInfo,
|
|
|
399
415
|
if handled {
|
|
400
416
|
go cli.sendMessageReceipt(info)
|
|
401
417
|
}
|
|
418
|
+
return
|
|
402
419
|
}
|
|
403
420
|
|
|
404
421
|
func (cli *Client) clearUntrustedIdentity(ctx context.Context, target types.JID) error {
|
|
@@ -605,32 +622,52 @@ func (cli *Client) handleHistorySyncNotificationLoop() {
|
|
|
605
622
|
go cli.handleHistorySyncNotificationLoop()
|
|
606
623
|
}
|
|
607
624
|
}()
|
|
608
|
-
ctx :=
|
|
625
|
+
ctx := cli.BackgroundEventCtx
|
|
609
626
|
for notif := range cli.historySyncNotifications {
|
|
610
|
-
cli.
|
|
627
|
+
blob, err := cli.DownloadHistorySync(ctx, notif, false)
|
|
628
|
+
if err != nil {
|
|
629
|
+
cli.Log.Errorf("Failed to download history sync: %v", err)
|
|
630
|
+
} else {
|
|
631
|
+
cli.dispatchEvent(&events.HistorySync{Data: blob})
|
|
632
|
+
}
|
|
611
633
|
}
|
|
612
634
|
}
|
|
613
635
|
|
|
614
|
-
|
|
636
|
+
// DownloadHistorySync will download and parse the history sync blob from the given history sync notification.
|
|
637
|
+
//
|
|
638
|
+
// You only need to call this manually if you set [Client.ManualHistorySyncDownload] to true.
|
|
639
|
+
// By default, whatsmeow will call this automatically and dispatch an [events.HistorySync] with the parsed data.
|
|
640
|
+
func (cli *Client) DownloadHistorySync(ctx context.Context, notif *waE2E.HistorySyncNotification, synchronousStorage bool) (*waHistorySync.HistorySync, error) {
|
|
615
641
|
var historySync waHistorySync.HistorySync
|
|
616
642
|
if data, err := cli.Download(ctx, notif); err != nil {
|
|
617
|
-
|
|
643
|
+
return nil, fmt.Errorf("failed to download: %w", err)
|
|
618
644
|
} else if reader, err := zlib.NewReader(bytes.NewReader(data)); err != nil {
|
|
619
|
-
|
|
645
|
+
return nil, fmt.Errorf("failed to prepare to decompress: %w", err)
|
|
620
646
|
} else if rawData, err := io.ReadAll(reader); err != nil {
|
|
621
|
-
|
|
647
|
+
return nil, fmt.Errorf("failed to decompress: %w", err)
|
|
622
648
|
} else if err = proto.Unmarshal(rawData, &historySync); err != nil {
|
|
623
|
-
|
|
649
|
+
return nil, fmt.Errorf("failed to unmarshal: %w", err)
|
|
624
650
|
} else {
|
|
625
651
|
cli.Log.Debugf("Received history sync (type %s, chunk %d)", historySync.GetSyncType(), historySync.GetChunkOrder())
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
652
|
+
doStorage := func(ctx context.Context) {
|
|
653
|
+
if historySync.GetSyncType() == waHistorySync.HistorySync_PUSH_NAME {
|
|
654
|
+
cli.handleHistoricalPushNames(ctx, historySync.GetPushnames())
|
|
655
|
+
} else if len(historySync.GetConversations()) > 0 {
|
|
656
|
+
cli.storeHistoricalMessageSecrets(ctx, historySync.GetConversations())
|
|
657
|
+
}
|
|
658
|
+
if len(historySync.GetPhoneNumberToLidMappings()) > 0 {
|
|
659
|
+
cli.storeHistoricalPNLIDMappings(ctx, historySync.GetPhoneNumberToLidMappings())
|
|
660
|
+
}
|
|
661
|
+
if historySync.GlobalSettings != nil {
|
|
662
|
+
cli.storeGlobalSettings(ctx, historySync.GlobalSettings)
|
|
663
|
+
}
|
|
630
664
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
}
|
|
665
|
+
if synchronousStorage {
|
|
666
|
+
doStorage(ctx)
|
|
667
|
+
} else {
|
|
668
|
+
go doStorage(context.WithoutCancel(ctx))
|
|
669
|
+
}
|
|
670
|
+
return &historySync, nil
|
|
634
671
|
}
|
|
635
672
|
}
|
|
636
673
|
|
|
@@ -670,10 +707,11 @@ func (cli *Client) handleAppStateSyncKeyShare(ctx context.Context, keys *waE2E.A
|
|
|
670
707
|
}
|
|
671
708
|
}
|
|
672
709
|
|
|
673
|
-
func (cli *Client) handlePlaceholderResendResponse(msg *waE2E.PeerDataOperationRequestResponseMessage) {
|
|
710
|
+
func (cli *Client) handlePlaceholderResendResponse(msg *waE2E.PeerDataOperationRequestResponseMessage) (ok bool) {
|
|
674
711
|
reqID := msg.GetStanzaID()
|
|
675
712
|
parts := msg.GetPeerDataOperationResult()
|
|
676
713
|
cli.Log.Debugf("Handling response to placeholder resend request %s with %d items", reqID, len(parts))
|
|
714
|
+
ok = true
|
|
677
715
|
for i, part := range parts {
|
|
678
716
|
var webMsg waWeb.WebMessageInfo
|
|
679
717
|
if resp := part.GetPlaceholderMessageResendResponse(); resp == nil {
|
|
@@ -684,36 +722,50 @@ func (cli *Client) handlePlaceholderResendResponse(msg *waE2E.PeerDataOperationR
|
|
|
684
722
|
cli.Log.Warnf("Failed to parse web message info in item #%d of response to %s: %v", i+1, reqID, err)
|
|
685
723
|
} else {
|
|
686
724
|
msgEvt.UnavailableRequestID = reqID
|
|
687
|
-
cli.dispatchEvent(msgEvt)
|
|
725
|
+
ok = cli.dispatchEvent(msgEvt) && ok
|
|
688
726
|
}
|
|
689
727
|
}
|
|
728
|
+
return
|
|
690
729
|
}
|
|
691
730
|
|
|
692
|
-
func (cli *Client) handleProtocolMessage(ctx context.Context, info *types.MessageInfo, msg *waE2E.Message) {
|
|
731
|
+
func (cli *Client) handleProtocolMessage(ctx context.Context, info *types.MessageInfo, msg *waE2E.Message) (ok bool) {
|
|
732
|
+
ok = true
|
|
693
733
|
protoMsg := msg.GetProtocolMessage()
|
|
694
734
|
|
|
695
|
-
if
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
735
|
+
if !info.IsFromMe {
|
|
736
|
+
return
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
if protoMsg.GetHistorySyncNotification() != nil {
|
|
740
|
+
if !cli.ManualHistorySyncDownload {
|
|
741
|
+
cli.historySyncNotifications <- protoMsg.HistorySyncNotification
|
|
742
|
+
if cli.historySyncHandlerStarted.CompareAndSwap(false, true) {
|
|
743
|
+
go cli.handleHistorySyncNotificationLoop()
|
|
744
|
+
}
|
|
699
745
|
}
|
|
700
746
|
go cli.sendProtocolMessageReceipt(info.ID, types.ReceiptTypeHistorySync)
|
|
701
747
|
}
|
|
702
748
|
|
|
749
|
+
if protoMsg.GetLidMigrationMappingSyncMessage() != nil {
|
|
750
|
+
cli.storeLIDSyncMessage(ctx, protoMsg.GetLidMigrationMappingSyncMessage().GetEncodedMappingPayload())
|
|
751
|
+
}
|
|
752
|
+
|
|
703
753
|
if protoMsg.GetPeerDataOperationRequestResponseMessage().GetPeerDataOperationRequestType() == waE2E.PeerDataOperationRequestType_PLACEHOLDER_MESSAGE_RESEND {
|
|
704
|
-
|
|
754
|
+
ok = cli.handlePlaceholderResendResponse(protoMsg.GetPeerDataOperationRequestResponseMessage()) && ok
|
|
705
755
|
}
|
|
706
756
|
|
|
707
|
-
if protoMsg.GetAppStateSyncKeyShare() != nil
|
|
757
|
+
if protoMsg.GetAppStateSyncKeyShare() != nil {
|
|
708
758
|
go cli.handleAppStateSyncKeyShare(context.WithoutCancel(ctx), protoMsg.AppStateSyncKeyShare)
|
|
709
759
|
}
|
|
710
760
|
|
|
711
761
|
if info.Category == "peer" {
|
|
712
762
|
go cli.sendProtocolMessageReceipt(info.ID, types.ReceiptTypePeerMsg)
|
|
713
763
|
}
|
|
764
|
+
return
|
|
714
765
|
}
|
|
715
766
|
|
|
716
|
-
func (cli *Client) processProtocolParts(ctx context.Context, info *types.MessageInfo, msg *waE2E.Message) {
|
|
767
|
+
func (cli *Client) processProtocolParts(ctx context.Context, info *types.MessageInfo, msg *waE2E.Message) (ok bool) {
|
|
768
|
+
ok = true
|
|
717
769
|
cli.storeMessageSecret(ctx, info, msg)
|
|
718
770
|
// Hopefully sender key distribution messages and protocol messages can't be inside ephemeral messages
|
|
719
771
|
if msg.GetDeviceSentMessage().GetMessage() != nil {
|
|
@@ -733,8 +785,9 @@ func (cli *Client) processProtocolParts(ctx context.Context, info *types.Message
|
|
|
733
785
|
// N.B. Edits are protocol messages, but they're also wrapped inside EditedMessage,
|
|
734
786
|
// which is only unwrapped after processProtocolParts, so this won't trigger for edits.
|
|
735
787
|
if msg.GetProtocolMessage() != nil {
|
|
736
|
-
cli.handleProtocolMessage(ctx, info, msg)
|
|
788
|
+
ok = cli.handleProtocolMessage(ctx, info, msg) && ok
|
|
737
789
|
}
|
|
790
|
+
return
|
|
738
791
|
}
|
|
739
792
|
|
|
740
793
|
func (cli *Client) storeMessageSecret(ctx context.Context, info *types.MessageInfo, msg *waE2E.Message) {
|
|
@@ -816,10 +869,107 @@ func (cli *Client) storeHistoricalMessageSecrets(ctx context.Context, conversati
|
|
|
816
869
|
}
|
|
817
870
|
}
|
|
818
871
|
|
|
819
|
-
func (cli *Client)
|
|
820
|
-
|
|
872
|
+
func (cli *Client) storeLIDSyncMessage(ctx context.Context, msg []byte) {
|
|
873
|
+
var decoded waLidMigrationSyncPayload.LIDMigrationMappingSyncPayload
|
|
874
|
+
err := proto.Unmarshal(msg, &decoded)
|
|
875
|
+
if err != nil {
|
|
876
|
+
zerolog.Ctx(ctx).Err(err).Msg("Failed to unmarshal LID migration mapping sync payload")
|
|
877
|
+
return
|
|
878
|
+
}
|
|
879
|
+
if cli.Store.LIDMigrationTimestamp == 0 && decoded.GetChatDbMigrationTimestamp() > 0 {
|
|
880
|
+
cli.Store.LIDMigrationTimestamp = int64(decoded.GetChatDbMigrationTimestamp())
|
|
881
|
+
err = cli.Store.Save(ctx)
|
|
882
|
+
if err != nil {
|
|
883
|
+
zerolog.Ctx(ctx).Err(err).
|
|
884
|
+
Int64("lid_migration_timestamp", cli.Store.LIDMigrationTimestamp).
|
|
885
|
+
Msg("Failed to save chat DB LID migration timestamp")
|
|
886
|
+
} else {
|
|
887
|
+
zerolog.Ctx(ctx).Debug().
|
|
888
|
+
Int64("lid_migration_timestamp", cli.Store.LIDMigrationTimestamp).
|
|
889
|
+
Msg("Saved chat DB LID migration timestamp")
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
lidPairs := make([]store.LIDMapping, len(decoded.PnToLidMappings))
|
|
893
|
+
for i, mapping := range decoded.PnToLidMappings {
|
|
894
|
+
lidPairs[i] = store.LIDMapping{
|
|
895
|
+
LID: types.JID{User: strconv.FormatUint(mapping.GetAssignedLid(), 10), Server: types.HiddenUserServer},
|
|
896
|
+
PN: types.JID{User: strconv.FormatUint(mapping.GetPn(), 10), Server: types.DefaultUserServer},
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
err = cli.Store.LIDs.PutManyLIDMappings(ctx, lidPairs)
|
|
900
|
+
if err != nil {
|
|
901
|
+
zerolog.Ctx(ctx).Err(err).
|
|
902
|
+
Int("pair_count", len(lidPairs)).
|
|
903
|
+
Msg("Failed to store phone number to LID mappings from sync message")
|
|
904
|
+
} else {
|
|
905
|
+
zerolog.Ctx(ctx).Debug().
|
|
906
|
+
Int("pair_count", len(lidPairs)).
|
|
907
|
+
Msg("Stored PN-LID mappings from sync message")
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
func (cli *Client) storeGlobalSettings(ctx context.Context, settings *waHistorySync.GlobalSettings) {
|
|
912
|
+
if cli.Store.LIDMigrationTimestamp == 0 && settings.GetChatDbLidMigrationTimestamp() > 0 {
|
|
913
|
+
cli.Store.LIDMigrationTimestamp = settings.GetChatDbLidMigrationTimestamp()
|
|
914
|
+
err := cli.Store.Save(ctx)
|
|
915
|
+
if err != nil {
|
|
916
|
+
zerolog.Ctx(ctx).Err(err).
|
|
917
|
+
Int64("lid_migration_timestamp", cli.Store.LIDMigrationTimestamp).
|
|
918
|
+
Msg("Failed to save chat DB LID migration timestamp")
|
|
919
|
+
} else {
|
|
920
|
+
zerolog.Ctx(ctx).Debug().
|
|
921
|
+
Int64("lid_migration_timestamp", cli.Store.LIDMigrationTimestamp).
|
|
922
|
+
Msg("Saved chat DB LID migration timestamp")
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
func (cli *Client) storeHistoricalPNLIDMappings(ctx context.Context, mappings []*waHistorySync.PhoneNumberToLIDMapping) {
|
|
928
|
+
lidPairs := make([]store.LIDMapping, 0, len(mappings))
|
|
929
|
+
for _, mapping := range mappings {
|
|
930
|
+
pn, err := types.ParseJID(mapping.GetPnJID())
|
|
931
|
+
if err != nil {
|
|
932
|
+
zerolog.Ctx(ctx).Err(err).
|
|
933
|
+
Str("pn_jid", mapping.GetPnJID()).
|
|
934
|
+
Str("lid_jid", mapping.GetLidJID()).
|
|
935
|
+
Msg("Failed to parse phone number from history sync")
|
|
936
|
+
continue
|
|
937
|
+
}
|
|
938
|
+
if pn.Server == types.LegacyUserServer {
|
|
939
|
+
pn.Server = types.DefaultUserServer
|
|
940
|
+
}
|
|
941
|
+
lid, err := types.ParseJID(mapping.GetLidJID())
|
|
942
|
+
if err != nil {
|
|
943
|
+
zerolog.Ctx(ctx).Err(err).
|
|
944
|
+
Str("pn_jid", mapping.GetPnJID()).
|
|
945
|
+
Str("lid_jid", mapping.GetLidJID()).
|
|
946
|
+
Msg("Failed to parse LID from history sync")
|
|
947
|
+
continue
|
|
948
|
+
}
|
|
949
|
+
lidPairs = append(lidPairs, store.LIDMapping{
|
|
950
|
+
LID: lid,
|
|
951
|
+
PN: pn,
|
|
952
|
+
})
|
|
953
|
+
}
|
|
954
|
+
err := cli.Store.LIDs.PutManyLIDMappings(ctx, lidPairs)
|
|
955
|
+
if err != nil {
|
|
956
|
+
zerolog.Ctx(ctx).Err(err).
|
|
957
|
+
Int("pair_count", len(lidPairs)).
|
|
958
|
+
Msg("Failed to store phone number to LID mappings from history sync")
|
|
959
|
+
} else {
|
|
960
|
+
zerolog.Ctx(ctx).Debug().
|
|
961
|
+
Int("pair_count", len(lidPairs)).
|
|
962
|
+
Msg("Stored PN-LID mappings from history sync")
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
func (cli *Client) handleDecryptedMessage(ctx context.Context, info *types.MessageInfo, msg *waE2E.Message, retryCount int) bool {
|
|
967
|
+
ok := cli.processProtocolParts(ctx, info, msg)
|
|
968
|
+
if !ok {
|
|
969
|
+
return false
|
|
970
|
+
}
|
|
821
971
|
evt := &events.Message{Info: *info, RawMessage: msg, RetryCount: retryCount}
|
|
822
|
-
cli.dispatchEvent(evt.UnwrapRaw())
|
|
972
|
+
return cli.dispatchEvent(evt.UnwrapRaw())
|
|
823
973
|
}
|
|
824
974
|
|
|
825
975
|
func (cli *Client) sendProtocolMessageReceipt(id types.MessageID, msgType types.ReceiptType) {
|
|
@@ -250,8 +250,9 @@ func (cli *Client) handleAccountSyncNotification(ctx context.Context, node *waBi
|
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
func (cli *Client) handlePrivacyTokenNotification(ctx context.Context, node *waBinary.Node) {
|
|
253
|
-
|
|
254
|
-
|
|
253
|
+
ownJID := cli.getOwnID().ToNonAD()
|
|
254
|
+
ownLID := cli.getOwnLID().ToNonAD()
|
|
255
|
+
if ownJID.IsEmpty() {
|
|
255
256
|
cli.Log.Debugf("Ignoring privacy token notification, session was deleted")
|
|
256
257
|
return
|
|
257
258
|
}
|
|
@@ -270,8 +271,11 @@ func (cli *Client) handlePrivacyTokenNotification(ctx context.Context, node *waB
|
|
|
270
271
|
ag := child.AttrGetter()
|
|
271
272
|
if child.Tag != "token" {
|
|
272
273
|
cli.Log.Warnf("privacy_token notification contained unexpected <%s> tag", child.Tag)
|
|
273
|
-
} else if targetUser := ag.JID("jid"); targetUser !=
|
|
274
|
-
|
|
274
|
+
} else if targetUser := ag.JID("jid"); targetUser != ownLID && targetUser != ownJID {
|
|
275
|
+
// Don't log about own privacy tokens for other users
|
|
276
|
+
if sender != ownJID && sender != ownLID {
|
|
277
|
+
cli.Log.Warnf("privacy_token notification contained token for different user %s", targetUser)
|
|
278
|
+
}
|
|
275
279
|
} else if tokenType := ag.String("type"); tokenType != "trusted_contact" {
|
|
276
280
|
cli.Log.Warnf("privacy_token notification contained unexpected token type %s", tokenType)
|
|
277
281
|
} else if token, ok := child.Content.([]byte); !ok {
|
|
@@ -406,13 +410,14 @@ func (cli *Client) handleStatusNotification(ctx context.Context, node *waBinary.
|
|
|
406
410
|
}
|
|
407
411
|
|
|
408
412
|
func (cli *Client) handleNotification(node *waBinary.Node) {
|
|
409
|
-
ctx :=
|
|
413
|
+
ctx := cli.BackgroundEventCtx
|
|
410
414
|
ag := node.AttrGetter()
|
|
411
415
|
notifType := ag.String("type")
|
|
412
416
|
if !ag.OK() {
|
|
413
417
|
return
|
|
414
418
|
}
|
|
415
|
-
|
|
419
|
+
var cancelled bool
|
|
420
|
+
defer cli.maybeDeferredAck(ctx, node)(&cancelled)
|
|
416
421
|
switch notifType {
|
|
417
422
|
case "encrypt":
|
|
418
423
|
go cli.handleEncryptNotification(ctx, node)
|
|
@@ -429,7 +434,7 @@ func (cli *Client) handleNotification(node *waBinary.Node) {
|
|
|
429
434
|
if err != nil {
|
|
430
435
|
cli.Log.Errorf("Failed to parse group notification: %v", err)
|
|
431
436
|
} else {
|
|
432
|
-
cli.dispatchEvent(evt)
|
|
437
|
+
cancelled = cli.dispatchEvent(evt)
|
|
433
438
|
}
|
|
434
439
|
case "picture":
|
|
435
440
|
cli.handlePictureNotification(ctx, node)
|
|
@@ -3,6 +3,9 @@ package armadillo
|
|
|
3
3
|
import (
|
|
4
4
|
"google.golang.org/protobuf/proto"
|
|
5
5
|
|
|
6
|
+
"go.mau.fi/whatsmeow/proto/instamadilloAddMessage"
|
|
7
|
+
"go.mau.fi/whatsmeow/proto/instamadilloDeleteMessage"
|
|
8
|
+
"go.mau.fi/whatsmeow/proto/instamadilloSupplementMessage"
|
|
6
9
|
"go.mau.fi/whatsmeow/proto/waArmadilloApplication"
|
|
7
10
|
"go.mau.fi/whatsmeow/proto/waCommon"
|
|
8
11
|
"go.mau.fi/whatsmeow/proto/waConsumerApplication"
|
|
@@ -29,6 +32,10 @@ var (
|
|
|
29
32
|
_ MessageApplicationSub = (*waMultiDevice.MultiDevice)(nil) // 5
|
|
30
33
|
_ MessageApplicationSub = (*Unsupported_Voip)(nil) // 6
|
|
31
34
|
_ MessageApplicationSub = (*waArmadilloApplication.Armadillo)(nil) // 7
|
|
35
|
+
|
|
36
|
+
_ MessageApplicationSub = (*instamadilloAddMessage.AddMessagePayload)(nil)
|
|
37
|
+
_ MessageApplicationSub = (*instamadilloSupplementMessage.SupplementMessagePayload)(nil)
|
|
38
|
+
_ MessageApplicationSub = (*instamadilloDeleteMessage.DeleteMessagePayload)(nil)
|
|
32
39
|
)
|
|
33
40
|
|
|
34
41
|
func (*Unsupported_BusinessApplication) IsMessageApplicationSub() {}
|