slidge-whatsapp 0.3.7__cp312-cp312-manylinux_2_41_aarch64.whl → 0.3.8__cp312-cp312-manylinux_2_41_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.
Files changed (164) hide show
  1. slidge_whatsapp/config.py +7 -2
  2. slidge_whatsapp/contact.py +3 -2
  3. slidge_whatsapp/event.go +14 -9
  4. slidge_whatsapp/gateway.go +7 -1
  5. slidge_whatsapp/generated/_whatsapp.cpython-312-aarch64-linux-gnu.h +182 -178
  6. slidge_whatsapp/generated/_whatsapp.cpython-312-aarch64-linux-gnu.so +0 -0
  7. slidge_whatsapp/generated/build.py +146 -142
  8. slidge_whatsapp/generated/whatsapp.c +1456 -1376
  9. slidge_whatsapp/generated/whatsapp.go +1069 -1045
  10. slidge_whatsapp/generated/whatsapp.py +1324 -1298
  11. slidge_whatsapp/generated/whatsapp_go.h +182 -178
  12. slidge_whatsapp/go.mod +6 -6
  13. slidge_whatsapp/go.sum +12 -12
  14. slidge_whatsapp/group.py +25 -0
  15. slidge_whatsapp/session.go +69 -67
  16. slidge_whatsapp/session.py +11 -1
  17. slidge_whatsapp/vendor/github.com/coder/websocket/LICENSE.txt +13 -0
  18. slidge_whatsapp/vendor/github.com/coder/websocket/Makefile +18 -0
  19. slidge_whatsapp/vendor/github.com/coder/websocket/README.md +162 -0
  20. slidge_whatsapp/vendor/github.com/coder/websocket/accept.go +378 -0
  21. slidge_whatsapp/vendor/github.com/coder/websocket/close.go +335 -0
  22. slidge_whatsapp/vendor/github.com/coder/websocket/compress.go +234 -0
  23. slidge_whatsapp/vendor/github.com/coder/websocket/conn.go +306 -0
  24. slidge_whatsapp/vendor/github.com/coder/websocket/dial.go +347 -0
  25. slidge_whatsapp/vendor/github.com/coder/websocket/doc.go +33 -0
  26. slidge_whatsapp/vendor/github.com/coder/websocket/errors.go +8 -0
  27. slidge_whatsapp/vendor/github.com/coder/websocket/frame.go +173 -0
  28. slidge_whatsapp/vendor/github.com/coder/websocket/hijack.go +33 -0
  29. slidge_whatsapp/vendor/github.com/coder/websocket/internal/bpool/bpool.go +25 -0
  30. slidge_whatsapp/vendor/github.com/coder/websocket/internal/errd/wrap.go +14 -0
  31. slidge_whatsapp/vendor/github.com/coder/websocket/internal/util/util.go +15 -0
  32. slidge_whatsapp/vendor/github.com/coder/websocket/internal/wsjs/wsjs_js.go +169 -0
  33. slidge_whatsapp/vendor/github.com/coder/websocket/mask.go +128 -0
  34. slidge_whatsapp/vendor/github.com/coder/websocket/mask_amd64.s +127 -0
  35. slidge_whatsapp/vendor/github.com/coder/websocket/mask_arm64.s +72 -0
  36. slidge_whatsapp/vendor/github.com/coder/websocket/mask_asm.go +26 -0
  37. slidge_whatsapp/vendor/github.com/coder/websocket/mask_go.go +7 -0
  38. slidge_whatsapp/vendor/github.com/coder/websocket/netconn.go +233 -0
  39. slidge_whatsapp/vendor/github.com/coder/websocket/netconn_js.go +11 -0
  40. slidge_whatsapp/vendor/github.com/coder/websocket/netconn_notjs.go +19 -0
  41. slidge_whatsapp/vendor/github.com/coder/websocket/read.go +540 -0
  42. slidge_whatsapp/vendor/github.com/coder/websocket/stringer.go +91 -0
  43. slidge_whatsapp/vendor/github.com/coder/websocket/write.go +384 -0
  44. slidge_whatsapp/vendor/github.com/coder/websocket/ws_js.go +598 -0
  45. slidge_whatsapp/vendor/github.com/ebitengine/purego/func.go +1 -1
  46. slidge_whatsapp/vendor/github.com/ebitengine/purego/struct_amd64.go +1 -1
  47. slidge_whatsapp/vendor/github.com/ebitengine/purego/struct_arm64.go +3 -1
  48. slidge_whatsapp/vendor/github.com/ebitengine/purego/struct_loong64.go +1 -1
  49. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/directive.go +3 -0
  50. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/selection.go +3 -0
  51. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/value.go +4 -3
  52. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate/encode.go +3 -0
  53. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate.go +18 -4
  54. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/broadcast.go +3 -3
  55. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/call.go +6 -4
  56. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/client.go +90 -80
  57. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/connectionevents.go +14 -11
  58. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/download.go +4 -1
  59. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/group.go +47 -48
  60. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/handshake.go +3 -2
  61. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/internals.go +79 -75
  62. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/keepalive.go +8 -6
  63. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/mediaconn.go +1 -2
  64. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/mediaretry.go +2 -2
  65. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/message.go +42 -40
  66. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/newsletter.go +35 -32
  67. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/notification.go +2 -3
  68. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/pair-code.go +2 -4
  69. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/pair.go +19 -19
  70. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/prekeys.go +9 -8
  71. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/presence.go +9 -9
  72. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/privacysettings.go +4 -5
  73. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloAddMessage/InstamadilloAddMessage.pb.go +1 -1
  74. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeActionLog/InstamadilloCoreTypeActionLog.pb.go +1 -1
  75. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeAdminMessage/InstamadilloCoreTypeAdminMessage.pb.go +1 -1
  76. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeCollection/InstamadilloCoreTypeCollection.pb.go +1 -1
  77. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeLink/InstamadilloCoreTypeLink.pb.go +1 -1
  78. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeMedia/InstamadilloCoreTypeMedia.pb.go +1 -1
  79. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeText/InstamadilloCoreTypeText.pb.go +1 -1
  80. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloDeleteMessage/InstamadilloDeleteMessage.pb.go +1 -1
  81. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloSupplementMessage/InstamadilloSupplementMessage.pb.go +1 -1
  82. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloTransportPayload/InstamadilloTransportPayload.pb.go +1 -1
  83. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloXmaContentRef/InstamadilloXmaContentRef.pb.go +1 -1
  84. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waAICommon/WAAICommon.pb.go +1145 -335
  85. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waAICommon/WAAICommon.proto +78 -0
  86. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waAdv/WAAdv.pb.go +1 -1
  87. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waArmadilloApplication/WAArmadilloApplication.pb.go +1 -1
  88. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waArmadilloXMA/WAArmadilloXMA.pb.go +1 -1
  89. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCert/WACert.pb.go +1 -1
  90. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waChatLockSettings/WAProtobufsChatLockSettings.pb.go +1 -1
  91. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCommon/WACommon.pb.go +1 -1
  92. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCompanionReg/WACompanionReg.pb.go +22 -4
  93. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCompanionReg/WACompanionReg.proto +2 -0
  94. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waConsumerApplication/WAConsumerApplication.pb.go +1 -1
  95. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waDeviceCapabilities/WAProtobufsDeviceCapabilities.pb.go +104 -30
  96. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waDeviceCapabilities/WAProtobufsDeviceCapabilities.proto +7 -0
  97. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.pb.go +1037 -963
  98. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.proto +15 -8
  99. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waHistorySync/WAWebProtobufsHistorySync.pb.go +1 -1
  100. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waLidMigrationSyncPayload/WAWebProtobufLidMigrationSyncPayload.pb.go +1 -1
  101. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMediaTransport/WAMediaTransport.pb.go +1 -1
  102. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMmsRetry/WAMmsRetry.pb.go +1 -1
  103. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMsgApplication/WAMsgApplication.pb.go +1 -1
  104. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMsgTransport/WAMsgTransport.pb.go +1 -1
  105. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMultiDevice/WAMultiDevice.pb.go +1 -1
  106. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waServerSync/WAServerSync.pb.go +1 -1
  107. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.pb.go +40 -35
  108. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.proto +1 -0
  109. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.pb.go +921 -653
  110. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.proto +44 -15
  111. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waUserPassword/WAProtobufsUserPassword.pb.go +1 -1
  112. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waVnameCert/WAWebProtobufsVnameCert.pb.go +1 -1
  113. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWa6/WAWebProtobufsWa6.pb.go +9 -5
  114. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWa6/WAWebProtobufsWa6.proto +1 -0
  115. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWeb/WAWebProtobufsWeb.pb.go +193 -115
  116. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWeb/WAWebProtobufsWeb.proto +9 -0
  117. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/push.go +2 -4
  118. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/receipt.go +12 -12
  119. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/request.go +25 -19
  120. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/retry.go +2 -2
  121. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/send.go +43 -27
  122. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/sendfb.go +4 -4
  123. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/socket/constants.go +1 -1
  124. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/socket/framesocket.go +43 -56
  125. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/socket/noisehandshake.go +9 -3
  126. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/socket/noisesocket.go +36 -22
  127. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/clientpayload.go +24 -4
  128. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/store.go +12 -0
  129. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/events/appstate.go +2 -1
  130. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/upload.go +1 -1
  131. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/user.go +79 -40
  132. slidge_whatsapp/vendor/golang.org/x/sys/unix/mkerrors.sh +2 -0
  133. slidge_whatsapp/vendor/golang.org/x/sys/unix/syscall_linux.go +6 -0
  134. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux.go +359 -0
  135. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsyscall_linux.go +10 -0
  136. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux.go +31 -0
  137. slidge_whatsapp/vendor/golang.org/x/sys/windows/syscall_windows.go +15 -0
  138. slidge_whatsapp/vendor/golang.org/x/sys/windows/types_windows.go +76 -0
  139. slidge_whatsapp/vendor/golang.org/x/sys/windows/zsyscall_windows.go +37 -0
  140. slidge_whatsapp/vendor/modules.txt +12 -8
  141. {slidge_whatsapp-0.3.7.dist-info → slidge_whatsapp-0.3.8.dist-info}/METADATA +1 -1
  142. {slidge_whatsapp-0.3.7.dist-info → slidge_whatsapp-0.3.8.dist-info}/RECORD +145 -136
  143. slidge_whatsapp/vendor/github.com/gorilla/websocket/.gitignore +0 -25
  144. slidge_whatsapp/vendor/github.com/gorilla/websocket/AUTHORS +0 -9
  145. slidge_whatsapp/vendor/github.com/gorilla/websocket/LICENSE +0 -22
  146. slidge_whatsapp/vendor/github.com/gorilla/websocket/README.md +0 -33
  147. slidge_whatsapp/vendor/github.com/gorilla/websocket/client.go +0 -434
  148. slidge_whatsapp/vendor/github.com/gorilla/websocket/compression.go +0 -148
  149. slidge_whatsapp/vendor/github.com/gorilla/websocket/conn.go +0 -1238
  150. slidge_whatsapp/vendor/github.com/gorilla/websocket/doc.go +0 -227
  151. slidge_whatsapp/vendor/github.com/gorilla/websocket/join.go +0 -42
  152. slidge_whatsapp/vendor/github.com/gorilla/websocket/json.go +0 -60
  153. slidge_whatsapp/vendor/github.com/gorilla/websocket/mask.go +0 -55
  154. slidge_whatsapp/vendor/github.com/gorilla/websocket/mask_safe.go +0 -16
  155. slidge_whatsapp/vendor/github.com/gorilla/websocket/prepared.go +0 -102
  156. slidge_whatsapp/vendor/github.com/gorilla/websocket/proxy.go +0 -77
  157. slidge_whatsapp/vendor/github.com/gorilla/websocket/server.go +0 -365
  158. slidge_whatsapp/vendor/github.com/gorilla/websocket/tls_handshake.go +0 -21
  159. slidge_whatsapp/vendor/github.com/gorilla/websocket/tls_handshake_116.go +0 -21
  160. slidge_whatsapp/vendor/github.com/gorilla/websocket/util.go +0 -298
  161. slidge_whatsapp/vendor/github.com/gorilla/websocket/x_net_proxy.go +0 -473
  162. {slidge_whatsapp-0.3.7.dist-info → slidge_whatsapp-0.3.8.dist-info}/WHEEL +0 -0
  163. {slidge_whatsapp-0.3.7.dist-info → slidge_whatsapp-0.3.8.dist-info}/entry_points.txt +0 -0
  164. {slidge_whatsapp-0.3.7.dist-info → slidge_whatsapp-0.3.8.dist-info}/licenses/LICENSE +0 -0
