slidge-whatsapp 0.2.5__cp311-cp311-manylinux_2_36_aarch64.whl → 0.2.7__cp311-cp311-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.

Files changed (357) hide show
  1. slidge_whatsapp/config.py +3 -0
  2. slidge_whatsapp/event.go +31 -26
  3. slidge_whatsapp/gateway.go +13 -9
  4. slidge_whatsapp/gateway.py +2 -2
  5. slidge_whatsapp/generated/_whatsapp.cpython-311-aarch64-linux-gnu.h +170 -170
  6. slidge_whatsapp/generated/_whatsapp.cpython-311-aarch64-linux-gnu.so +0 -0
  7. slidge_whatsapp/generated/build.py +135 -135
  8. slidge_whatsapp/generated/whatsapp.c +1496 -1496
  9. slidge_whatsapp/generated/whatsapp.go +1137 -1137
  10. slidge_whatsapp/generated/whatsapp.py +1216 -1216
  11. slidge_whatsapp/generated/whatsapp_go.h +170 -170
  12. slidge_whatsapp/go.mod +15 -12
  13. slidge_whatsapp/go.sum +35 -29
  14. slidge_whatsapp/media/media.go +21 -11
  15. slidge_whatsapp/session.go +73 -66
  16. slidge_whatsapp/vendor/github.com/ebitengine/purego/dlfcn.go +4 -4
  17. slidge_whatsapp/vendor/github.com/ebitengine/purego/dlfcn_darwin.go +0 -5
  18. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/go_libinit.go +3 -0
  19. slidge_whatsapp/vendor/github.com/ebitengine/purego/internal/fakecgo/symbols.go +40 -20
  20. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/CHANGELOG.md +14 -1
  21. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/ffi.go +2 -2
  22. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/fun.go +10 -2
  23. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/lib.go +1 -1
  24. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/lib_unix.go +1 -1
  25. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/lib_windows.go +1 -1
  26. slidge_whatsapp/vendor/github.com/mattn/go-sqlite3/README.md +2 -7
  27. slidge_whatsapp/vendor/github.com/mattn/go-sqlite3/callback.go +2 -1
  28. slidge_whatsapp/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c +8510 -5090
  29. slidge_whatsapp/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.h +344 -150
  30. slidge_whatsapp/vendor/github.com/mattn/go-sqlite3/sqlite3.go +57 -23
  31. slidge_whatsapp/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_unlock_notify.c +4 -0
  32. slidge_whatsapp/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_unlock_notify.go +4 -0
  33. slidge_whatsapp/vendor/github.com/petermattis/goid/.gitignore +4 -0
  34. slidge_whatsapp/vendor/github.com/petermattis/goid/LICENSE +202 -0
  35. slidge_whatsapp/vendor/github.com/petermattis/goid/README.md +4 -0
  36. slidge_whatsapp/vendor/github.com/petermattis/goid/goid.go +35 -0
  37. slidge_whatsapp/vendor/github.com/petermattis/goid/goid_gccgo.go +26 -0
  38. slidge_whatsapp/vendor/github.com/petermattis/goid/goid_go1.3.c +23 -0
  39. slidge_whatsapp/vendor/github.com/petermattis/goid/goid_go1.3.go +22 -0
  40. slidge_whatsapp/vendor/github.com/petermattis/goid/goid_go1.4.go +35 -0
  41. slidge_whatsapp/vendor/github.com/petermattis/goid/goid_go1.4.s +18 -0
  42. slidge_whatsapp/vendor/github.com/petermattis/goid/goid_go1.5.go +28 -0
  43. slidge_whatsapp/vendor/github.com/petermattis/goid/goid_go1.5.s +44 -0
  44. slidge_whatsapp/vendor/github.com/petermattis/goid/goid_slow.go +24 -0
  45. slidge_whatsapp/vendor/github.com/petermattis/goid/runtime_gccgo_go1.8.go +17 -0
  46. slidge_whatsapp/vendor/github.com/petermattis/goid/runtime_go1.23.go +38 -0
  47. slidge_whatsapp/vendor/github.com/petermattis/goid/runtime_go1.5.go +57 -0
  48. slidge_whatsapp/vendor/github.com/petermattis/goid/runtime_go1.6.go +43 -0
  49. slidge_whatsapp/vendor/github.com/petermattis/goid/runtime_go1.9.go +37 -0
  50. slidge_whatsapp/vendor/github.com/rs/zerolog/CONTRIBUTING.md +43 -0
  51. slidge_whatsapp/vendor/github.com/rs/zerolog/README.md +31 -0
  52. slidge_whatsapp/vendor/github.com/rs/zerolog/console.go +20 -5
  53. slidge_whatsapp/vendor/github.com/rs/zerolog/log/log.go +131 -0
  54. slidge_whatsapp/vendor/github.com/rs/zerolog/log.go +1 -1
  55. slidge_whatsapp/vendor/github.com/rs/zerolog/sampler.go +4 -1
  56. slidge_whatsapp/vendor/github.com/rs/zerolog/writer.go +9 -0
  57. slidge_whatsapp/vendor/go.mau.fi/libsignal/groups/GroupCipher.go +17 -6
  58. slidge_whatsapp/vendor/go.mau.fi/libsignal/groups/GroupSessionBuilder.go +17 -7
  59. slidge_whatsapp/vendor/go.mau.fi/libsignal/groups/state/store/SenderKeyStore.go +4 -2
  60. slidge_whatsapp/vendor/go.mau.fi/libsignal/keys/chain/ChainKey.go +1 -0
  61. slidge_whatsapp/vendor/go.mau.fi/libsignal/keys/identity/IdentityKey.go +1 -0
  62. slidge_whatsapp/vendor/go.mau.fi/libsignal/logger/DefaultLogger.go +2 -2
  63. slidge_whatsapp/vendor/go.mau.fi/libsignal/serialize/FingerprintProtocol.pb.go +3 -2
  64. slidge_whatsapp/vendor/go.mau.fi/libsignal/serialize/LocalStorageProtocol.pb.go +3 -2
  65. slidge_whatsapp/vendor/go.mau.fi/libsignal/serialize/WhisperTextProtocol.pb.go +3 -2
  66. slidge_whatsapp/vendor/go.mau.fi/libsignal/session/Session.go +41 -17
  67. slidge_whatsapp/vendor/go.mau.fi/libsignal/session/SessionCipher.go +64 -30
  68. slidge_whatsapp/vendor/go.mau.fi/libsignal/state/store/IdentityKeyStore.go +5 -3
  69. slidge_whatsapp/vendor/go.mau.fi/libsignal/state/store/MessageKeyStore.go +6 -4
  70. slidge_whatsapp/vendor/go.mau.fi/libsignal/state/store/PreKeyStore.go +6 -4
  71. slidge_whatsapp/vendor/go.mau.fi/libsignal/state/store/SessionStore.go +8 -6
  72. slidge_whatsapp/vendor/go.mau.fi/libsignal/state/store/SignedPreKeyStore.go +7 -5
  73. slidge_whatsapp/vendor/go.mau.fi/util/dbutil/connlog.go +257 -0
  74. slidge_whatsapp/vendor/go.mau.fi/util/dbutil/database.go +309 -0
  75. slidge_whatsapp/vendor/go.mau.fi/util/dbutil/iter.go +233 -0
  76. slidge_whatsapp/vendor/go.mau.fi/util/dbutil/json.go +47 -0
  77. slidge_whatsapp/vendor/go.mau.fi/util/dbutil/log.go +129 -0
  78. slidge_whatsapp/vendor/go.mau.fi/util/dbutil/massinsert.go +164 -0
  79. slidge_whatsapp/vendor/go.mau.fi/util/dbutil/queryhelper.go +137 -0
  80. slidge_whatsapp/vendor/go.mau.fi/util/dbutil/reflectscan.go +30 -0
  81. slidge_whatsapp/vendor/go.mau.fi/util/dbutil/transaction.go +180 -0
  82. slidge_whatsapp/vendor/go.mau.fi/util/dbutil/upgrades.go +250 -0
  83. slidge_whatsapp/vendor/go.mau.fi/util/dbutil/upgradetable.go +331 -0
  84. slidge_whatsapp/vendor/go.mau.fi/util/exerrors/dualerror.go +33 -0
  85. slidge_whatsapp/vendor/go.mau.fi/util/exerrors/must.go +23 -0
  86. slidge_whatsapp/vendor/go.mau.fi/util/exhttp/cors.go +32 -0
  87. slidge_whatsapp/vendor/go.mau.fi/util/exhttp/handleerrors.go +64 -0
  88. slidge_whatsapp/vendor/go.mau.fi/util/exhttp/json.go +36 -0
  89. slidge_whatsapp/vendor/go.mau.fi/util/exhttp/middleware.go +30 -0
  90. slidge_whatsapp/vendor/go.mau.fi/util/exhttp/networkerror.go +37 -0
  91. slidge_whatsapp/vendor/go.mau.fi/util/exstrings/stringutil.go +76 -0
  92. slidge_whatsapp/vendor/go.mau.fi/util/exsync/event.go +88 -0
  93. slidge_whatsapp/vendor/go.mau.fi/util/exsync/returnonce.go +25 -0
  94. slidge_whatsapp/vendor/go.mau.fi/util/exsync/ringbuffer.go +139 -0
  95. slidge_whatsapp/vendor/go.mau.fi/util/exsync/syncmap.go +94 -0
  96. slidge_whatsapp/vendor/go.mau.fi/util/exsync/syncset.go +136 -0
  97. slidge_whatsapp/vendor/go.mau.fi/util/exzerolog/callermarshal.go +28 -0
  98. slidge_whatsapp/vendor/go.mau.fi/util/exzerolog/defaults.go +32 -0
  99. slidge_whatsapp/vendor/go.mau.fi/util/exzerolog/generics.go +45 -0
  100. slidge_whatsapp/vendor/go.mau.fi/util/exzerolog/writer.go +81 -0
  101. slidge_whatsapp/vendor/go.mau.fi/util/ptr/ptr.go +43 -0
  102. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate/decode.go +27 -26
  103. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate/encode.go +4 -3
  104. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate/keys.go +5 -4
  105. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate.go +27 -25
  106. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/armadillomessage.go +40 -7
  107. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/binary/encoder.go +1 -1
  108. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/broadcast.go +5 -4
  109. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/call.go +1 -1
  110. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/client.go +119 -37
  111. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/connectionevents.go +29 -11
  112. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/download-to-file.go +63 -30
  113. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/download.go +74 -34
  114. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/errors.go +1 -0
  115. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/group.go +61 -31
  116. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/internals.go +188 -152
  117. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/keepalive.go +3 -2
  118. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/mediaconn.go +5 -3
  119. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/mediaretry.go +2 -1
  120. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/message.go +444 -135
  121. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/msgsecret.go +118 -31
  122. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/notification.go +78 -42
  123. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/pair-code.go +7 -4
  124. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/pair.go +42 -18
  125. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/prekeys.go +9 -5
  126. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/presence.go +2 -1
  127. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/privacysettings.go +10 -11
  128. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/extra.go +7 -0
  129. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloAddMessage/InstamadilloAddMessage.pb.go +983 -0
  130. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloAddMessage/InstamadilloAddMessage.proto +85 -0
  131. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloAddMessage/extra.go +3 -0
  132. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeActionLog/InstamadilloCoreTypeActionLog.pb.go +197 -0
  133. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeActionLog/InstamadilloCoreTypeActionLog.proto +13 -0
  134. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeAdminMessage/InstamadilloCoreTypeAdminMessage.pb.go +279 -0
  135. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeAdminMessage/InstamadilloCoreTypeAdminMessage.proto +21 -0
  136. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeCollection/InstamadilloCoreTypeCollection.pb.go +137 -0
  137. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeCollection/InstamadilloCoreTypeCollection.proto +10 -0
  138. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeLink/InstamadilloCoreTypeLink.pb.go +313 -0
  139. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeLink/InstamadilloCoreTypeLink.proto +27 -0
  140. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeMedia/InstamadilloCoreTypeMedia.pb.go +1299 -0
  141. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeMedia/InstamadilloCoreTypeMedia.proto +112 -0
  142. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeText/InstamadilloCoreTypeText.pb.go +514 -0
  143. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeText/InstamadilloCoreTypeText.proto +47 -0
  144. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloDeleteMessage/InstamadilloDeleteMessage.pb.go +123 -0
  145. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloDeleteMessage/InstamadilloDeleteMessage.proto +7 -0
  146. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloDeleteMessage/extra.go +3 -0
  147. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloSupplementMessage/InstamadilloSupplementMessage.pb.go +720 -0
  148. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloSupplementMessage/InstamadilloSupplementMessage.proto +59 -0
  149. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloSupplementMessage/extra.go +3 -0
  150. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloTransportPayload/InstamadilloTransportPayload.pb.go +365 -0
  151. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloTransportPayload/InstamadilloTransportPayload.proto +33 -0
  152. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloXmaContentRef/InstamadilloXmaContentRef.pb.go +1238 -0
  153. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloXmaContentRef/InstamadilloXmaContentRef.proto +105 -0
  154. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waAdv/WAAdv.pb.go +39 -9
  155. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waArmadilloApplication/WAArmadilloApplication.pb.go +354 -175
  156. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waArmadilloApplication/WAArmadilloApplication.proto +5 -5
  157. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waArmadilloXMA/WAArmadilloXMA.pb.go +170 -15
  158. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waArmadilloXMA/WAArmadilloXMA.proto +4 -0
  159. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCert/WACert.pb.go +29 -9
  160. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waChatLockSettings/WAProtobufsChatLockSettings.pb.go +13 -9
  161. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCommon/WACommon.pb.go +344 -31
  162. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCommon/WACommon.proto +26 -0
  163. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCompanionReg/{WAWebProtobufsCompanionReg.pb.go → WACompanionReg.pb.go} +184 -89
  164. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCompanionReg/{WAWebProtobufsCompanionReg.proto → WACompanionReg.proto} +2 -1
  165. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waConsumerApplication/WAConsumerApplication.pb.go +173 -9
  166. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waDeviceCapabilities/WAProtobufsDeviceCapabilities.pb.go +78 -16
  167. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waDeviceCapabilities/WAProtobufsDeviceCapabilities.proto +5 -0
  168. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.pb.go +7428 -2151
  169. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.proto +373 -44
  170. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waHistorySync/WAWebProtobufsHistorySync.pb.go +456 -135
  171. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waHistorySync/WAWebProtobufsHistorySync.proto +14 -0
  172. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waLidMigrationSyncPayload/WAWebProtobufLidMigrationSyncPayload.pb.go +198 -0
  173. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waLidMigrationSyncPayload/WAWebProtobufLidMigrationSyncPayload.proto +14 -0
  174. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMediaTransport/WAMediaTransport.pb.go +162 -9
  175. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMediaTransport/WAMediaTransport.proto +1 -0
  176. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMmsRetry/WAMmsRetry.pb.go +32 -9
  177. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMmsRetry/WAMmsRetry.proto +1 -0
  178. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMsgApplication/WAMsgApplication.pb.go +192 -52
  179. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMsgApplication/WAMsgApplication.proto +8 -0
  180. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMsgTransport/WAMsgTransport.pb.go +60 -9
  181. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMsgTransport/extra.go +7 -6
  182. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMultiDevice/WAMultiDevice.pb.go +39 -9
  183. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waServerSync/WAServerSync.pb.go +61 -9
  184. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.pb.go +800 -0
  185. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.proto +72 -0
  186. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.pb.go +1344 -438
  187. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.proto +52 -0
  188. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waUserPassword/WAProtobufsUserPassword.pb.go +27 -9
  189. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waVnameCert/WAWebProtobufsVnameCert.pb.go +59 -9
  190. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWa6/WAWebProtobufsWa6.pb.go +382 -78
  191. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWa6/WAWebProtobufsWa6.proto +8 -0
  192. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWeb/WAWebProtobufsWeb.pb.go +563 -9
  193. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWeb/WAWebProtobufsWeb.proto +4 -0
  194. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/receipt.go +25 -9
  195. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/reportingfields.json +1 -0
  196. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/reportingtoken.go +176 -0
  197. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/retry.go +39 -21
  198. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/send.go +261 -75
  199. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/sendfb.go +28 -16
  200. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/clientpayload.go +3 -1
  201. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/noop.go +85 -43
  202. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/signal.go +75 -88
  203. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/container.go +86 -65
  204. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/lidmap.go +186 -0
  205. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/store.go +291 -167
  206. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrades/00-latest-schema.sql +155 -0
  207. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrades/03-message-secrets.sql +11 -0
  208. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrades/04-privacy-tokens.sql +8 -0
  209. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrades/05-account-jid-format.sql +2 -0
  210. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrades/06-facebook-uuid.sql +2 -0
  211. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrades/07-account-lid.sql +2 -0
  212. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrades/08-lid-mapping.sql +5 -0
  213. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrades/09-decryption-buffer.sql +10 -0
  214. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrades/10-chat-db-lid-migration-ts.sql +2 -0
  215. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrades/upgrades.go +22 -0
  216. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/store.go +107 -56
  217. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/botmap.go +210 -0
  218. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/events/events.go +13 -2
  219. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/group.go +15 -6
  220. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/jid.go +7 -8
  221. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/message.go +18 -0
  222. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/update.go +3 -2
  223. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/upload.go +1 -1
  224. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/user.go +47 -29
  225. slidge_whatsapp/vendor/golang.org/x/exp/LICENSE +27 -0
  226. slidge_whatsapp/vendor/golang.org/x/exp/PATENTS +22 -0
  227. slidge_whatsapp/vendor/golang.org/x/exp/constraints/constraints.go +54 -0
  228. slidge_whatsapp/vendor/golang.org/x/net/http/httpguts/guts.go +50 -0
  229. slidge_whatsapp/vendor/golang.org/x/net/http/httpguts/httplex.go +347 -0
  230. slidge_whatsapp/vendor/golang.org/x/net/http2/.gitignore +2 -0
  231. slidge_whatsapp/vendor/golang.org/x/net/http2/ascii.go +53 -0
  232. slidge_whatsapp/vendor/golang.org/x/net/http2/ciphers.go +641 -0
  233. slidge_whatsapp/vendor/golang.org/x/net/http2/client_conn_pool.go +311 -0
  234. slidge_whatsapp/vendor/golang.org/x/net/http2/config.go +122 -0
  235. slidge_whatsapp/vendor/golang.org/x/net/http2/config_go124.go +61 -0
  236. slidge_whatsapp/vendor/golang.org/x/net/http2/config_pre_go124.go +16 -0
  237. slidge_whatsapp/vendor/golang.org/x/net/http2/databuffer.go +149 -0
  238. slidge_whatsapp/vendor/golang.org/x/net/http2/errors.go +145 -0
  239. slidge_whatsapp/vendor/golang.org/x/net/http2/flow.go +120 -0
  240. slidge_whatsapp/vendor/golang.org/x/net/http2/frame.go +1702 -0
  241. slidge_whatsapp/vendor/golang.org/x/net/http2/gotrack.go +170 -0
  242. slidge_whatsapp/vendor/golang.org/x/net/http2/hpack/encode.go +245 -0
  243. slidge_whatsapp/vendor/golang.org/x/net/http2/hpack/hpack.go +523 -0
  244. slidge_whatsapp/vendor/golang.org/x/net/http2/hpack/huffman.go +226 -0
  245. slidge_whatsapp/vendor/golang.org/x/net/http2/hpack/static_table.go +188 -0
  246. slidge_whatsapp/vendor/golang.org/x/net/http2/hpack/tables.go +403 -0
  247. slidge_whatsapp/vendor/golang.org/x/net/http2/http2.go +432 -0
  248. slidge_whatsapp/vendor/golang.org/x/net/http2/pipe.go +184 -0
  249. slidge_whatsapp/vendor/golang.org/x/net/http2/server.go +3350 -0
  250. slidge_whatsapp/vendor/golang.org/x/net/http2/timer.go +20 -0
  251. slidge_whatsapp/vendor/golang.org/x/net/http2/transport.go +3287 -0
  252. slidge_whatsapp/vendor/golang.org/x/net/http2/unencrypted.go +32 -0
  253. slidge_whatsapp/vendor/golang.org/x/net/http2/write.go +381 -0
  254. slidge_whatsapp/vendor/golang.org/x/net/http2/writesched.go +251 -0
  255. slidge_whatsapp/vendor/golang.org/x/net/http2/writesched_priority.go +451 -0
  256. slidge_whatsapp/vendor/golang.org/x/net/http2/writesched_random.go +77 -0
  257. slidge_whatsapp/vendor/golang.org/x/net/http2/writesched_roundrobin.go +119 -0
  258. slidge_whatsapp/vendor/golang.org/x/net/idna/go118.go +13 -0
  259. slidge_whatsapp/vendor/golang.org/x/net/idna/idna10.0.0.go +769 -0
  260. slidge_whatsapp/vendor/golang.org/x/net/idna/idna9.0.0.go +717 -0
  261. slidge_whatsapp/vendor/golang.org/x/net/idna/pre_go118.go +11 -0
  262. slidge_whatsapp/vendor/golang.org/x/net/idna/punycode.go +217 -0
  263. slidge_whatsapp/vendor/golang.org/x/net/idna/tables10.0.0.go +4559 -0
  264. slidge_whatsapp/vendor/golang.org/x/net/idna/tables11.0.0.go +4653 -0
  265. slidge_whatsapp/vendor/golang.org/x/net/idna/tables12.0.0.go +4733 -0
  266. slidge_whatsapp/vendor/golang.org/x/net/idna/tables13.0.0.go +4959 -0
  267. slidge_whatsapp/vendor/golang.org/x/net/idna/tables15.0.0.go +5144 -0
  268. slidge_whatsapp/vendor/golang.org/x/net/idna/tables9.0.0.go +4486 -0
  269. slidge_whatsapp/vendor/golang.org/x/net/idna/trie.go +51 -0
  270. slidge_whatsapp/vendor/golang.org/x/net/idna/trie12.0.0.go +30 -0
  271. slidge_whatsapp/vendor/golang.org/x/net/idna/trie13.0.0.go +30 -0
  272. slidge_whatsapp/vendor/golang.org/x/net/idna/trieval.go +119 -0
  273. slidge_whatsapp/vendor/golang.org/x/net/internal/httpcommon/ascii.go +53 -0
  274. slidge_whatsapp/vendor/golang.org/x/net/internal/httpcommon/headermap.go +115 -0
  275. slidge_whatsapp/vendor/golang.org/x/net/internal/httpcommon/request.go +467 -0
  276. slidge_whatsapp/vendor/golang.org/x/sys/unix/syscall_darwin.go +148 -1
  277. slidge_whatsapp/vendor/golang.org/x/sys/unix/syscall_linux.go +16 -26
  278. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +84 -0
  279. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s +20 -0
  280. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +84 -0
  281. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s +20 -0
  282. slidge_whatsapp/vendor/golang.org/x/sys/windows/security_windows.go +44 -5
  283. slidge_whatsapp/vendor/golang.org/x/sys/windows/syscall_windows.go +4 -2
  284. slidge_whatsapp/vendor/golang.org/x/sys/windows/types_windows.go +239 -0
  285. slidge_whatsapp/vendor/golang.org/x/sys/windows/zsyscall_windows.go +9 -0
  286. slidge_whatsapp/vendor/golang.org/x/text/LICENSE +27 -0
  287. slidge_whatsapp/vendor/golang.org/x/text/PATENTS +22 -0
  288. slidge_whatsapp/vendor/golang.org/x/text/secure/bidirule/bidirule.go +336 -0
  289. slidge_whatsapp/vendor/golang.org/x/text/secure/bidirule/bidirule10.0.0.go +11 -0
  290. slidge_whatsapp/vendor/golang.org/x/text/secure/bidirule/bidirule9.0.0.go +14 -0
  291. slidge_whatsapp/vendor/golang.org/x/text/transform/transform.go +709 -0
  292. slidge_whatsapp/vendor/golang.org/x/text/unicode/bidi/bidi.go +359 -0
  293. slidge_whatsapp/vendor/golang.org/x/text/unicode/bidi/bracket.go +335 -0
  294. slidge_whatsapp/vendor/golang.org/x/text/unicode/bidi/core.go +1071 -0
  295. slidge_whatsapp/vendor/golang.org/x/text/unicode/bidi/prop.go +206 -0
  296. slidge_whatsapp/vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go +1815 -0
  297. slidge_whatsapp/vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go +1887 -0
  298. slidge_whatsapp/vendor/golang.org/x/text/unicode/bidi/tables12.0.0.go +1923 -0
  299. slidge_whatsapp/vendor/golang.org/x/text/unicode/bidi/tables13.0.0.go +1955 -0
  300. slidge_whatsapp/vendor/golang.org/x/text/unicode/bidi/tables15.0.0.go +2042 -0
  301. slidge_whatsapp/vendor/golang.org/x/text/unicode/bidi/tables9.0.0.go +1781 -0
  302. slidge_whatsapp/vendor/golang.org/x/text/unicode/bidi/trieval.go +48 -0
  303. slidge_whatsapp/vendor/golang.org/x/text/unicode/norm/composition.go +512 -0
  304. slidge_whatsapp/vendor/golang.org/x/text/unicode/norm/forminfo.go +279 -0
  305. slidge_whatsapp/vendor/golang.org/x/text/unicode/norm/input.go +109 -0
  306. slidge_whatsapp/vendor/golang.org/x/text/unicode/norm/iter.go +458 -0
  307. slidge_whatsapp/vendor/golang.org/x/text/unicode/norm/normalize.go +610 -0
  308. slidge_whatsapp/vendor/golang.org/x/text/unicode/norm/readwriter.go +125 -0
  309. slidge_whatsapp/vendor/golang.org/x/text/unicode/norm/tables10.0.0.go +7657 -0
  310. slidge_whatsapp/vendor/golang.org/x/text/unicode/norm/tables11.0.0.go +7693 -0
  311. slidge_whatsapp/vendor/golang.org/x/text/unicode/norm/tables12.0.0.go +7710 -0
  312. slidge_whatsapp/vendor/golang.org/x/text/unicode/norm/tables13.0.0.go +7760 -0
  313. slidge_whatsapp/vendor/golang.org/x/text/unicode/norm/tables15.0.0.go +7907 -0
  314. slidge_whatsapp/vendor/golang.org/x/text/unicode/norm/tables9.0.0.go +7637 -0
  315. slidge_whatsapp/vendor/golang.org/x/text/unicode/norm/transform.go +88 -0
  316. slidge_whatsapp/vendor/golang.org/x/text/unicode/norm/trie.go +54 -0
  317. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb +0 -0
  318. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/filedesc/editions.go +3 -0
  319. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go +16 -0
  320. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/strs/{strings_unsafe_go121.go → strings_unsafe.go} +0 -2
  321. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/version/version.go +1 -1
  322. slidge_whatsapp/vendor/google.golang.org/protobuf/proto/merge.go +6 -0
  323. slidge_whatsapp/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go +2 -0
  324. slidge_whatsapp/vendor/google.golang.org/protobuf/reflect/protoreflect/{value_unsafe_go121.go → value_unsafe.go} +0 -2
  325. slidge_whatsapp/vendor/modules.txt +52 -13
  326. {slidge_whatsapp-0.2.5.dist-info → slidge_whatsapp-0.2.7.dist-info}/METADATA +1 -1
  327. {slidge_whatsapp-0.2.5.dist-info → slidge_whatsapp-0.2.7.dist-info}/RECORD +330 -184
  328. {slidge_whatsapp-0.2.5.dist-info → slidge_whatsapp-0.2.7.dist-info}/WHEEL +1 -1
  329. slidge_whatsapp/vendor/github.com/rs/zerolog/CNAME +0 -1
  330. slidge_whatsapp/vendor/github.com/rs/zerolog/_config.yml +0 -1
  331. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waAdv/WAAdv.pb.raw +0 -0
  332. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waArmadilloApplication/WAArmadilloApplication.pb.raw +0 -0
  333. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waArmadilloXMA/WAArmadilloXMA.pb.raw +0 -0
  334. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCert/WACert.pb.raw +0 -23
  335. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waChatLockSettings/WAProtobufsChatLockSettings.pb.raw +0 -7
  336. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCommon/WACommon.pb.raw +0 -0
  337. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCompanionReg/WAWebProtobufsCompanionReg.pb.raw +0 -0
  338. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waConsumerApplication/WAConsumerApplication.pb.raw +0 -0
  339. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waDeviceCapabilities/WAProtobufsDeviceCapabilities.pb.raw +0 -0
  340. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.pb.raw +0 -0
  341. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waHistorySync/WAWebProtobufsHistorySync.pb.raw +0 -0
  342. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMediaTransport/WAMediaTransport.pb.raw +0 -0
  343. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMmsRetry/WAMmsRetry.pb.raw +0 -0
  344. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMsgApplication/WAMsgApplication.pb.raw +0 -0
  345. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMsgTransport/WAMsgTransport.pb.raw +0 -0
  346. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMultiDevice/WAMultiDevice.pb.raw +0 -0
  347. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waServerSync/WAServerSync.pb.raw +0 -0
  348. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.pb.raw +0 -0
  349. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waUserPassword/WAProtobufsUserPassword.pb.raw +0 -0
  350. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waVnameCert/WAWebProtobufsVnameCert.pb.raw +0 -0
  351. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWa6/WAWebProtobufsWa6.pb.raw +0 -0
  352. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWeb/WAWebProtobufsWeb.pb.raw +0 -0
  353. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrade.go +0 -296
  354. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/strs/strings_unsafe_go120.go +0 -94
  355. slidge_whatsapp/vendor/google.golang.org/protobuf/reflect/protoreflect/value_unsafe_go120.go +0 -98
  356. {slidge_whatsapp-0.2.5.dist-info → slidge_whatsapp-0.2.7.dist-info}/LICENSE +0 -0
  357. {slidge_whatsapp-0.2.5.dist-info → slidge_whatsapp-0.2.7.dist-info}/entry_points.txt +0 -0