@@ -27,14 +27,14 @@ var (
27
27
  KeepAliveMaxFailTime = 3 * time.Minute
28
28
  )
29
29
 
30
- func (cli *Client) keepAliveLoop(ctx context.Context) {
30
+ func (cli *Client) keepAliveLoop(ctx, connCtx context.Context) {
31
31
  lastSuccess := time.Now()
32
32
  var errorCount int
33
33
  for {
34
34
  interval := rand.Int64N(KeepAliveIntervalMax.Milliseconds()-KeepAliveIntervalMin.Milliseconds()) + KeepAliveIntervalMin.Milliseconds()
35
35
  select {
36
36
  case <-time.After(time.Duration(interval) * time.Millisecond):
37
- isSuccess, shouldContinue := cli.sendKeepAlive(ctx)
37
+ isSuccess, shouldContinue := cli.sendKeepAlive(connCtx)
38
38
  if !shouldContinue {
39
39
  return
40
40
  } else if !isSuccess {
@@ -47,7 +47,7 @@ func (cli *Client) keepAliveLoop(ctx context.Context) {
47
47
  cli.Log.Debugf("Forcing reconnect due to keepalive failure")
48
48
  cli.Disconnect()
49
49
  cli.resetExpectedDisconnect()
50
- go cli.autoReconnect()
50
+ go cli.autoReconnect(ctx)
51
51
  }
52
52
  } else {
53
53
  if errorCount > 0 {
@@ -56,19 +56,21 @@ func (cli *Client) keepAliveLoop(ctx context.Context) {
56
56
  }
57
57
  lastSuccess = time.Now()
58
58
  }
59
- case <-ctx.Done():
59
+ case <-connCtx.Done():
60
60
  return
61
61
  }
62
62
  }
63
63
  }
64
64
 
65
65
  func (cli *Client) sendKeepAlive(ctx context.Context) (isSuccess, shouldContinue bool) {
66
- respCh, err := cli.sendIQAsync(infoQuery{
66
+ respCh, err := cli.sendIQAsync(ctx, infoQuery{
67
67
  Namespace: "w:p",
68
68
  Type: "get",
69
69
  To: types.ServerJID,
70
70
  })
71
- if err != nil {
71
+ if ctx.Err() != nil {
72
+ return false, false
73
+ } else if err != nil {
72
74
  cli.Log.Warnf("Failed to send keepalive: %v", err)
73
75
  return false, true
74
76
  }
@@ -58,8 +58,7 @@ func (cli *Client) refreshMediaConn(ctx context.Context, force bool) (*MediaConn
58
58
  }
59
59
 
60
60
  func (cli *Client) queryMediaConn(ctx context.Context) (*MediaConn, error) {
61
- resp, err := cli.sendIQ(infoQuery{
62
- Context: ctx,
61
+ resp, err := cli.sendIQ(ctx, infoQuery{
63
62
  Namespace: "w:m",
64
63
  Type: "set",
65
64
  To: types.ServerJID,
@@ -74,7 +74,7 @@ func encryptMediaRetryReceipt(messageID types.MessageID, mediaKey []byte) (ciphe
74
74
  // // Alternatively, you can use cli.DownloadMediaWithPath and provide the individual fields manually.
75
75
  // }
76
76
  // }
77
- func (cli *Client) SendMediaRetryReceipt(message *types.MessageInfo, mediaKey []byte) error {
77
+ func (cli *Client) SendMediaRetryReceipt(ctx context.Context, message *types.MessageInfo, mediaKey []byte) error {
78
78
  if cli == nil {
79
79
  return ErrClientIsNil
80
80
  }
@@ -100,7 +100,7 @@ func (cli *Client) SendMediaRetryReceipt(message *types.MessageInfo, mediaKey []
100
100
  {Tag: "enc_iv", Content: iv},
101
101
  }
102
102
 
103
- err = cli.sendNode(waBinary.Node{
103
+ err = cli.sendNode(ctx, waBinary.Node{
104
104
  Tag: "receipt",
105
105
  Attrs: waBinary.Attrs{
106
106
  "id": message.ID,
@@ -40,8 +40,7 @@ import (
40
40
 
41
41
  var pbSerializer = store.SignalProtobufSerializer
42
42
 
43
- func (cli *Client) handleEncryptedMessage(node *waBinary.Node) {
44
- ctx := cli.BackgroundEventCtx
43
+ func (cli *Client) handleEncryptedMessage(ctx context.Context, node *waBinary.Node) {
45
44
  info, err := cli.parseMessageInfo(node)
46
45
  if err != nil {
47
46
  cli.Log.Warnf("Failed to parse message: %v", err)
@@ -52,10 +51,10 @@ func (cli *Client) handleEncryptedMessage(node *waBinary.Node) {
52
51
  cli.StoreLIDPNMapping(ctx, info.RecipientAlt, info.Chat)
53
52
  }
54
53
  if info.VerifiedName != nil && len(info.VerifiedName.Details.GetVerifiedName()) > 0 {
55
- go cli.updateBusinessName(cli.BackgroundEventCtx, info.Sender, info, info.VerifiedName.Details.GetVerifiedName())
54
+ go cli.updateBusinessName(ctx, info.Sender, info.SenderAlt, info, info.VerifiedName.Details.GetVerifiedName())
56
55
  }
57
56
  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
+ go cli.updatePushName(ctx, info.Sender, info.SenderAlt, info, info.PushName)
59
58
  }
60
59
  if info.Sender.Server == types.NewsletterServer {
61
60
  var cancelled bool
@@ -303,7 +302,7 @@ func (cli *Client) decryptMessages(ctx context.Context, info *types.MessageInfo,
303
302
  cli.Log.Warnf("Unavailable message %s from %s (type: %q)", info.ID, info.SourceString(), uType)
304
303
  cli.backgroundIfAsyncAck(func() {
305
304
  cli.immediateRequestMessageFromPhone(ctx, info)
306
- cli.sendAck(node, 0)
305
+ cli.sendAck(ctx, node, 0)
307
306
  })
308
307
  cli.dispatchEvent(&events.UndecryptableMessage{Info: *info, IsUnavailable: true, UnavailableType: uType})
309
308
  return
@@ -391,15 +390,15 @@ func (cli *Client) decryptMessages(ctx context.Context, info *types.MessageInfo,
391
390
  isUnavailable := encType == "skmsg" && !containsDirectMsg && errors.Is(err, signalerror.ErrNoSenderKeyForUser)
392
391
  if encType == "msmsg" {
393
392
  cli.backgroundIfAsyncAck(func() {
394
- cli.sendAck(node, NackMissingMessageSecret)
393
+ cli.sendAck(ctx, node, NackMissingMessageSecret)
395
394
  })
396
395
  } else if cli.SynchronousAck {
397
396
  cli.sendRetryReceipt(ctx, node, info, isUnavailable)
398
397
  // TODO this probably isn't supposed to ack
399
- cli.sendAck(node, 0)
398
+ cli.sendAck(ctx, node, 0)
400
399
  } else {
401
400
  go cli.sendRetryReceipt(context.WithoutCancel(ctx), node, info, isUnavailable)
402
- go cli.sendAck(node, 0)
401
+ go cli.sendAck(ctx, node, 0)
403
402
  }
404
403
  cli.dispatchEvent(&events.UndecryptableMessage{
405
404
  Info: *info,
@@ -460,11 +459,11 @@ func (cli *Client) decryptMessages(ctx context.Context, info *types.MessageInfo,
460
459
  }
461
460
  cli.backgroundIfAsyncAck(func() {
462
461
  if !recognizedStanza {
463
- cli.sendAck(node, NackUnrecognizedStanza)
462
+ cli.sendAck(ctx, node, NackUnrecognizedStanza)
464
463
  } else if protobufFailed {
465
- cli.sendAck(node, NackInvalidProtobuf)
464
+ cli.sendAck(ctx, node, NackInvalidProtobuf)
466
465
  } else {
467
- cli.sendMessageReceipt(info, node)
466
+ cli.sendMessageReceipt(ctx, info, node)
468
467
  }
469
468
  })
470
469
  return
@@ -690,37 +689,41 @@ func (cli *Client) handleHistorySyncNotificationLoop() {
690
689
  // You only need to call this manually if you set [Client.ManualHistorySyncDownload] to true.
691
690
  // By default, whatsmeow will call this automatically and dispatch an [events.HistorySync] with the parsed data.
692
691
  func (cli *Client) DownloadHistorySync(ctx context.Context, notif *waE2E.HistorySyncNotification, synchronousStorage bool) (*waHistorySync.HistorySync, error) {
693
- var historySync waHistorySync.HistorySync
694
- if data, err := cli.Download(ctx, notif); err != nil {
692
+ var data []byte
693
+ var err error
694
+ if notif.InitialHistBootstrapInlinePayload != nil {
695
+ data = notif.InitialHistBootstrapInlinePayload
696
+ } else if data, err = cli.Download(ctx, notif); err != nil {
695
697
  return nil, fmt.Errorf("failed to download: %w", err)
696
- } else if reader, err := zlib.NewReader(bytes.NewReader(data)); err != nil {
698
+ }
699
+ var historySync waHistorySync.HistorySync
700
+ if reader, err := zlib.NewReader(bytes.NewReader(data)); err != nil {
697
701
  return nil, fmt.Errorf("failed to prepare to decompress: %w", err)
698
702
  } else if rawData, err := io.ReadAll(reader); err != nil {
699
703
  return nil, fmt.Errorf("failed to decompress: %w", err)
700
704
  } else if err = proto.Unmarshal(rawData, &historySync); err != nil {
701
705
  return nil, fmt.Errorf("failed to unmarshal: %w", err)
702
- } else {
703
- cli.Log.Debugf("Received history sync (type %s, chunk %d, progress %d)", historySync.GetSyncType(), historySync.GetChunkOrder(), historySync.GetProgress())
704
- doStorage := func(ctx context.Context) {
705
- if historySync.GetSyncType() == waHistorySync.HistorySync_PUSH_NAME {
706
- cli.handleHistoricalPushNames(ctx, historySync.GetPushnames())
707
- } else if len(historySync.GetConversations()) > 0 {
708
- cli.storeHistoricalMessageSecrets(ctx, historySync.GetConversations())
709
- }
710
- if len(historySync.GetPhoneNumberToLidMappings()) > 0 {
711
- cli.storeHistoricalPNLIDMappings(ctx, historySync.GetPhoneNumberToLidMappings())
712
- }
713
- if historySync.GlobalSettings != nil {
714
- cli.storeGlobalSettings(ctx, historySync.GlobalSettings)
715
- }
706
+ }
707
+ cli.Log.Debugf("Received history sync (type %s, chunk %d, progress %d)", historySync.GetSyncType(), historySync.GetChunkOrder(), historySync.GetProgress())
708
+ doStorage := func(ctx context.Context) {
709
+ if historySync.GetSyncType() == waHistorySync.HistorySync_PUSH_NAME {
710
+ cli.handleHistoricalPushNames(ctx, historySync.GetPushnames())
711
+ } else if len(historySync.GetConversations()) > 0 {
712
+ cli.storeHistoricalMessageSecrets(ctx, historySync.GetConversations())
716
713
  }
717
- if synchronousStorage {
718
- doStorage(ctx)
719
- } else {
720
- go doStorage(context.WithoutCancel(ctx))
714
+ if len(historySync.GetPhoneNumberToLidMappings()) > 0 {
715
+ cli.storeHistoricalPNLIDMappings(ctx, historySync.GetPhoneNumberToLidMappings())
721
716
  }
722
- return &historySync, nil
717
+ if historySync.GlobalSettings != nil {
718
+ cli.storeGlobalSettings(ctx, historySync.GlobalSettings)
719
+ }
720
+ }
721
+ if synchronousStorage {
722
+ doStorage(ctx)
723
+ } else {
724
+ go doStorage(context.WithoutCancel(ctx))
723
725
  }
726
+ return &historySync, nil
724
727
  }
725
728
 
726
729
  func (cli *Client) handleAppStateSyncKeyShare(ctx context.Context, keys *waE2E.AppStateSyncKeyShare) {
@@ -795,7 +798,7 @@ func (cli *Client) handleProtocolMessage(ctx context.Context, info *types.Messag
795
798
  go cli.handleHistorySyncNotificationLoop()
796
799
  }
797
800
  }
798
- go cli.sendProtocolMessageReceipt(info.ID, types.ReceiptTypeHistorySync)
801
+ go cli.sendProtocolMessageReceipt(ctx, info.ID, types.ReceiptTypeHistorySync)
799
802
  }
800
803
 
801
804
  if protoMsg.GetLidMigrationMappingSyncMessage() != nil {
@@ -811,7 +814,7 @@ func (cli *Client) handleProtocolMessage(ctx context.Context, info *types.Messag
811
814
  }
812
815
 
813
816
  if info.Category == "peer" {
814
- go cli.sendProtocolMessageReceipt(info.ID, types.ReceiptTypePeerMsg)
817
+ go cli.sendProtocolMessageReceipt(ctx, info.ID, types.ReceiptTypePeerMsg)
815
818
  }
816
819
  return
817
820
  }
@@ -1024,17 +1027,16 @@ func (cli *Client) handleDecryptedMessage(ctx context.Context, info *types.Messa
1024
1027
  return cli.dispatchEvent(evt.UnwrapRaw())
1025
1028
  }
1026
1029
 
1027
- func (cli *Client) sendProtocolMessageReceipt(id types.MessageID, msgType types.ReceiptType) {
1028
- clientID := cli.Store.ID
1029
- if len(id) == 0 || clientID == nil {
1030
+ func (cli *Client) sendProtocolMessageReceipt(ctx context.Context, id types.MessageID, msgType types.ReceiptType) {
1031
+ if len(id) == 0 {
1030
1032
  return
1031
1033
  }
1032
- err := cli.sendNode(waBinary.Node{
1034
+ err := cli.sendNode(ctx, waBinary.Node{
1033
1035
  Tag: "receipt",
1034
1036
  Attrs: waBinary.Attrs{
1035
1037
  "id": string(id),
1036
1038
  "type": string(msgType),
1037
- "to": types.NewJID(clientID.User, types.LegacyUserServer),
1039
+ "to": cli.getOwnID().ToNonAD(),
1038
1040
  },
1039
1041
  Content: nil,
1040
1042
  })
@@ -20,13 +20,13 @@ import (
20
20
  "go.mau.fi/whatsmeow/argo"
21
21
  waBinary "go.mau.fi/whatsmeow/binary"
22
22
  "go.mau.fi/whatsmeow/proto/waWa6"
23
+ "go.mau.fi/whatsmeow/store"
23
24
  "go.mau.fi/whatsmeow/types"
24
25
  )
25
26
 
26
27
  // NewsletterSubscribeLiveUpdates subscribes to receive live updates from a WhatsApp channel temporarily (for the duration returned).
27
28
  func (cli *Client) NewsletterSubscribeLiveUpdates(ctx context.Context, jid types.JID) (time.Duration, error) {
28
- resp, err := cli.sendIQ(infoQuery{
29
- Context: ctx,
29
+ resp, err := cli.sendIQ(ctx, infoQuery{
30
30
  Namespace: "newsletter",
31
31
  Type: iqSet,
32
32
  To: jid,
@@ -45,7 +45,7 @@ func (cli *Client) NewsletterSubscribeLiveUpdates(ctx context.Context, jid types
45
45
  // NewsletterMarkViewed marks a channel message as viewed, incrementing the view counter.
46
46
  //
47
47
  // This is not the same as marking the channel as read on your other devices, use the usual MarkRead function for that.
48
- func (cli *Client) NewsletterMarkViewed(jid types.JID, serverIDs []types.MessageServerID) error {
48
+ func (cli *Client) NewsletterMarkViewed(ctx context.Context, jid types.JID, serverIDs []types.MessageServerID) error {
49
49
  if cli == nil {
50
50
  return ErrClientIsNil
51
51
  }
@@ -60,7 +60,7 @@ func (cli *Client) NewsletterMarkViewed(jid types.JID, serverIDs []types.Message
60
60
  }
61
61
  reqID := cli.generateRequestID()
62
62
  resp := cli.waitResponse(reqID)
63
- err := cli.sendNode(waBinary.Node{
63
+ err := cli.sendNode(ctx, waBinary.Node{
64
64
  Tag: "receipt",
65
65
  Attrs: waBinary.Attrs{
66
66
  "to": jid,
@@ -85,7 +85,7 @@ func (cli *Client) NewsletterMarkViewed(jid types.JID, serverIDs []types.Message
85
85
  // To remove a reaction sent earlier, set reaction to an empty string.
86
86
  //
87
87
  // The last parameter is the message ID of the reaction itself. It can be left empty to let whatsmeow generate a random one.
88
- func (cli *Client) NewsletterSendReaction(jid types.JID, serverID types.MessageServerID, reaction string, messageID types.MessageID) error {
88
+ func (cli *Client) NewsletterSendReaction(ctx context.Context, jid types.JID, serverID types.MessageServerID, reaction string, messageID types.MessageID) error {
89
89
  if messageID == "" {
90
90
  messageID = cli.GenerateMessageID()
91
91
  }
@@ -101,7 +101,7 @@ func (cli *Client) NewsletterSendReaction(jid types.JID, serverID types.MessageS
101
101
  } else {
102
102
  messageAttrs["edit"] = string(types.EditAttributeSenderRevoke)
103
103
  }
104
- return cli.sendNode(waBinary.Node{
104
+ return cli.sendNode(ctx, waBinary.Node{
105
105
  Tag: "message",
106
106
  Attrs: messageAttrs,
107
107
  Content: []waBinary.Node{{
@@ -170,6 +170,9 @@ func convertQueryID(cli *Client, queryID string) string {
170
170
  }
171
171
 
172
172
  func (cli *Client) sendMexIQ(ctx context.Context, queryID string, variables any) (json.RawMessage, error) {
173
+ if store.BaseClientPayload.GetUserAgent().GetPlatform() == waWa6.ClientPayload_UserAgent_MACOS {
174
+ return nil, fmt.Errorf("argo decoding is currently broken")
175
+ }
173
176
  queryID = convertQueryID(cli, queryID)
174
177
  payload, err := json.Marshal(map[string]any{
175
178
  "variables": variables,
@@ -177,7 +180,7 @@ func (cli *Client) sendMexIQ(ctx context.Context, queryID string, variables any)
177
180
  if err != nil {
178
181
  return nil, err
179
182
  }
180
- resp, err := cli.sendIQ(infoQuery{
183
+ resp, err := cli.sendIQ(ctx, infoQuery{
181
184
  Namespace: "w:mex",
182
185
  Type: iqGet,
183
186
  To: types.ServerJID,
@@ -188,7 +191,6 @@ func (cli *Client) sendMexIQ(ctx context.Context, queryID string, variables any)
188
191
  },
189
192
  Content: payload,
190
193
  }},
191
- Context: ctx,
192
194
  })
193
195
  if err != nil {
194
196
  return nil, err
@@ -202,6 +204,9 @@ func (cli *Client) sendMexIQ(ctx context.Context, queryID string, variables any)
202
204
  return nil, fmt.Errorf("unexpected content type %T in mex response", result.Content)
203
205
  }
204
206
  if result.AttrGetter().OptionalString("format") == "argo" {
207
+ if true {
208
+ return nil, fmt.Errorf("argo decoding is currently broken")
209
+ }
205
210
  store, err := argo.GetStore()
206
211
  if err != nil {
207
212
  return nil, err
@@ -241,8 +246,8 @@ type respGetNewsletterInfo struct {
241
246
  Newsletter *types.NewsletterMetadata `json:"xwa2_newsletter"`
242
247
  }
243
248
 
244
- func (cli *Client) getNewsletterInfo(input map[string]any, fetchViewerMeta bool) (*types.NewsletterMetadata, error) {
245
- data, err := cli.sendMexIQ(context.TODO(), queryFetchNewsletter, map[string]any{
249
+ func (cli *Client) getNewsletterInfo(ctx context.Context, input map[string]any, fetchViewerMeta bool) (*types.NewsletterMetadata, error) {
250
+ data, err := cli.sendMexIQ(ctx, queryFetchNewsletter, map[string]any{
246
251
  "fetch_creation_time": true,
247
252
  "fetch_full_image": true,
248
253
  "fetch_viewer_metadata": fetchViewerMeta,
@@ -259,8 +264,8 @@ func (cli *Client) getNewsletterInfo(input map[string]any, fetchViewerMeta bool)
259
264
  }
260
265
 
261
266
  // GetNewsletterInfo gets the info of a newsletter that you're joined to.
262
- func (cli *Client) GetNewsletterInfo(jid types.JID) (*types.NewsletterMetadata, error) {
263
- return cli.getNewsletterInfo(map[string]any{
267
+ func (cli *Client) GetNewsletterInfo(ctx context.Context, jid types.JID) (*types.NewsletterMetadata, error) {
268
+ return cli.getNewsletterInfo(ctx, map[string]any{
264
269
  "key": jid.String(),
265
270
  "type": types.NewsletterKeyTypeJID,
266
271
  }, true)
@@ -271,8 +276,8 @@ func (cli *Client) GetNewsletterInfo(jid types.JID) (*types.NewsletterMetadata,
271
276
  // You can either pass the full link (https://whatsapp.com/channel/...) or just the `...` part.
272
277
  //
273
278
  // Note that the ViewerMeta field of the returned NewsletterMetadata will be nil.
274
- func (cli *Client) GetNewsletterInfoWithInvite(key string) (*types.NewsletterMetadata, error) {
275
- return cli.getNewsletterInfo(map[string]any{
279
+ func (cli *Client) GetNewsletterInfoWithInvite(ctx context.Context, key string) (*types.NewsletterMetadata, error) {
280
+ return cli.getNewsletterInfo(ctx, map[string]any{
276
281
  "key": strings.TrimPrefix(key, NewsletterLinkPrefix),
277
282
  "type": types.NewsletterKeyTypeInvite,
278
283
  }, false)
@@ -283,8 +288,8 @@ type respGetSubscribedNewsletters struct {
283
288
  }
284
289
 
285
290
  // GetSubscribedNewsletters gets the info of all newsletters that you're joined to.
286
- func (cli *Client) GetSubscribedNewsletters() ([]*types.NewsletterMetadata, error) {
287
- data, err := cli.sendMexIQ(context.TODO(), querySubscribedNewsletters, map[string]any{})
291
+ func (cli *Client) GetSubscribedNewsletters(ctx context.Context) ([]*types.NewsletterMetadata, error) {
292
+ data, err := cli.sendMexIQ(ctx, querySubscribedNewsletters, map[string]any{})
288
293
  var respData respGetSubscribedNewsletters
289
294
  if data != nil {
290
295
  jsonErr := json.Unmarshal(data, &respData)
@@ -306,8 +311,8 @@ type respCreateNewsletter struct {
306
311
  }
307
312
 
308
313
  // CreateNewsletter creates a new WhatsApp channel.
309
- func (cli *Client) CreateNewsletter(params CreateNewsletterParams) (*types.NewsletterMetadata, error) {
310
- resp, err := cli.sendMexIQ(context.TODO(), mutationCreateNewsletter, map[string]any{
314
+ func (cli *Client) CreateNewsletter(ctx context.Context, params CreateNewsletterParams) (*types.NewsletterMetadata, error) {
315
+ resp, err := cli.sendMexIQ(ctx, mutationCreateNewsletter, map[string]any{
311
316
  "newsletter_input": &params,
312
317
  })
313
318
  if err != nil {
@@ -326,8 +331,8 @@ func (cli *Client) CreateNewsletter(params CreateNewsletterParams) (*types.Newsl
326
331
  // To accept the terms for creating newsletters, use
327
332
  //
328
333
  // cli.AcceptTOSNotice("20601218", "5")
329
- func (cli *Client) AcceptTOSNotice(noticeID, stage string) error {
330
- _, err := cli.sendIQ(infoQuery{
334
+ func (cli *Client) AcceptTOSNotice(ctx context.Context, noticeID, stage string) error {
335
+ _, err := cli.sendIQ(ctx, infoQuery{
331
336
  Namespace: "tos",
332
337
  Type: iqSet,
333
338
  To: types.ServerJID,
@@ -343,28 +348,28 @@ func (cli *Client) AcceptTOSNotice(noticeID, stage string) error {
343
348
  }
344
349
 
345
350
  // NewsletterToggleMute changes the mute status of a newsletter.
346
- func (cli *Client) NewsletterToggleMute(jid types.JID, mute bool) error {
351
+ func (cli *Client) NewsletterToggleMute(ctx context.Context, jid types.JID, mute bool) error {
347
352
  query := mutationUnmuteNewsletter
348
353
  if mute {
349
354
  query = mutationMuteNewsletter
350
355
  }
351
- _, err := cli.sendMexIQ(context.TODO(), query, map[string]any{
356
+ _, err := cli.sendMexIQ(ctx, query, map[string]any{
352
357
  "newsletter_id": jid.String(),
353
358
  })
354
359
  return err
355
360
  }
356
361
 
357
362
  // FollowNewsletter makes the user follow (join) a WhatsApp channel.
358
- func (cli *Client) FollowNewsletter(jid types.JID) error {
359
- _, err := cli.sendMexIQ(context.TODO(), mutationFollowNewsletter, map[string]any{
363
+ func (cli *Client) FollowNewsletter(ctx context.Context, jid types.JID) error {
364
+ _, err := cli.sendMexIQ(ctx, mutationFollowNewsletter, map[string]any{
360
365
  "newsletter_id": jid.String(),
361
366
  })
362
367
  return err
363
368
  }
364
369
 
365
370
  // UnfollowNewsletter makes the user unfollow (leave) a WhatsApp channel.
366
- func (cli *Client) UnfollowNewsletter(jid types.JID) error {
367
- _, err := cli.sendMexIQ(context.TODO(), mutationUnfollowNewsletter, map[string]any{
371
+ func (cli *Client) UnfollowNewsletter(ctx context.Context, jid types.JID) error {
372
+ _, err := cli.sendMexIQ(ctx, mutationUnfollowNewsletter, map[string]any{
368
373
  "newsletter_id": jid.String(),
369
374
  })
370
375
  return err
@@ -376,7 +381,7 @@ type GetNewsletterMessagesParams struct {
376
381
  }
377
382
 
378
383
  // GetNewsletterMessages gets messages in a WhatsApp channel.
379
- func (cli *Client) GetNewsletterMessages(jid types.JID, params *GetNewsletterMessagesParams) ([]*types.NewsletterMessage, error) {
384
+ func (cli *Client) GetNewsletterMessages(ctx context.Context, jid types.JID, params *GetNewsletterMessagesParams) ([]*types.NewsletterMessage, error) {
380
385
  attrs := waBinary.Attrs{
381
386
  "type": "jid",
382
387
  "jid": jid,
@@ -389,7 +394,7 @@ func (cli *Client) GetNewsletterMessages(jid types.JID, params *GetNewsletterMes
389
394
  attrs["before"] = params.Before
390
395
  }
391
396
  }
392
- resp, err := cli.sendIQ(infoQuery{
397
+ resp, err := cli.sendIQ(ctx, infoQuery{
393
398
  Namespace: "newsletter",
394
399
  Type: iqGet,
395
400
  To: types.ServerJID,
@@ -397,7 +402,6 @@ func (cli *Client) GetNewsletterMessages(jid types.JID, params *GetNewsletterMes
397
402
  Tag: "messages",
398
403
  Attrs: attrs,
399
404
  }},
400
- Context: context.TODO(),
401
405
  })
402
406
  if err != nil {
403
407
  return nil, err
@@ -418,7 +422,7 @@ type GetNewsletterUpdatesParams struct {
418
422
  // GetNewsletterMessageUpdates gets updates in a WhatsApp channel.
419
423
  //
420
424
  // These are the same kind of updates that NewsletterSubscribeLiveUpdates triggers (reaction and view counts).
421
- func (cli *Client) GetNewsletterMessageUpdates(jid types.JID, params *GetNewsletterUpdatesParams) ([]*types.NewsletterMessage, error) {
425
+ func (cli *Client) GetNewsletterMessageUpdates(ctx context.Context, jid types.JID, params *GetNewsletterUpdatesParams) ([]*types.NewsletterMessage, error) {
422
426
  attrs := waBinary.Attrs{}
423
427
  if params != nil {
424
428
  if params.Count != 0 {
@@ -431,7 +435,7 @@ func (cli *Client) GetNewsletterMessageUpdates(jid types.JID, params *GetNewslet
431
435
  attrs["after"] = params.After
432
436
  }
433
437
  }
434
- resp, err := cli.sendIQ(infoQuery{
438
+ resp, err := cli.sendIQ(ctx, infoQuery{
435
439
  Namespace: "newsletter",
436
440
  Type: iqGet,
437
441
  To: jid,
@@ -439,7 +443,6 @@ func (cli *Client) GetNewsletterMessageUpdates(jid types.JID, params *GetNewslet
439
443
  Tag: "message_updates",
440
444
  Attrs: attrs,
441
445
  }},
442
- Context: context.TODO(),
443
446
  })
444
447
  if err != nil {
445
448
  return nil, err
@@ -34,7 +34,7 @@ func (cli *Client) handleEncryptNotification(ctx context.Context, node *waBinary
34
34
  }
35
35
  cli.Log.Infof("Got prekey count from server: %s", node.XMLString())
36
36
  if otksLeft < MinPreKeyCount {
37
- cli.uploadPreKeys(ctx)
37
+ cli.uploadPreKeys(ctx, false)
38
38
  }
39
39
  } else if _, ok := node.GetOptionalChildByTag("identity"); ok {
40
40
  cli.Log.Debugf("Got identity change for %s: %s, deleting all identities/sessions for that number", from, node.XMLString())
@@ -409,8 +409,7 @@ func (cli *Client) handleStatusNotification(ctx context.Context, node *waBinary.
409
409
  })
410
410
  }
411
411
 
412
- func (cli *Client) handleNotification(node *waBinary.Node) {
413
- ctx := cli.BackgroundEventCtx
412
+ func (cli *Client) handleNotification(ctx context.Context, node *waBinary.Node) {
414
413
  ag := node.AttrGetter()
415
414
  notifType := ag.String("type")
416
415
  if !ag.OK() {
@@ -99,11 +99,10 @@ func (cli *Client) PairPhone(ctx context.Context, phone string, showPushNotifica
99
99
  return "", ErrPhoneNumberIsNotInternational
100
100
  }
101
101
  jid := types.NewJID(phone, types.DefaultUserServer)
102
- resp, err := cli.sendIQ(infoQuery{
102
+ resp, err := cli.sendIQ(ctx, infoQuery{
103
103
  Namespace: "md",
104
104
  Type: iqSet,
105
105
  To: types.ServerJID,
106
- Context: ctx,
107
106
  Content: []waBinary.Node{{
108
107
  Tag: "link_code_companion_reg",
109
108
  Attrs: waBinary.Attrs{
@@ -223,11 +222,10 @@ func (cli *Client) handleCodePairNotification(ctx context.Context, parentNode *w
223
222
  advSecret := hkdfutil.SHA256(advSecretInput, nil, []byte("adv_secret"), 32)
224
223
  cli.Store.AdvSecretKey = advSecret
225
224
 
226
- _, err = cli.sendIQ(infoQuery{
225
+ _, err = cli.sendIQ(ctx, infoQuery{
227
226
  Namespace: "md",
228
227
  Type: iqSet,
229
228
  To: types.ServerJID,
230
- Context: ctx,
231
229
  Content: []waBinary.Node{{
232
230
  Tag: "link_code_companion_reg",
233
231
  Attrs: waBinary.Attrs{
@@ -33,22 +33,22 @@ var (
33
33
  AdvHostedDeviceSignaturePrefix = []byte{6, 6}
34
34
  )
35
35
 
36
- func (cli *Client) handleIQ(node *waBinary.Node) {
36
+ func (cli *Client) handleIQ(ctx context.Context, node *waBinary.Node) {
37
37
  children := node.GetChildren()
38
38
  if len(children) != 1 || node.Attrs["from"] != types.ServerJID {
39
39
  return
40
40
  }
41
41
  switch children[0].Tag {
42
42
  case "pair-device":
43
- cli.handlePairDevice(node)
43
+ cli.handlePairDevice(ctx, node)
44
44
  case "pair-success":
45
- cli.handlePairSuccess(node)
45
+ cli.handlePairSuccess(ctx, node)
46
46
  }
47
47
  }
48
48
 
49
- func (cli *Client) handlePairDevice(node *waBinary.Node) {
49
+ func (cli *Client) handlePairDevice(ctx context.Context, node *waBinary.Node) {
50
50
  pairDevice := node.GetChildByTag("pair-device")
51
- err := cli.sendNode(waBinary.Node{
51
+ err := cli.sendNode(ctx, waBinary.Node{
52
52
  Tag: "iq",
53
53
  Attrs: waBinary.Attrs{
54
54
  "to": node.Attrs["from"],
@@ -84,7 +84,7 @@ func (cli *Client) makeQRData(ref string) string {
84
84
  return strings.Join([]string{ref, noise, identity, adv}, ",")
85
85
  }
86
86
 
87
- func (cli *Client) handlePairSuccess(node *waBinary.Node) {
87
+ func (cli *Client) handlePairSuccess(ctx context.Context, node *waBinary.Node) {
88
88
  id := node.Attrs["id"].(string)
89
89
  pairSuccess := node.GetChildByTag("pair-success")
90
90
 
@@ -95,7 +95,7 @@ func (cli *Client) handlePairSuccess(node *waBinary.Node) {
95
95
  platform, _ := pairSuccess.GetChildByTag("platform").Attrs["name"].(string)
96
96
 
97
97
  go func() {
98
- err := cli.handlePair(context.TODO(), deviceIdentityBytes, id, businessName, platform, jid, lid)
98
+ err := cli.handlePair(ctx, deviceIdentityBytes, id, businessName, platform, jid, lid)
99
99
  if err != nil {
100
100
  cli.Log.Errorf("Failed to pair device: %v", err)
101
101
  cli.Disconnect()
@@ -111,7 +111,7 @@ func (cli *Client) handlePair(ctx context.Context, deviceIdentityBytes []byte, r
111
111
  var deviceIdentityContainer waAdv.ADVSignedDeviceIdentityHMAC
112
112
  err := proto.Unmarshal(deviceIdentityBytes, &deviceIdentityContainer)
113
113
  if err != nil {
114
- cli.sendPairError(reqID, 500, "internal-error")
114
+ cli.sendPairError(ctx, reqID, 500, "internal-error")
115
115
  return &PairProtoError{"failed to parse device identity container in pair success message", err}
116
116
  }
117
117
 
@@ -124,33 +124,33 @@ func (cli *Client) handlePair(ctx context.Context, deviceIdentityBytes []byte, r
124
124
 
125
125
  if !bytes.Equal(h.Sum(nil), deviceIdentityContainer.HMAC) {
126
126
  cli.Log.Warnf("Invalid HMAC from pair success message")
127
- cli.sendPairError(reqID, 401, "hmac-mismatch")
127
+ cli.sendPairError(ctx, reqID, 401, "hmac-mismatch")
128
128
  return ErrPairInvalidDeviceIdentityHMAC
129
129
  }
130
130
 
131
131
  var deviceIdentity waAdv.ADVSignedDeviceIdentity
132
132
  err = proto.Unmarshal(deviceIdentityContainer.Details, &deviceIdentity)
133
133
  if err != nil {
134
- cli.sendPairError(reqID, 500, "internal-error")
134
+ cli.sendPairError(ctx, reqID, 500, "internal-error")
135
135
  return &PairProtoError{"failed to parse signed device identity in pair success message", err}
136
136
  }
137
137
 
138
138
  var deviceIdentityDetails waAdv.ADVDeviceIdentity
139
139
  err = proto.Unmarshal(deviceIdentity.Details, &deviceIdentityDetails)
140
140
  if err != nil {
141
- cli.sendPairError(reqID, 500, "internal-error")
141
+ cli.sendPairError(ctx, reqID, 500, "internal-error")
142
142
  return &PairProtoError{"failed to parse device identity details in pair success message", err}
143
143
  }
144
144
 
145
145
  if !verifyAccountSignature(&deviceIdentity, cli.Store.IdentityKey, deviceIdentityDetails.GetDeviceType() == waAdv.ADVEncryptionType_HOSTED) {
146
- cli.sendPairError(reqID, 401, "signature-mismatch")
146
+ cli.sendPairError(ctx, reqID, 401, "signature-mismatch")
147
147
  return ErrPairInvalidDeviceSignature
148
148
  }
149
149
 
150
150
  deviceIdentity.DeviceSignature = generateDeviceSignature(&deviceIdentity, cli.Store.IdentityKey)[:]
151
151
 
152
152
  if cli.PrePairCallback != nil && !cli.PrePairCallback(jid, platform, businessName) {
153
- cli.sendPairError(reqID, 500, "internal-error")
153
+ cli.sendPairError(ctx, reqID, 500, "internal-error")
154
154
  return ErrPairRejectedLocally
155
155
  }
156
156
 
@@ -163,7 +163,7 @@ func (cli *Client) handlePair(ctx context.Context, deviceIdentityBytes []byte, r
163
163
 
164
164
  selfSignedDeviceIdentity, err := proto.Marshal(&deviceIdentity)
165
165
  if err != nil {
166
- cli.sendPairError(reqID, 500, "internal-error")
166
+ cli.sendPairError(ctx, reqID, 500, "internal-error")
167
167
  return &PairProtoError{"failed to marshal self-signed device identity", err}
168
168
  }
169
169
 
@@ -173,21 +173,21 @@ func (cli *Client) handlePair(ctx context.Context, deviceIdentityBytes []byte, r
173
173
  cli.Store.Platform = platform
174
174
  err = cli.Store.Save(ctx)
175
175
  if err != nil {
176
- cli.sendPairError(reqID, 500, "internal-error")
176
+ cli.sendPairError(ctx, reqID, 500, "internal-error")
177
177
  return &PairDatabaseError{"failed to save device store", err}
178
178
  }
179
179
  cli.StoreLIDPNMapping(ctx, lid, jid)
180
180
  err = cli.Store.Identities.PutIdentity(ctx, mainDeviceLID.SignalAddress().String(), mainDeviceIdentity)
181
181
  if err != nil {
182
182
  _ = cli.Store.Delete(ctx)
183
- cli.sendPairError(reqID, 500, "internal-error")
183
+ cli.sendPairError(ctx, reqID, 500, "internal-error")
184
184
  return &PairDatabaseError{"failed to store main device identity", err}
185
185
  }
186
186
 
187
187
  // Expect a disconnect after this and don't dispatch the usual Disconnected event
188
188
  cli.expectDisconnect()
189
189
 
190
- err = cli.sendNode(waBinary.Node{
190
+ err = cli.sendNode(ctx, waBinary.Node{
191
191
  Tag: "iq",
192
192
  Attrs: waBinary.Attrs{
193
193
  "to": types.ServerJID,
@@ -249,8 +249,8 @@ func generateDeviceSignature(deviceIdentity *waAdv.ADVSignedDeviceIdentity, ikp
249
249
  return &sig
250
250
  }
251
251
 
252
- func (cli *Client) sendPairError(id string, code int, text string) {
253
- err := cli.sendNode(waBinary.Node{
252
+ func (cli *Client) sendPairError(ctx context.Context, id string, code int, text string) {
253
+ err := cli.sendNode(ctx, waBinary.Node{
254
254
  Tag: "iq",
255
255
  Attrs: waBinary.Attrs{
256
256
  "to": types.ServerJID,