@@ -7,16 +7,16 @@
7
7
  package whatsmeow
8
8
 
9
9
  import (
10
+ "context"
10
11
  "crypto/sha256"
11
12
  "fmt"
12
13
  "time"
13
14
 
14
- "go.mau.fi/whatsmeow/proto/waCommon"
15
- "go.mau.fi/whatsmeow/proto/waE2E"
16
-
17
15
  "go.mau.fi/util/random"
18
16
  "google.golang.org/protobuf/proto"
19
17
 
18
+ "go.mau.fi/whatsmeow/proto/waCommon"
19
+ "go.mau.fi/whatsmeow/proto/waE2E"
20
20
  "go.mau.fi/whatsmeow/types"
21
21
  "go.mau.fi/whatsmeow/types/events"
22
22
  "go.mau.fi/whatsmeow/util/gcmutil"
@@ -26,9 +26,13 @@ import (
26
26
  type MsgSecretType string
27
27
 
28
28
  const (
29
- EncSecretPollVote MsgSecretType = "Poll Vote"
30
- EncSecretReaction MsgSecretType = "Enc Reaction"
31
- EncSecretBotMsg MsgSecretType = "Bot Message"
29
+ EncSecretPollVote MsgSecretType = "Poll Vote"
30
+ EncSecretReaction MsgSecretType = "Enc Reaction"
31
+ EncSecretComment MsgSecretType = "Enc Comment"
32
+ EncSecretReportToken MsgSecretType = "Report Token"
33
+ EncSecretEventResponse MsgSecretType = "Event Response"
34
+ EncSecretEventEdit MsgSecretType = "Event Edit"
35
+ EncSecretBotMsg MsgSecretType = "Bot Message"
32
36
  )
33
37
 
34
38
  func applyBotMessageHKDF(messageSecret []byte) []byte {
@@ -49,7 +53,11 @@ func generateMsgSecretKey(
49
53
  useCaseSecret = append(useCaseSecret, modificationType...)
50
54
 
51
55
  secretKey := hkdfutil.SHA256(origMsgSecret, nil, useCaseSecret, 32)
52
- additionalData := []byte(fmt.Sprintf("%s\x00%s", origMsgID, modificationSenderStr))
56
+ var additionalData []byte
57
+ switch modificationType {
58
+ case EncSecretPollVote, EncSecretEventResponse, "":
59
+ additionalData = fmt.Appendf(nil, "%s\x00%s", origMsgID, modificationSenderStr)
60
+ }
53
61
 
54
62
  return secretKey, additionalData
55
63
  }
@@ -57,8 +65,9 @@ func generateMsgSecretKey(
57
65
  func getOrigSenderFromKey(msg *events.Message, key *waCommon.MessageKey) (types.JID, error) {
58
66
  if key.GetFromMe() {
59
67
  // fromMe always means the poll and vote were sent by the same user
68
+ // TODO this is wrong if the message key used @s.whatsapp.net, but the new event is from @lid
60
69
  return msg.Info.Sender, nil
61
- } else if msg.Info.Chat.Server == types.DefaultUserServer {
70
+ } else if msg.Info.Chat.Server == types.DefaultUserServer || msg.Info.Chat.Server == types.HiddenUserServer {
62
71
  sender, err := types.ParseJID(key.GetRemoteJID())
63
72
  if err != nil {
64
73
  return types.EmptyJID, fmt.Errorf("failed to parse JID %q of original message sender: %w", key.GetRemoteJID(), err)
@@ -66,7 +75,7 @@ func getOrigSenderFromKey(msg *events.Message, key *waCommon.MessageKey) (types.
66
75
  return sender, nil
67
76
  } else {
68
77
  sender, err := types.ParseJID(key.GetParticipant())
69
- if sender.Server != types.DefaultUserServer {
78
+ if sender.Server != types.DefaultUserServer && sender.Server != types.HiddenUserServer {
70
79
  err = fmt.Errorf("unexpected server")
71
80
  }
72
81
  if err != nil {
@@ -81,21 +90,34 @@ type messageEncryptedSecret interface {
81
90
  GetEncPayload() []byte
82
91
  }
83
92
 
84
- func (cli *Client) decryptMsgSecret(msg *events.Message, useCase MsgSecretType, encrypted messageEncryptedSecret, origMsgKey *waCommon.MessageKey) ([]byte, error) {
93
+ func (cli *Client) decryptMsgSecret(ctx context.Context, msg *events.Message, useCase MsgSecretType, encrypted messageEncryptedSecret, origMsgKey *waCommon.MessageKey) ([]byte, error) {
85
94
  if cli == nil {
86
95
  return nil, ErrClientIsNil
87
96
  }
88
- pollSender, err := getOrigSenderFromKey(msg, origMsgKey)
97
+ origSender, err := getOrigSenderFromKey(msg, origMsgKey)
89
98
  if err != nil {
90
99
  return nil, err
91
100
  }
92
- baseEncKey, err := cli.Store.MsgSecrets.GetMessageSecret(msg.Info.Chat, pollSender, origMsgKey.GetID())
101
+ baseEncKey, err := cli.Store.MsgSecrets.GetMessageSecret(ctx, msg.Info.Chat, origSender, origMsgKey.GetID())
93
102
  if err != nil {
94
103
  return nil, fmt.Errorf("failed to get original message secret key: %w", err)
95
- } else if baseEncKey == nil {
104
+ }
105
+ if baseEncKey == nil && origMsgKey.GetFromMe() && origSender.Server == types.HiddenUserServer {
106
+ origSender, err = cli.Store.LIDs.GetPNForLID(ctx, origSender)
107
+ if err != nil {
108
+ return nil, fmt.Errorf("%w (also failed to get PN for LID: %w)", ErrOriginalMessageSecretNotFound, err)
109
+ } else if origSender.IsEmpty() {
110
+ return nil, fmt.Errorf("%w (PN for LID not found)", ErrOriginalMessageSecretNotFound)
111
+ }
112
+ baseEncKey, err = cli.Store.MsgSecrets.GetMessageSecret(ctx, msg.Info.Chat, origSender, origMsgKey.GetID())
113
+ if err != nil {
114
+ return nil, fmt.Errorf("failed to get original message secret key with PN: %w", err)
115
+ }
116
+ }
117
+ if baseEncKey == nil {
96
118
  return nil, ErrOriginalMessageSecretNotFound
97
119
  }
98
- secretKey, additionalData := generateMsgSecretKey(useCase, msg.Info.Sender, origMsgKey.GetID(), pollSender, baseEncKey)
120
+ secretKey, additionalData := generateMsgSecretKey(useCase, msg.Info.Sender, origMsgKey.GetID(), origSender, baseEncKey)
99
121
  plaintext, err := gcmutil.Decrypt(secretKey, encrypted.GetEncIV(), encrypted.GetEncPayload(), additionalData)
100
122
  if err != nil {
101
123
  return nil, fmt.Errorf("failed to decrypt secret message: %w", err)
@@ -103,16 +125,14 @@ func (cli *Client) decryptMsgSecret(msg *events.Message, useCase MsgSecretType,
103
125
  return plaintext, nil
104
126
  }
105
127
 
106
- func (cli *Client) encryptMsgSecret(chat, origSender types.JID, origMsgID types.MessageID, useCase MsgSecretType, plaintext []byte) (ciphertext, iv []byte, err error) {
128
+ func (cli *Client) encryptMsgSecret(ctx context.Context, ownID, chat, origSender types.JID, origMsgID types.MessageID, useCase MsgSecretType, plaintext []byte) (ciphertext, iv []byte, err error) {
107
129
  if cli == nil {
108
130
  return nil, nil, ErrClientIsNil
109
- }
110
- ownID := cli.getOwnID()
111
- if ownID.IsEmpty() {
131
+ } else if ownID.IsEmpty() {
112
132
  return nil, nil, ErrNotLoggedIn
113
133
  }
114
134
 
115
- baseEncKey, err := cli.Store.MsgSecrets.GetMessageSecret(chat, origSender, origMsgID)
135
+ baseEncKey, err := cli.Store.MsgSecrets.GetMessageSecret(ctx, chat, origSender, origMsgID)
116
136
  if err != nil {
117
137
  return nil, nil, fmt.Errorf("failed to get original message secret key: %w", err)
118
138
  } else if baseEncKey == nil {
@@ -128,8 +148,7 @@ func (cli *Client) encryptMsgSecret(chat, origSender types.JID, origMsgID types.
128
148
  return ciphertext, iv, nil
129
149
  }
130
150
 
131
- func (cli *Client) decryptBotMessage(messageSecret []byte, msMsg messageEncryptedSecret, messageID types.MessageID, targetSenderJID types.JID, info *types.MessageInfo) ([]byte, error) {
132
- // gcm decrypt key generation
151
+ func (cli *Client) decryptBotMessage(ctx context.Context, messageSecret []byte, msMsg messageEncryptedSecret, messageID types.MessageID, targetSenderJID types.JID, info *types.MessageInfo) ([]byte, error) {
133
152
  newKey, additionalData := generateMsgSecretKey("", info.Sender, messageID, targetSenderJID, applyBotMessageHKDF(messageSecret))
134
153
 
135
154
  plaintext, err := gcmutil.Decrypt(newKey, msMsg.GetEncIV(), msMsg.GetEncPayload(), additionalData)
@@ -140,8 +159,7 @@ func (cli *Client) decryptBotMessage(messageSecret []byte, msMsg messageEncrypte
140
159
  return plaintext, nil
141
160
  }
142
161
 
143
- // DecryptReaction decrypts a reaction update message. This form of reactions hasn't been rolled out yet,
144
- // so this function is likely not of much use.
162
+ // DecryptReaction decrypts a reaction message in a community announcement group.
145
163
  //
146
164
  // if evt.Message.GetEncReactionMessage() != nil {
147
165
  // reaction, err := cli.DecryptReaction(evt)
@@ -151,12 +169,12 @@ func (cli *Client) decryptBotMessage(messageSecret []byte, msMsg messageEncrypte
151
169
  // }
152
170
  // fmt.Printf("Reaction message: %+v\n", reaction)
153
171
  // }
154
- func (cli *Client) DecryptReaction(reaction *events.Message) (*waE2E.ReactionMessage, error) {
172
+ func (cli *Client) DecryptReaction(ctx context.Context, reaction *events.Message) (*waE2E.ReactionMessage, error) {
155
173
  encReaction := reaction.Message.GetEncReactionMessage()
156
174
  if encReaction == nil {
157
175
  return nil, ErrNotEncryptedReactionMessage
158
176
  }
159
- plaintext, err := cli.decryptMsgSecret(reaction, EncSecretReaction, encReaction, encReaction.GetTargetMessageKey())
177
+ plaintext, err := cli.decryptMsgSecret(ctx, reaction, EncSecretReaction, encReaction, encReaction.GetTargetMessageKey())
160
178
  if err != nil {
161
179
  return nil, fmt.Errorf("failed to decrypt reaction: %w", err)
162
180
  }
@@ -168,6 +186,33 @@ func (cli *Client) DecryptReaction(reaction *events.Message) (*waE2E.ReactionMes
168
186
  return &msg, nil
169
187
  }
170
188
 
189
+ // DecryptComment decrypts a reply/comment message in a community announcement group.
190
+ //
191
+ // if evt.Message.GetEncCommentMessage() != nil {
192
+ // comment, err := cli.DecryptComment(evt)
193
+ // if err != nil {
194
+ // fmt.Println(":(", err)
195
+ // return
196
+ // }
197
+ // fmt.Printf("Comment message: %+v\n", comment)
198
+ // }
199
+ func (cli *Client) DecryptComment(ctx context.Context, comment *events.Message) (*waE2E.Message, error) {
200
+ encComment := comment.Message.GetEncCommentMessage()
201
+ if encComment == nil {
202
+ return nil, ErrNotEncryptedCommentMessage
203
+ }
204
+ plaintext, err := cli.decryptMsgSecret(ctx, comment, EncSecretComment, encComment, encComment.GetTargetMessageKey())
205
+ if err != nil {
206
+ return nil, fmt.Errorf("failed to decrypt comment: %w", err)
207
+ }
208
+ var msg waE2E.Message
209
+ err = proto.Unmarshal(plaintext, &msg)
210
+ if err != nil {
211
+ return nil, fmt.Errorf("failed to decode comment protobuf: %w", err)
212
+ }
213
+ return &msg, nil
214
+ }
215
+
171
216
  // DecryptPollVote decrypts a poll update message. The vote itself includes SHA-256 hashes of the selected options.
172
217
  //
173
218
  // if evt.Message.GetPollUpdateMessage() != nil {
@@ -181,12 +226,12 @@ func (cli *Client) DecryptReaction(reaction *events.Message) (*waE2E.ReactionMes
181
226
  // fmt.Printf("- %X\n", hash)
182
227
  // }
183
228
  // }
184
- func (cli *Client) DecryptPollVote(vote *events.Message) (*waE2E.PollVoteMessage, error) {
229
+ func (cli *Client) DecryptPollVote(ctx context.Context, vote *events.Message) (*waE2E.PollVoteMessage, error) {
185
230
  pollUpdate := vote.Message.GetPollUpdateMessage()
186
231
  if pollUpdate == nil {
187
232
  return nil, ErrNotPollUpdateMessage
188
233
  }
189
- plaintext, err := cli.decryptMsgSecret(vote, EncSecretPollVote, pollUpdate.GetVote(), pollUpdate.GetPollCreationMessageKey())
234
+ plaintext, err := cli.decryptMsgSecret(ctx, vote, EncSecretPollVote, pollUpdate.GetVote(), pollUpdate.GetPollCreationMessageKey())
190
235
  if err != nil {
191
236
  return nil, fmt.Errorf("failed to decrypt poll vote: %w", err)
192
237
  }
@@ -234,8 +279,8 @@ func HashPollOptions(optionNames []string) [][]byte {
234
279
  // }
235
280
  // resp, err := cli.SendMessage(context.Background(), evt.Info.Chat, pollVoteMsg)
236
281
  // }
237
- func (cli *Client) BuildPollVote(pollInfo *types.MessageInfo, optionNames []string) (*waE2E.Message, error) {
238
- pollUpdate, err := cli.EncryptPollVote(pollInfo, &waE2E.PollVoteMessage{
282
+ func (cli *Client) BuildPollVote(ctx context.Context, pollInfo *types.MessageInfo, optionNames []string) (*waE2E.Message, error) {
283
+ pollUpdate, err := cli.EncryptPollVote(ctx, pollInfo, &waE2E.PollVoteMessage{
239
284
  SelectedOptions: HashPollOptions(optionNames),
240
285
  })
241
286
  return &waE2E.Message{PollUpdateMessage: pollUpdate}, err
@@ -267,12 +312,12 @@ func (cli *Client) BuildPollCreation(name string, optionNames []string, selectab
267
312
  }
268
313
 
269
314
  // EncryptPollVote encrypts a poll vote message. This is a slightly lower-level function, using BuildPollVote is recommended.
270
- func (cli *Client) EncryptPollVote(pollInfo *types.MessageInfo, vote *waE2E.PollVoteMessage) (*waE2E.PollUpdateMessage, error) {
315
+ func (cli *Client) EncryptPollVote(ctx context.Context, pollInfo *types.MessageInfo, vote *waE2E.PollVoteMessage) (*waE2E.PollUpdateMessage, error) {
271
316
  plaintext, err := proto.Marshal(vote)
272
317
  if err != nil {
273
318
  return nil, fmt.Errorf("failed to marshal poll vote protobuf: %w", err)
274
319
  }
275
- ciphertext, iv, err := cli.encryptMsgSecret(pollInfo.Chat, pollInfo.Sender, pollInfo.ID, EncSecretPollVote, plaintext)
320
+ ciphertext, iv, err := cli.encryptMsgSecret(ctx, cli.getOwnID(), pollInfo.Chat, pollInfo.Sender, pollInfo.ID, EncSecretPollVote, plaintext)
276
321
  if err != nil {
277
322
  return nil, fmt.Errorf("failed to encrypt poll vote: %w", err)
278
323
  }
@@ -285,3 +330,45 @@ func (cli *Client) EncryptPollVote(pollInfo *types.MessageInfo, vote *waE2E.Poll
285
330
  SenderTimestampMS: proto.Int64(time.Now().UnixMilli()),
286
331
  }, nil
287
332
  }
333
+
334
+ func (cli *Client) EncryptComment(ctx context.Context, rootMsgInfo *types.MessageInfo, comment *waE2E.Message) (*waE2E.Message, error) {
335
+ plaintext, err := proto.Marshal(comment)
336
+ if err != nil {
337
+ return nil, fmt.Errorf("failed to marshal comment protobuf: %w", err)
338
+ }
339
+ // TODO is hardcoding LID here correct? What about polls?
340
+ ciphertext, iv, err := cli.encryptMsgSecret(ctx, cli.getOwnLID(), rootMsgInfo.Chat, rootMsgInfo.Sender, rootMsgInfo.ID, EncSecretComment, plaintext)
341
+ if err != nil {
342
+ return nil, fmt.Errorf("failed to encrypt comment: %w", err)
343
+ }
344
+ return &waE2E.Message{
345
+ EncCommentMessage: &waE2E.EncCommentMessage{
346
+ TargetMessageKey: &waCommon.MessageKey{
347
+ RemoteJID: proto.String(rootMsgInfo.Chat.String()),
348
+ Participant: proto.String(rootMsgInfo.Sender.ToNonAD().String()),
349
+ FromMe: proto.Bool(rootMsgInfo.IsFromMe),
350
+ ID: proto.String(rootMsgInfo.ID),
351
+ },
352
+ EncPayload: ciphertext,
353
+ EncIV: iv,
354
+ },
355
+ }, nil
356
+ }
357
+
358
+ func (cli *Client) EncryptReaction(ctx context.Context, rootMsgInfo *types.MessageInfo, reaction *waE2E.ReactionMessage) (*waE2E.EncReactionMessage, error) {
359
+ reactionKey := reaction.Key
360
+ reaction.Key = nil
361
+ plaintext, err := proto.Marshal(reaction)
362
+ if err != nil {
363
+ return nil, fmt.Errorf("failed to marshal reaction protobuf: %w", err)
364
+ }
365
+ ciphertext, iv, err := cli.encryptMsgSecret(ctx, cli.getOwnLID(), rootMsgInfo.Chat, rootMsgInfo.Sender, rootMsgInfo.ID, EncSecretReaction, plaintext)
366
+ if err != nil {
367
+ return nil, fmt.Errorf("failed to encrypt reaction: %w", err)
368
+ }
369
+ return &waE2E.EncReactionMessage{
370
+ TargetMessageKey: reactionKey,
371
+ EncPayload: ciphertext,
372
+ EncIV: iv,
373
+ }, nil
374
+ }
@@ -7,8 +7,10 @@
7
7
  package whatsmeow
8
8
 
9
9
  import (
10
+ "context"
10
11
  "encoding/json"
11
12
  "errors"
13
+ "slices"
12
14
 
13
15
  "google.golang.org/protobuf/proto"
14
16
 
@@ -20,7 +22,7 @@ import (
20
22
  "go.mau.fi/whatsmeow/types/events"
21
23
  )
22
24
 
23
- func (cli *Client) handleEncryptNotification(node *waBinary.Node) {
25
+ func (cli *Client) handleEncryptNotification(ctx context.Context, node *waBinary.Node) {
24
26
  from := node.AttrGetter().JID("from")
25
27
  if from == types.ServerJID {
26
28
  count := node.GetChildByTag("count")
@@ -32,15 +34,15 @@ func (cli *Client) handleEncryptNotification(node *waBinary.Node) {
32
34
  }
33
35
  cli.Log.Infof("Got prekey count from server: %s", node.XMLString())
34
36
  if otksLeft < MinPreKeyCount {
35
- cli.uploadPreKeys()
37
+ cli.uploadPreKeys(ctx)
36
38
  }
37
39
  } else if _, ok := node.GetOptionalChildByTag("identity"); ok {
38
40
  cli.Log.Debugf("Got identity change for %s: %s, deleting all identities/sessions for that number", from, node.XMLString())
39
- err := cli.Store.Identities.DeleteAllIdentities(from.User)
41
+ err := cli.Store.Identities.DeleteAllIdentities(ctx, from.User)
40
42
  if err != nil {
41
43
  cli.Log.Warnf("Failed to delete all identities of %s from store after identity change: %v", from, err)
42
44
  }
43
- err = cli.Store.Sessions.DeleteAllSessions(from.User)
45
+ err = cli.Store.Sessions.DeleteAllSessions(ctx, from.User)
44
46
  if err != nil {
45
47
  cli.Log.Warnf("Failed to delete all sessions of %s from store after identity change: %v", from, err)
46
48
  }
@@ -51,13 +53,13 @@ func (cli *Client) handleEncryptNotification(node *waBinary.Node) {
51
53
  }
52
54
  }
53
55
 
54
- func (cli *Client) handleAppStateNotification(node *waBinary.Node) {
56
+ func (cli *Client) handleAppStateNotification(ctx context.Context, node *waBinary.Node) {
55
57
  for _, collection := range node.GetChildrenByTag("collection") {
56
58
  ag := collection.AttrGetter()
57
59
  name := appstate.WAPatchName(ag.String("name"))
58
60
  version := ag.Uint64("version")
59
61
  cli.Log.Debugf("Got server sync notification that app state %s has updated to version %d", name, version)
60
- err := cli.FetchAppState(name, false, false)
62
+ err := cli.FetchAppState(ctx, name, false, false)
61
63
  if errors.Is(err, ErrIQDisconnected) || errors.Is(err, ErrNotConnected) {
62
64
  // There are some app state changes right before a remote logout, so stop syncing if we're disconnected.
63
65
  cli.Log.Debugf("Failed to sync app state after notification: %v, not trying to sync other states", err)
@@ -68,7 +70,7 @@ func (cli *Client) handleAppStateNotification(node *waBinary.Node) {
68
70
  }
69
71
  }
70
72
 
71
- func (cli *Client) handlePictureNotification(node *waBinary.Node) {
73
+ func (cli *Client) handlePictureNotification(ctx context.Context, node *waBinary.Node) {
72
74
  ts := node.AttrGetter().UnixTime("t")
73
75
  for _, child := range node.GetChildren() {
74
76
  ag := child.AttrGetter()
@@ -94,16 +96,26 @@ func (cli *Client) handlePictureNotification(node *waBinary.Node) {
94
96
  }
95
97
  }
96
98
 
97
- func (cli *Client) handleDeviceNotification(node *waBinary.Node) {
99
+ func (cli *Client) handleDeviceNotification(ctx context.Context, node *waBinary.Node) {
98
100
  cli.userDevicesCacheLock.Lock()
99
101
  defer cli.userDevicesCacheLock.Unlock()
100
102
  ag := node.AttrGetter()
101
103
  from := ag.JID("from")
104
+ fromLID := ag.OptionalJID("lid")
105
+ if fromLID != nil {
106
+ cli.StoreLIDPNMapping(ctx, *fromLID, from)
107
+ }
102
108
  cached, ok := cli.userDevicesCache[from]
103
109
  if !ok {
104
110
  cli.Log.Debugf("No device list cached for %s, ignoring device list notification", from)
105
111
  return
106
112
  }
113
+ var cachedLID deviceCache
114
+ var cachedLIDHash string
115
+ if fromLID != nil {
116
+ cachedLID = cli.userDevicesCache[*fromLID]
117
+ cachedLIDHash = participantListHashV2(cachedLID.devices)
118
+ }
107
119
  cachedParticipantHash := participantListHashV2(cached.devices)
108
120
  for _, child := range node.GetChildren() {
109
121
  if child.Tag != "add" && child.Tag != "remove" {
@@ -112,16 +124,24 @@ func (cli *Client) handleDeviceNotification(node *waBinary.Node) {
112
124
  }
113
125
  cag := child.AttrGetter()
114
126
  deviceHash := cag.String("device_hash")
127
+ deviceLIDHash := cag.OptionalString("device_lid_hash")
115
128
  deviceChild, _ := child.GetOptionalChildByTag("device")
116
129
  changedDeviceJID := deviceChild.AttrGetter().JID("jid")
130
+ changedDeviceLID := deviceChild.AttrGetter().OptionalJID("lid")
117
131
  switch child.Tag {
118
132
  case "add":
119
133
  cached.devices = append(cached.devices, changedDeviceJID)
134
+ if changedDeviceLID != nil {
135
+ cachedLID.devices = append(cachedLID.devices, *changedDeviceLID)
136
+ }
120
137
  case "remove":
121
- for i, jid := range cached.devices {
122
- if jid == changedDeviceJID {
123
- cached.devices = append(cached.devices[:i], cached.devices[i+1:]...)
124
- }
138
+ cached.devices = slices.DeleteFunc(cached.devices, func(existing types.JID) bool {
139
+ return existing == changedDeviceJID
140
+ })
141
+ if changedDeviceLID != nil {
142
+ cachedLID.devices = slices.DeleteFunc(cachedLID.devices, func(existing types.JID) bool {
143
+ return existing == *changedDeviceLID
144
+ })
125
145
  }
126
146
  case "update":
127
147
  // ???
@@ -134,10 +154,20 @@ func (cli *Client) handleDeviceNotification(node *waBinary.Node) {
134
154
  cli.Log.Warnf("%s's device list hash changed from %s to %s (%s). New hash doesn't match (%s)", from, cachedParticipantHash, deviceHash, child.Tag, newParticipantHash)
135
155
  delete(cli.userDevicesCache, from)
136
156
  }
157
+ if fromLID != nil && changedDeviceLID != nil && deviceLIDHash != "" {
158
+ newLIDParticipantHash := participantListHashV2(cachedLID.devices)
159
+ if newLIDParticipantHash == deviceLIDHash {
160
+ cli.Log.Debugf("%s's device list hash changed from %s to %s (%s). New hash matches", fromLID, cachedLIDHash, deviceLIDHash, child.Tag)
161
+ cli.userDevicesCache[*fromLID] = cachedLID
162
+ } else {
163
+ cli.Log.Warnf("%s's device list hash changed from %s to %s (%s). New hash doesn't match (%s)", fromLID, cachedLIDHash, deviceLIDHash, child.Tag, newLIDParticipantHash)
164
+ delete(cli.userDevicesCache, *fromLID)
165
+ }
166
+ }
137
167
  }
138
168
  }
139
169
 
140
- func (cli *Client) handleFBDeviceNotification(node *waBinary.Node) {
170
+ func (cli *Client) handleFBDeviceNotification(ctx context.Context, node *waBinary.Node) {
141
171
  cli.userDevicesCacheLock.Lock()
142
172
  defer cli.userDevicesCacheLock.Unlock()
143
173
  jid := node.AttrGetter().JID("from")
@@ -145,7 +175,7 @@ func (cli *Client) handleFBDeviceNotification(node *waBinary.Node) {
145
175
  cli.userDevicesCache[jid] = userDevices
146
176
  }
147
177
 
148
- func (cli *Client) handleOwnDevicesNotification(node *waBinary.Node) {
178
+ func (cli *Client) handleOwnDevicesNotification(ctx context.Context, node *waBinary.Node) {
149
179
  cli.userDevicesCacheLock.Lock()
150
180
  defer cli.userDevicesCacheLock.Unlock()
151
181
  ownID := cli.getOwnID().ToNonAD()
@@ -177,7 +207,7 @@ func (cli *Client) handleOwnDevicesNotification(node *waBinary.Node) {
177
207
  }
178
208
  }
179
209
 
180
- func (cli *Client) handleBlocklist(node *waBinary.Node) {
210
+ func (cli *Client) handleBlocklist(ctx context.Context, node *waBinary.Node) {
181
211
  ag := node.AttrGetter()
182
212
  evt := events.Blocklist{
183
213
  Action: events.BlocklistAction(ag.OptionalString("action")),
@@ -199,29 +229,30 @@ func (cli *Client) handleBlocklist(node *waBinary.Node) {
199
229
  cli.dispatchEvent(&evt)
200
230
  }
201
231
 
202
- func (cli *Client) handleAccountSyncNotification(node *waBinary.Node) {
232
+ func (cli *Client) handleAccountSyncNotification(ctx context.Context, node *waBinary.Node) {
203
233
  for _, child := range node.GetChildren() {
204
234
  switch child.Tag {
205
235
  case "privacy":
206
- cli.handlePrivacySettingsNotification(&child)
236
+ cli.handlePrivacySettingsNotification(ctx, &child)
207
237
  case "devices":
208
- cli.handleOwnDevicesNotification(&child)
238
+ cli.handleOwnDevicesNotification(ctx, &child)
209
239
  case "picture":
210
240
  cli.dispatchEvent(&events.Picture{
211
241
  Timestamp: node.AttrGetter().UnixTime("t"),
212
242
  JID: cli.getOwnID().ToNonAD(),
213
243
  })
214
244
  case "blocklist":
215
- cli.handleBlocklist(&child)
245
+ cli.handleBlocklist(ctx, &child)
216
246
  default:
217
247
  cli.Log.Debugf("Unhandled account sync item %s", child.Tag)
218
248
  }
219
249
  }
220
250
  }
221
251
 
222
- func (cli *Client) handlePrivacyTokenNotification(node *waBinary.Node) {
223
- ownID := cli.getOwnID().ToNonAD()
224
- if ownID.IsEmpty() {
252
+ func (cli *Client) handlePrivacyTokenNotification(ctx context.Context, node *waBinary.Node) {
253
+ ownJID := cli.getOwnID().ToNonAD()
254
+ ownLID := cli.getOwnLID().ToNonAD()
255
+ if ownJID.IsEmpty() {
225
256
  cli.Log.Debugf("Ignoring privacy token notification, session was deleted")
226
257
  return
227
258
  }
@@ -240,8 +271,11 @@ func (cli *Client) handlePrivacyTokenNotification(node *waBinary.Node) {
240
271
  ag := child.AttrGetter()
241
272
  if child.Tag != "token" {
242
273
  cli.Log.Warnf("privacy_token notification contained unexpected <%s> tag", child.Tag)
243
- } else if targetUser := ag.JID("jid"); targetUser != ownID {
244
- cli.Log.Warnf("privacy_token notification contained token for different user %s", targetUser)
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
+ }
245
279
  } else if tokenType := ag.String("type"); tokenType != "trusted_contact" {
246
280
  cli.Log.Warnf("privacy_token notification contained unexpected token type %s", tokenType)
247
281
  } else if token, ok := child.Content.([]byte); !ok {
@@ -251,7 +285,7 @@ func (cli *Client) handlePrivacyTokenNotification(node *waBinary.Node) {
251
285
  if !ag.OK() {
252
286
  cli.Log.Warnf("privacy_token notification is missing some fields: %v", ag.Error())
253
287
  }
254
- err := cli.Store.PrivacyTokens.PutPrivacyTokens(store.PrivacyToken{
288
+ err := cli.Store.PrivacyTokens.PutPrivacyTokens(ctx, store.PrivacyToken{
255
289
  User: sender,
256
290
  Token: token,
257
291
  Timestamp: timestamp,
@@ -308,7 +342,7 @@ func (cli *Client) parseNewsletterMessages(node *waBinary.Node) []*types.Newslet
308
342
  return output
309
343
  }
310
344
 
311
- func (cli *Client) handleNewsletterNotification(node *waBinary.Node) {
345
+ func (cli *Client) handleNewsletterNotification(ctx context.Context, node *waBinary.Node) {
312
346
  ag := node.AttrGetter()
313
347
  liveUpdates := node.GetChildByTag("live_updates")
314
348
  cli.dispatchEvent(&events.NewsletterLiveUpdate{
@@ -331,7 +365,7 @@ type newsletterEvent struct {
331
365
  // _on_state_change -> id, is_requestor, state
332
366
  }
333
367
 
334
- func (cli *Client) handleMexNotification(node *waBinary.Node) {
368
+ func (cli *Client) handleMexNotification(ctx context.Context, node *waBinary.Node) {
335
369
  for _, child := range node.GetChildren() {
336
370
  if child.Tag != "update" {
337
371
  continue
@@ -356,7 +390,7 @@ func (cli *Client) handleMexNotification(node *waBinary.Node) {
356
390
  }
357
391
  }
358
392
 
359
- func (cli *Client) handleStatusNotification(node *waBinary.Node) {
393
+ func (cli *Client) handleStatusNotification(ctx context.Context, node *waBinary.Node) {
360
394
  ag := node.AttrGetter()
361
395
  child, found := node.GetOptionalChildByTag("set")
362
396
  if !found {
@@ -376,44 +410,46 @@ func (cli *Client) handleStatusNotification(node *waBinary.Node) {
376
410
  }
377
411
 
378
412
  func (cli *Client) handleNotification(node *waBinary.Node) {
413
+ ctx := cli.BackgroundEventCtx
379
414
  ag := node.AttrGetter()
380
415
  notifType := ag.String("type")
381
416
  if !ag.OK() {
382
417
  return
383
418
  }
384
- defer cli.maybeDeferredAck(node)()
419
+ var cancelled bool
420
+ defer cli.maybeDeferredAck(ctx, node)(&cancelled)
385
421
  switch notifType {
386
422
  case "encrypt":
387
- go cli.handleEncryptNotification(node)
423
+ go cli.handleEncryptNotification(ctx, node)
388
424
  case "server_sync":
389
- go cli.handleAppStateNotification(node)
425
+ go cli.handleAppStateNotification(ctx, node)
390
426
  case "account_sync":
391
- go cli.handleAccountSyncNotification(node)
427
+ go cli.handleAccountSyncNotification(ctx, node)
392
428
  case "devices":
393
- cli.handleDeviceNotification(node)
429
+ cli.handleDeviceNotification(ctx, node)
394
430
  case "fbid:devices":
395
- cli.handleFBDeviceNotification(node)
431
+ cli.handleFBDeviceNotification(ctx, node)
396
432
  case "w:gp2":
397
433
  evt, err := cli.parseGroupNotification(node)
398
434
  if err != nil {
399
435
  cli.Log.Errorf("Failed to parse group notification: %v", err)
400
436
  } else {
401
- cli.dispatchEvent(evt)
437
+ cancelled = cli.dispatchEvent(evt)
402
438
  }
403
439
  case "picture":
404
- cli.handlePictureNotification(node)
440
+ cli.handlePictureNotification(ctx, node)
405
441
  case "mediaretry":
406
- cli.handleMediaRetryNotification(node)
442
+ cli.handleMediaRetryNotification(ctx, node)
407
443
  case "privacy_token":
408
- cli.handlePrivacyTokenNotification(node)
444
+ cli.handlePrivacyTokenNotification(ctx, node)
409
445
  case "link_code_companion_reg":
410
- go cli.tryHandleCodePairNotification(node)
446
+ go cli.tryHandleCodePairNotification(ctx, node)
411
447
  case "newsletter":
412
- cli.handleNewsletterNotification(node)
448
+ cli.handleNewsletterNotification(ctx, node)
413
449
  case "mex":
414
- cli.handleMexNotification(node)
450
+ cli.handleMexNotification(ctx, node)
415
451
  case "status":
416
- cli.handleStatusNotification(node)
452
+ cli.handleStatusNotification(ctx, node)
417
453
  // Other types: business, disappearing_mode, server, status, pay, psa
418
454
  default:
419
455
  cli.Log.Debugf("Unhandled notification with type %s", notifType)
@@ -7,6 +7,7 @@
7
7
  package whatsmeow
8
8
 
9
9
  import (
10
+ "context"
10
11
  "crypto/aes"
11
12
  "crypto/cipher"
12
13
  "crypto/sha256"
@@ -86,7 +87,7 @@ func generateCompanionEphemeralKey() (ephemeralKeyPair *keys.KeyPair, ephemeralK
86
87
  // (the server will validate it and return 400 if it's wrong).
87
88
  //
88
89
  // See https://faq.whatsapp.com/1324084875126592 for more info
89
- func (cli *Client) PairPhone(phone string, showPushNotification bool, clientType PairClientType, clientDisplayName string) (string, error) {
90
+ func (cli *Client) PairPhone(ctx context.Context, phone string, showPushNotification bool, clientType PairClientType, clientDisplayName string) (string, error) {
90
91
  if cli == nil {
91
92
  return "", ErrClientIsNil
92
93
  }
@@ -102,6 +103,7 @@ func (cli *Client) PairPhone(phone string, showPushNotification bool, clientType
102
103
  Namespace: "md",
103
104
  Type: iqSet,
104
105
  To: types.ServerJID,
106
+ Context: ctx,
105
107
  Content: []waBinary.Node{{
106
108
  Tag: "link_code_companion_reg",
107
109
  Attrs: waBinary.Attrs{
@@ -139,14 +141,14 @@ func (cli *Client) PairPhone(phone string, showPushNotification bool, clientType
139
141
  return encodedLinkingCode[0:4] + "-" + encodedLinkingCode[4:], nil
140
142
  }
141
143
 
142
- func (cli *Client) tryHandleCodePairNotification(parentNode *waBinary.Node) {
143
- err := cli.handleCodePairNotification(parentNode)
144
+ func (cli *Client) tryHandleCodePairNotification(ctx context.Context, parentNode *waBinary.Node) {
145
+ err := cli.handleCodePairNotification(ctx, parentNode)
144
146
  if err != nil {
145
147
  cli.Log.Errorf("Failed to handle code pair notification: %s", err)
146
148
  }
147
149
  }
148
150
 
149
- func (cli *Client) handleCodePairNotification(parentNode *waBinary.Node) error {
151
+ func (cli *Client) handleCodePairNotification(ctx context.Context, parentNode *waBinary.Node) error {
150
152
  node, ok := parentNode.GetOptionalChildByTag("link_code_companion_reg")
151
153
  if !ok {
152
154
  return &ElementMissingError{
@@ -225,6 +227,7 @@ func (cli *Client) handleCodePairNotification(parentNode *waBinary.Node) error {
225
227
  Namespace: "md",
226
228
  Type: iqSet,
227
229
  To: types.ServerJID,
230
+ Context: ctx,
228
231
  Content: []waBinary.Node{{
229
232
  Tag: "link_code_companion_reg",
230
233
  Attrs: waBinary.Attrs{