slidge-whatsapp 0.2.6__cp313-cp313-manylinux_2_36_x86_64.whl → 0.3.0b0__cp313-cp313-manylinux_2_36_x86_64.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 (258) hide show
  1. slidge_whatsapp/contact.py +13 -3
  2. slidge_whatsapp/event.go +115 -39
  3. slidge_whatsapp/gateway.go +7 -63
  4. slidge_whatsapp/gateway.py +2 -3
  5. slidge_whatsapp/generated/_whatsapp.cpython-313-x86_64-linux-gnu.h +182 -165
  6. slidge_whatsapp/generated/_whatsapp.cpython-313-x86_64-linux-gnu.so +0 -0
  7. slidge_whatsapp/generated/build.py +142 -128
  8. slidge_whatsapp/generated/whatsapp.c +1735 -1463
  9. slidge_whatsapp/generated/whatsapp.go +1280 -1169
  10. slidge_whatsapp/generated/whatsapp.py +1464 -1339
  11. slidge_whatsapp/generated/whatsapp_go.h +182 -165
  12. slidge_whatsapp/go.mod +18 -15
  13. slidge_whatsapp/go.sum +38 -32
  14. slidge_whatsapp/group.py +34 -30
  15. slidge_whatsapp/media/media.go +6 -2
  16. slidge_whatsapp/session.go +33 -16
  17. slidge_whatsapp/session.py +46 -14
  18. slidge_whatsapp/vendor/github.com/beeper/argo-go/LICENSE +9 -0
  19. slidge_whatsapp/vendor/github.com/beeper/argo-go/block/blockreader.go +329 -0
  20. slidge_whatsapp/vendor/github.com/beeper/argo-go/block/blockwriter.go +417 -0
  21. slidge_whatsapp/vendor/github.com/beeper/argo-go/codec/decoder.go +652 -0
  22. slidge_whatsapp/vendor/github.com/beeper/argo-go/codec/encoder.go +985 -0
  23. slidge_whatsapp/vendor/github.com/beeper/argo-go/header/header.go +135 -0
  24. slidge_whatsapp/vendor/github.com/beeper/argo-go/internal/util/util.go +133 -0
  25. slidge_whatsapp/vendor/github.com/beeper/argo-go/label/label.go +384 -0
  26. slidge_whatsapp/vendor/github.com/beeper/argo-go/label/wiremarkers.go +37 -0
  27. slidge_whatsapp/vendor/github.com/beeper/argo-go/pkg/bitset/bitset.go +197 -0
  28. slidge_whatsapp/vendor/github.com/beeper/argo-go/pkg/buf/buf.go +420 -0
  29. slidge_whatsapp/vendor/github.com/beeper/argo-go/pkg/varint/varint.go +246 -0
  30. slidge_whatsapp/vendor/github.com/beeper/argo-go/wire/wire.go +614 -0
  31. slidge_whatsapp/vendor/github.com/beeper/argo-go/wirecodec/decode.go +341 -0
  32. slidge_whatsapp/vendor/github.com/elliotchance/orderedmap/v3/LICENSE +21 -0
  33. slidge_whatsapp/vendor/github.com/elliotchance/orderedmap/v3/list.go +95 -0
  34. slidge_whatsapp/vendor/github.com/elliotchance/orderedmap/v3/orderedmap.go +187 -0
  35. slidge_whatsapp/vendor/github.com/gen2brain/go-fitz/fitz.go +1 -0
  36. slidge_whatsapp/vendor/github.com/gen2brain/go-fitz/fitz_cgo.go +3 -0
  37. slidge_whatsapp/vendor/github.com/gen2brain/go-fitz/fitz_nocgo.go +4 -5
  38. slidge_whatsapp/vendor/github.com/gen2brain/go-fitz/purego_darwin.go +11 -1
  39. slidge_whatsapp/vendor/github.com/gen2brain/go-fitz/purego_linux.go +10 -0
  40. slidge_whatsapp/vendor/github.com/gen2brain/go-fitz/purego_windows.go +12 -0
  41. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/.gitignore +0 -2
  42. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/CHANGELOG.md +30 -0
  43. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/COPYRIGHT.txt +6 -1
  44. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/README.md +14 -17
  45. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/abi.go +1 -1
  46. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/abi2.go +7 -0
  47. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/assets/libffi/LICENSE +21 -0
  48. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/assets/libffi/darwin_amd64/libffi.8.dylib +0 -0
  49. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/assets/libffi/darwin_arm64/libffi.8.dylib +0 -0
  50. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/assets/libffi/windows_amd64/libffi-8.dll +0 -0
  51. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/cif.go +15 -0
  52. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/cif_arm64.go +16 -0
  53. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/embed.go +49 -0
  54. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/embed_darwin_amd64.go +10 -0
  55. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/embed_darwin_arm64.go +10 -0
  56. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/embed_windows_amd64.go +10 -0
  57. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/ffi.go +51 -13
  58. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/init.go +22 -9
  59. slidge_whatsapp/vendor/github.com/mattn/go-sqlite3/README.md +2 -0
  60. slidge_whatsapp/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c +3096 -1651
  61. slidge_whatsapp/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.h +188 -128
  62. slidge_whatsapp/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_userauth.go +13 -140
  63. slidge_whatsapp/vendor/github.com/mattn/go-sqlite3/sqlite3ext.h +4 -0
  64. slidge_whatsapp/vendor/github.com/petermattis/goid/runtime_go1.23.go +2 -2
  65. slidge_whatsapp/vendor/github.com/petermattis/goid/runtime_go1.25.go +37 -0
  66. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/LICENSE +19 -0
  67. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/argmap.go +37 -0
  68. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/collections.go +148 -0
  69. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/comment.go +31 -0
  70. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/decode.go +216 -0
  71. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/definition.go +110 -0
  72. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/directive.go +43 -0
  73. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/document.go +89 -0
  74. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/dumper.go +159 -0
  75. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/fragment.go +41 -0
  76. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/operation.go +32 -0
  77. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/path.go +72 -0
  78. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/selection.go +41 -0
  79. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/source.go +19 -0
  80. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/type.go +68 -0
  81. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/value.go +122 -0
  82. slidge_whatsapp/vendor/go.mau.fi/util/exhttp/handleerrors.go +60 -26
  83. slidge_whatsapp/vendor/go.mau.fi/util/exhttp/json.go +1 -6
  84. slidge_whatsapp/vendor/go.mau.fi/util/exhttp/networkerror.go +2 -1
  85. slidge_whatsapp/vendor/go.mau.fi/util/exstrings/stringutil.go +104 -0
  86. slidge_whatsapp/vendor/go.mau.fi/util/exsync/event.go +19 -3
  87. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/.pre-commit-config.yaml +3 -3
  88. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate/decode.go +1 -1
  89. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate/hash.go +1 -1
  90. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate.go +5 -1
  91. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/argo/argo-wire-type-store.argo +63 -0
  92. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/argo/argo.go +62 -0
  93. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/argo/name-to-queryids.json +306 -0
  94. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/armadillomessage.go +40 -7
  95. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/binary/encoder.go +1 -1
  96. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/call.go +2 -1
  97. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/client.go +79 -45
  98. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/connectionevents.go +13 -6
  99. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/download-to-file.go +19 -12
  100. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/download.go +26 -6
  101. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/errors.go +3 -0
  102. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/group.go +99 -27
  103. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/internals.go +54 -26
  104. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/keepalive.go +1 -0
  105. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/message.go +208 -57
  106. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/msgsecret.go +2 -14
  107. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/newsletter.go +83 -7
  108. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/notification.go +17 -8
  109. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/pair-code.go +2 -2
  110. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/presence.go +15 -6
  111. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/extra.go +7 -0
  112. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloAddMessage/InstamadilloAddMessage.pb.go +983 -0
  113. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloAddMessage/InstamadilloAddMessage.proto +85 -0
  114. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloAddMessage/extra.go +3 -0
  115. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeActionLog/InstamadilloCoreTypeActionLog.pb.go +197 -0
  116. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeActionLog/InstamadilloCoreTypeActionLog.proto +13 -0
  117. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeAdminMessage/InstamadilloCoreTypeAdminMessage.pb.go +279 -0
  118. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeAdminMessage/InstamadilloCoreTypeAdminMessage.proto +21 -0
  119. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeCollection/InstamadilloCoreTypeCollection.pb.go +137 -0
  120. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeCollection/InstamadilloCoreTypeCollection.proto +10 -0
  121. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeLink/InstamadilloCoreTypeLink.pb.go +313 -0
  122. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeLink/InstamadilloCoreTypeLink.proto +27 -0
  123. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeMedia/InstamadilloCoreTypeMedia.pb.go +1299 -0
  124. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeMedia/InstamadilloCoreTypeMedia.proto +112 -0
  125. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeText/InstamadilloCoreTypeText.pb.go +514 -0
  126. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeText/InstamadilloCoreTypeText.proto +47 -0
  127. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloDeleteMessage/InstamadilloDeleteMessage.pb.go +123 -0
  128. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloDeleteMessage/InstamadilloDeleteMessage.proto +7 -0
  129. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloDeleteMessage/extra.go +3 -0
  130. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloSupplementMessage/InstamadilloSupplementMessage.pb.go +720 -0
  131. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloSupplementMessage/InstamadilloSupplementMessage.proto +59 -0
  132. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloSupplementMessage/extra.go +3 -0
  133. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloTransportPayload/InstamadilloTransportPayload.pb.go +365 -0
  134. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloTransportPayload/InstamadilloTransportPayload.proto +33 -0
  135. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloXmaContentRef/InstamadilloXmaContentRef.pb.go +1238 -0
  136. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloXmaContentRef/InstamadilloXmaContentRef.proto +105 -0
  137. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waArmadilloXMA/WAArmadilloXMA.pb.go +16 -4
  138. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waArmadilloXMA/WAArmadilloXMA.proto +3 -0
  139. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waBotMetadata/WABotMetadata.pb.go +5156 -0
  140. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waBotMetadata/WABotMetadata.proto +516 -0
  141. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCompanionReg/WACompanionReg.pb.go +46 -10
  142. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCompanionReg/WACompanionReg.proto +4 -0
  143. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.pb.go +8975 -11209
  144. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.proto +193 -421
  145. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waHistorySync/WAWebProtobufsHistorySync.pb.go +52 -23
  146. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waHistorySync/WAWebProtobufsHistorySync.proto +3 -0
  147. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waLidMigrationSyncPayload/WAWebProtobufLidMigrationSyncPayload.pb.go +198 -0
  148. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waLidMigrationSyncPayload/WAWebProtobufLidMigrationSyncPayload.proto +14 -0
  149. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMsgTransport/extra.go +7 -6
  150. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.pb.go +952 -0
  151. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.proto +88 -0
  152. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.pb.go +1143 -463
  153. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.proto +60 -0
  154. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWa6/WAWebProtobufsWa6.pb.go +60 -38
  155. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWa6/WAWebProtobufsWa6.proto +3 -0
  156. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWeb/WAWebProtobufsWeb.pb.go +11 -3
  157. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWeb/WAWebProtobufsWeb.proto +2 -0
  158. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/receipt.go +20 -7
  159. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/reportingfields.json +1 -0
  160. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/reportingtoken.go +176 -0
  161. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/retry.go +10 -2
  162. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/send.go +38 -21
  163. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/sendfb.go +1 -0
  164. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/clientpayload.go +1 -1
  165. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/noop.go +3 -2
  166. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/container.go +9 -6
  167. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/store.go +25 -5
  168. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrades/00-latest-schema.sql +4 -2
  169. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrades/10-chat-db-lid-migration-ts.sql +2 -0
  170. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/store.go +5 -1
  171. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/call.go +1 -0
  172. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/events/events.go +13 -2
  173. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/jid.go +2 -1
  174. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/message.go +1 -0
  175. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/user.go +2 -0
  176. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/user.go +14 -8
  177. slidge_whatsapp/vendor/golang.org/x/crypto/curve25519/curve25519.go +1 -1
  178. slidge_whatsapp/vendor/golang.org/x/net/http2/config.go +44 -2
  179. slidge_whatsapp/vendor/golang.org/x/net/http2/frame.go +8 -8
  180. slidge_whatsapp/vendor/golang.org/x/net/http2/gotrack.go +14 -3
  181. slidge_whatsapp/vendor/golang.org/x/net/http2/http2.go +7 -29
  182. slidge_whatsapp/vendor/golang.org/x/net/http2/server.go +53 -71
  183. slidge_whatsapp/vendor/golang.org/x/net/http2/transport.go +20 -74
  184. slidge_whatsapp/vendor/golang.org/x/sys/unix/affinity_linux.go +1 -3
  185. slidge_whatsapp/vendor/golang.org/x/sys/unix/mkerrors.sh +3 -0
  186. slidge_whatsapp/vendor/golang.org/x/sys/unix/syscall_darwin.go +1 -55
  187. slidge_whatsapp/vendor/golang.org/x/sys/unix/syscall_solaris.go +1 -1
  188. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux.go +47 -16
  189. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +3 -0
  190. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +3 -0
  191. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +3 -0
  192. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +3 -0
  193. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +3 -0
  194. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +3 -0
  195. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +3 -0
  196. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +3 -0
  197. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +3 -0
  198. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +3 -0
  199. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +3 -0
  200. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +3 -0
  201. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +3 -0
  202. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +3 -0
  203. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +3 -0
  204. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go +4 -4
  205. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go +1 -0
  206. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +1 -0
  207. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +1 -0
  208. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +1 -0
  209. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go +1 -0
  210. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +1 -0
  211. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +1 -0
  212. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +1 -0
  213. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +1 -0
  214. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go +1 -0
  215. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +1 -0
  216. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +1 -0
  217. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +1 -0
  218. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +1 -0
  219. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +1 -0
  220. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux.go +168 -12
  221. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_386.go +17 -1
  222. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +16 -0
  223. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go +18 -2
  224. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +16 -0
  225. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_loong64.go +16 -0
  226. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go +17 -1
  227. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +16 -0
  228. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +16 -0
  229. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go +17 -1
  230. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go +18 -2
  231. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +16 -0
  232. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +16 -0
  233. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +16 -0
  234. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go +16 -0
  235. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go +16 -0
  236. slidge_whatsapp/vendor/golang.org/x/sys/windows/types_windows.go +6 -0
  237. slidge_whatsapp/vendor/golang.org/x/sys/windows/zsyscall_windows.go +483 -483
  238. slidge_whatsapp/vendor/google.golang.org/protobuf/encoding/protowire/wire.go +25 -1
  239. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb +0 -0
  240. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/filedesc/editions.go +10 -5
  241. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/filedesc/presence.go +33 -0
  242. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/genid/api_gen.go +6 -0
  243. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go +68 -22
  244. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/impl/codec_message_opaque.go +2 -1
  245. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/impl/message_opaque.go +8 -37
  246. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/impl/presence.go +0 -3
  247. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/version/version.go +1 -1
  248. slidge_whatsapp/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go +8 -0
  249. slidge_whatsapp/vendor/modules.txt +57 -23
  250. {slidge_whatsapp-0.2.6.dist-info → slidge_whatsapp-0.3.0b0.dist-info}/METADATA +2 -2
  251. {slidge_whatsapp-0.2.6.dist-info → slidge_whatsapp-0.3.0b0.dist-info}/RECORD +254 -174
  252. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/abi_amd64.go +0 -7
  253. slidge_whatsapp/vendor/golang.org/x/net/http2/config_go124.go +0 -61
  254. slidge_whatsapp/vendor/golang.org/x/net/http2/config_pre_go124.go +0 -16
  255. slidge_whatsapp/vendor/golang.org/x/net/http2/timer.go +0 -20
  256. {slidge_whatsapp-0.2.6.dist-info → slidge_whatsapp-0.3.0b0.dist-info}/LICENSE +0 -0
  257. {slidge_whatsapp-0.2.6.dist-info → slidge_whatsapp-0.3.0b0.dist-info}/WHEEL +0 -0
  258. {slidge_whatsapp-0.2.6.dist-info → slidge_whatsapp-0.3.0b0.dist-info}/entry_points.txt +0 -0
@@ -2,6 +2,7 @@ from datetime import datetime, timezone
2
2
  from typing import TYPE_CHECKING
3
3
 
4
4
  from slidge import LegacyContact, LegacyRoster
5
+ from slidge.util.types import Avatar
5
6
  from slixmpp.exceptions import XMPPError
6
7
 
7
8
  from . import config
@@ -28,6 +29,12 @@ class Contact(LegacyContact[str]):
28
29
  else:
29
30
  self.online(last_seen=last_seen)
30
31
 
32
+ async def update_info(self) -> None:
33
+ if whatsapp.IsAnonymousJID(self.legacy_id):
34
+ self.log.error(
35
+ "Contact for anonymous participant added: %s", self.legacy_id
36
+ )
37
+
31
38
 
32
39
  class Roster(LegacyRoster[str, Contact]):
33
40
  session: "Session"
@@ -54,9 +61,12 @@ class Roster(LegacyRoster[str, Contact]):
54
61
  contact.name = data.Name
55
62
  contact.is_friend = True
56
63
  try:
57
- avatar = self.session.whatsapp.GetAvatar(data.JID, contact.avatar or "")
58
- if avatar.URL and contact.avatar != avatar.ID:
59
- await contact.set_avatar(avatar.URL, avatar.ID)
64
+ unique_id = ""
65
+ if contact.avatar is not None:
66
+ unique_id = contact.avatar.unique_id or ""
67
+ avatar = self.session.whatsapp.GetAvatar(data.JID, unique_id)
68
+ if avatar.URL and unique_id != avatar.ID:
69
+ await contact.set_avatar(Avatar(url=avatar.URL, unique_id=avatar.ID))
60
70
  elif avatar.URL == "" and avatar.ID == "":
61
71
  await contact.set_avatar(None)
62
72
  except RuntimeError as err:
slidge_whatsapp/event.go CHANGED
@@ -46,6 +46,7 @@ type EventPayload struct {
46
46
  QRCode string
47
47
  PairDeviceID string
48
48
  Connect Connect
49
+ LoggedOut LoggedOut
49
50
  Contact Contact
50
51
  Presence Presence
51
52
  Message Message
@@ -66,6 +67,11 @@ type Connect struct {
66
67
  Error string // The connection error, if any.
67
68
  }
68
69
 
70
+ // LoggedOut repreents event data related to an explicit or implicit log-out event.
71
+ type LoggedOut struct {
72
+ Reason string // The human-readable reason for logging out, if any.
73
+ }
74
+
69
75
  // A Avatar represents a small image set for a Contact or Group.
70
76
  type Avatar struct {
71
77
  ID string // The unique ID for this avatar, used for persistent caching.
@@ -82,10 +88,25 @@ type Contact struct {
82
88
  // NewContactEvent returns event data meant for [Session.propagateEvent] for the contact information
83
89
  // given. Unknown or invalid contact information will return an [EventUnknown] event with nil data.
84
90
  func newContactEvent(jid types.JID, info types.ContactInfo) (EventKind, *EventPayload) {
85
- var contact = Contact{
86
- JID: jid.ToNonAD().String(),
91
+ contact := newContact(jid, info)
92
+ if contact.JID == "" {
93
+ return EventUnknown, nil
87
94
  }
88
95
 
96
+ return EventContact, &EventPayload{Contact: contact}
97
+ }
98
+
99
+ // NewContact returns a concrete [Contact] instance for the JID and additional information given.
100
+ // In cases where a valid contact can't be returned, [Contact.JID] will be left empty.
101
+ func newContact(jid types.JID, info types.ContactInfo) Contact {
102
+ // Don't instantiate hidden contacts, as these are better handled as group participants
103
+ if jid.Server == types.HiddenUserServer {
104
+ return Contact{}
105
+ }
106
+
107
+ // Find valid contact name from list of alternatives, or return empty contact if none could
108
+ // be found.
109
+ var contact = Contact{JID: jid.ToNonAD().String()}
89
110
  for _, n := range []string{info.FullName, info.FirstName, info.BusinessName, info.PushName} {
90
111
  if n != "" {
91
112
  contact.Name = n
@@ -93,12 +114,11 @@ func newContactEvent(jid types.JID, info types.ContactInfo) (EventKind, *EventPa
93
114
  }
94
115
  }
95
116
 
96
- // Don't attempt to synchronize contacts with no user-readable name.
97
117
  if contact.Name == "" {
98
- return EventUnknown, nil
118
+ return Contact{}
99
119
  }
100
120
 
101
- return EventContact, &EventPayload{Contact: contact}
121
+ return contact
102
122
  }
103
123
 
104
124
  // PresenceKind represents the different kinds of activity states possible in WhatsApp.
@@ -169,9 +189,11 @@ type Message struct {
169
189
  Location Location // The location metadata for messages, if any.
170
190
  Poll Poll // The multiple-choice poll contained in the message, if any.
171
191
  Album Album // The image album message, if any.
192
+ GroupInvite Group // Group information for the invite group included in this message, if any.
172
193
  MentionJIDs []string // A list of JIDs mentioned in this message, if any.
173
194
  Receipts []Receipt // The receipt statuses for the message, typically provided alongside historical messages.
174
195
  Reactions []Message // Reactions attached to message, typically provided alongside historical messages.
196
+ IsHistory bool // Whether or not the message is derived from message history.
175
197
  }
176
198
 
177
199
  // A Attachment represents additional binary data (e.g. images, videos, documents) provided alongside
@@ -253,14 +275,13 @@ type Album struct {
253
275
 
254
276
  // NewMessageEvent returns event data meant for [Session.propagateEvent] for the primive message
255
277
  // event given. Unknown or invalid messages will return an [EventUnknown] event with nil data.
256
- func newMessageEvent(client *whatsmeow.Client, evt *events.Message) (EventKind, *EventPayload) {
278
+ func newMessageEvent(ctx context.Context, client *whatsmeow.Client, evt *events.Message) (EventKind, *EventPayload) {
257
279
  // Set basic data for message, to be potentially amended depending on the concrete version of
258
280
  // the underlying message.
259
- var ctx = context.Background()
260
281
  var message = Message{
261
282
  Kind: MessagePlain,
262
283
  ID: evt.Info.ID,
263
- JID: evt.Info.Sender.ToNonAD().String(),
284
+ JID: getPreferredJID(ctx, client, evt.Info.Sender, evt.Info.SenderAlt).ToNonAD().String(),
264
285
  Body: evt.Message.GetConversation(),
265
286
  Timestamp: evt.Info.Timestamp.Unix(),
266
287
  IsCarbon: evt.Info.IsFromMe,
@@ -378,7 +399,18 @@ func newMessageEvent(client *whatsmeow.Client, evt *events.Message) (EventKind,
378
399
  message.Body = e.GetText()
379
400
  }
380
401
 
381
- message = getMessageWithContext(message, e.GetContextInfo())
402
+ // Handle group-chat invite link in text message.
403
+ if code, ok := strings.CutPrefix(e.GetMatchedText(), whatsmeow.InviteLinkPrefix); ok {
404
+ if info, err := client.GetGroupInfoFromLink(e.GetMatchedText()); err != nil {
405
+ client.Log.Errorf("Failed getting group info from invite: %s", err)
406
+ } else if _, err := client.JoinGroupWithLink(code); err != nil {
407
+ client.Log.Errorf("Failed joining group with invite: %s", err)
408
+ } else {
409
+ message.GroupInvite = newGroup(ctx, client, info)
410
+ }
411
+ } else {
412
+ message = getMessageWithContext(message, e.GetContextInfo())
413
+ }
382
414
  }
383
415
 
384
416
  // Ignore obviously invalid messages.
@@ -424,6 +456,7 @@ func getMessageAttachments(ctx context.Context, client *whatsmeow.Client, messag
424
456
  message.GetVideoMessage(),
425
457
  message.GetDocumentMessage(),
426
458
  message.GetStickerMessage(),
459
+ message.GetPtvMessage(),
427
460
  }
428
461
 
429
462
  for _, msg := range kinds {
@@ -462,7 +495,9 @@ func getMessageAttachments(ctx context.Context, client *whatsmeow.Client, messag
462
495
  // Convert incoming data if a specification has been given, ignoring any errors that occur.
463
496
  if convertSpec != nil {
464
497
  data, err = media.Convert(ctx, a.Data, convertSpec)
465
- if err == nil {
498
+ if err != nil {
499
+ client.Log.Warnf("failed to convert incoming attachment: %s", err)
500
+ } else {
466
501
  a.Data, a.MIME = data, string(convertSpec.MIME)
467
502
  }
468
503
  }
@@ -648,6 +683,10 @@ func convertAttachment(ctx context.Context, attach *Attachment) error {
648
683
  }
649
684
 
650
685
  attach.Data, attach.MIME = data, string(spec.MIME)
686
+ if i := strings.LastIndexByte(attach.Filename, '.'); i != -1 {
687
+ attach.Filename = attach.Filename[:i] + extensionByType(attach.MIME)
688
+ }
689
+
651
690
  return nil
652
691
  }
653
692
 
@@ -669,7 +708,7 @@ var knownMediaTypes = map[string]whatsmeow.MediaType{
669
708
  func uploadAttachment(ctx context.Context, client *whatsmeow.Client, attach *Attachment) (*waE2E.Message, error) {
670
709
  var originalMIME = attach.MIME
671
710
  if err := convertAttachment(ctx, attach); err != nil {
672
- client.Log.Warnf("failed to auto-convert attachment: %s", err)
711
+ client.Log.Warnf("failed to convert outgoing attachment: %s", err)
673
712
  }
674
713
 
675
714
  mediaType := knownMediaTypes[getBaseMediaType(attach.MIME)]
@@ -831,10 +870,9 @@ func getBaseMediaType(typ string) string {
831
870
  //
832
871
  // Typically, this will return [EventMessage] events with appropriate [Message] payloads; unknown or
833
872
  // invalid messages will return an [EventUnknown] event with nil data.
834
- func newEventFromHistory(client *whatsmeow.Client, info *waWeb.WebMessageInfo) (EventKind, *EventPayload) {
873
+ func newEventFromHistory(ctx context.Context, client *whatsmeow.Client, info *waWeb.WebMessageInfo) (EventKind, *EventPayload) {
835
874
  // Handle message as group message is remote JID is a group JID in the absence of any other,
836
875
  // specific signal, or don't handle at all if no group JID is found.
837
- var ctx = context.Background()
838
876
  var jid = info.GetKey().GetRemoteJID()
839
877
  if j, _ := types.ParseJID(jid); j.Server != types.GroupServer {
840
878
  return EventUnknown, nil
@@ -849,6 +887,7 @@ func newEventFromHistory(client *whatsmeow.Client, info *waWeb.WebMessageInfo) (
849
887
  Body: info.GetMessage().GetConversation(),
850
888
  Timestamp: int64(info.GetMessageTimestamp()),
851
889
  IsCarbon: info.GetKey().GetFromMe(),
890
+ IsHistory: true,
852
891
  }
853
892
 
854
893
  if info.Participant != nil {
@@ -1003,10 +1042,10 @@ type Receipt struct {
1003
1042
 
1004
1043
  // NewReceiptEvent returns event data meant for [Session.propagateEvent] for the primive receipt
1005
1044
  // event given. Unknown or invalid receipts will return an [EventUnknown] event with nil data.
1006
- func newReceiptEvent(evt *events.Receipt) (EventKind, *EventPayload) {
1045
+ func newReceiptEvent(ctx context.Context, client *whatsmeow.Client, evt *events.Receipt) (EventKind, *EventPayload) {
1007
1046
  var receipt = Receipt{
1008
1047
  MessageIDs: slices.Clone(evt.MessageIDs),
1009
- JID: evt.Sender.ToNonAD().String(),
1048
+ JID: getPreferredJID(ctx, client, evt.Sender, evt.SenderAlt).ToNonAD().String(),
1010
1049
  Timestamp: evt.Timestamp.Unix(),
1011
1050
  IsCarbon: evt.IsFromMe,
1012
1051
  }
@@ -1053,14 +1092,15 @@ type Group struct {
1053
1092
  Subject GroupSubject // The longer-form, user-defined description for this group.
1054
1093
  Nickname string // Our own nickname in this group-chat.
1055
1094
  Participants []GroupParticipant // The list of participant contacts for this group, including ourselves.
1095
+ InviteCode string // The code for inviting members to this group-chat.
1056
1096
  }
1057
1097
 
1058
1098
  // A GroupSubject represents the user-defined group description and attached metadata thereof, for a
1059
1099
  // given [Group].
1060
1100
  type GroupSubject struct {
1061
- Subject string // The user-defined group description.
1062
- SetAt int64 // The exact time this group description was set at, as a timestamp.
1063
- SetByJID string // The JID of the user that set the subject.
1101
+ Subject string // The user-defined group description.
1102
+ SetAt int64 // The exact time this group description was set at, as a timestamp.
1103
+ SetBy string // The name of the user that set the subject.
1064
1104
  }
1065
1105
 
1066
1106
  // GroupParticipantAction represents the distinct set of actions that can be taken when encountering
@@ -1090,10 +1130,11 @@ func (a GroupParticipantAction) toParticipantChange() whatsmeow.ParticipantChang
1090
1130
  }
1091
1131
 
1092
1132
  // A GroupParticipant represents a contact who is currently joined in a given group. Participants in
1093
- // WhatsApp can always be derived back to their individual [Contact]; there are no anonymous groups
1133
+ // WhatsApp can generally be derived back to their individual [Contact]; there are no anonymous groups
1094
1134
  // in WhatsApp.
1095
1135
  type GroupParticipant struct {
1096
1136
  JID string // The WhatsApp JID for this participant.
1137
+ Nickname string // The user-set name for this participant, typically only set for anonymous participants.
1097
1138
  Affiliation GroupAffiliation // The set of priviledges given to this specific participant.
1098
1139
  Action GroupParticipantAction // The specific action to take for this participant; typically to add.
1099
1140
  }
@@ -1101,35 +1142,42 @@ type GroupParticipant struct {
1101
1142
  // NewGroupParticipant returns a [GroupParticipant], filling fields from the internal participant
1102
1143
  // type. This is a no-op if [types.GroupParticipant.Error] is non-zero, and other fields may only
1103
1144
  // be set optionally.
1104
- func newGroupParticipant(p types.GroupParticipant) GroupParticipant {
1105
- if p.Error > 0 {
1145
+ func newGroupParticipant(ctx context.Context, client *whatsmeow.Client, participant types.GroupParticipant) GroupParticipant {
1146
+ if participant.Error > 0 {
1106
1147
  return GroupParticipant{}
1107
1148
  }
1108
- var affiliation = GroupAffiliationNone
1109
- if p.IsSuperAdmin {
1110
- affiliation = GroupAffiliationOwner
1111
- } else if p.IsAdmin {
1112
- affiliation = GroupAffiliationAdmin
1149
+ var p = GroupParticipant{
1150
+ JID: participant.JID.ToNonAD().String(),
1113
1151
  }
1114
- return GroupParticipant{
1115
- JID: p.JID.ToNonAD().String(),
1116
- Affiliation: affiliation,
1152
+ if participant.IsSuperAdmin {
1153
+ p.Affiliation = GroupAffiliationOwner
1154
+ } else if participant.IsAdmin {
1155
+ p.Affiliation = GroupAffiliationAdmin
1117
1156
  }
1157
+ if IsAnonymousJID(p.JID) {
1158
+ if c, err := client.Store.Contacts.GetContact(ctx, participant.JID); err == nil {
1159
+ p.Nickname = c.PushName
1160
+ }
1161
+ }
1162
+ return p
1118
1163
  }
1119
1164
 
1120
1165
  // NewGroupEvent returns event data meant for [Session.propagateEvent] for the primive group event
1121
1166
  // given. Group data returned by this function can be partial, and callers should take care to only
1122
1167
  // handle non-empty values.
1123
- func newGroupEvent(evt *events.GroupInfo) (EventKind, *EventPayload) {
1168
+ func newGroupEvent(ctx context.Context, client *whatsmeow.Client, evt *events.GroupInfo) (EventKind, *EventPayload) {
1124
1169
  var group = Group{JID: evt.JID.ToNonAD().String()}
1125
1170
  if evt.Name != nil {
1126
1171
  group.Name = evt.Name.Name
1127
1172
  }
1128
1173
  if evt.Topic != nil {
1174
+ topicJID := getPreferredJID(ctx, client, evt.Topic.TopicSetBy, evt.Topic.TopicSetByPN)
1129
1175
  group.Subject = GroupSubject{
1130
- Subject: evt.Topic.Topic,
1131
- SetAt: evt.Topic.TopicSetAt.Unix(),
1132
- SetByJID: evt.Topic.TopicSetBy.ToNonAD().String(),
1176
+ Subject: evt.Topic.Topic,
1177
+ SetAt: evt.Topic.TopicSetAt.Unix(),
1178
+ }
1179
+ if c, err := client.Store.Contacts.GetContact(ctx, topicJID); err == nil {
1180
+ group.Subject.SetBy = c.PushName
1133
1181
  }
1134
1182
  }
1135
1183
  for _, p := range evt.Join {
@@ -1164,26 +1212,32 @@ func newGroupEvent(evt *events.GroupInfo) (EventKind, *EventPayload) {
1164
1212
  // NewGroup returns a concrete [Group] for the primitive data given. This function will generally
1165
1213
  // populate fields with as much data as is available from the remote, and is therefore should not
1166
1214
  // be called when partial data is to be returned.
1167
- func newGroup(client *whatsmeow.Client, info *types.GroupInfo) Group {
1215
+ func newGroup(ctx context.Context, client *whatsmeow.Client, info *types.GroupInfo) Group {
1168
1216
  var participants []GroupParticipant
1169
1217
  for i := range info.Participants {
1170
- p := newGroupParticipant(info.Participants[i])
1218
+ p := newGroupParticipant(ctx, client, info.Participants[i])
1171
1219
  if p.JID == "" {
1172
1220
  continue
1173
1221
  }
1174
1222
  participants = append(participants, p)
1175
1223
  }
1176
- return Group{
1224
+
1225
+ var topicJID = getPreferredJID(ctx, client, info.TopicSetBy, info.TopicSetByPN)
1226
+ var group = Group{
1177
1227
  JID: info.JID.ToNonAD().String(),
1178
1228
  Name: info.Name,
1179
1229
  Subject: GroupSubject{
1180
- Subject: info.Topic,
1181
- SetAt: info.TopicSetAt.Unix(),
1182
- SetByJID: info.TopicSetBy.ToNonAD().String(),
1230
+ Subject: info.Topic,
1231
+ SetAt: info.TopicSetAt.Unix(),
1183
1232
  },
1184
1233
  Nickname: client.Store.PushName,
1185
1234
  Participants: participants,
1186
1235
  }
1236
+ if c, err := client.Store.Contacts.GetContact(ctx, topicJID); err == nil {
1237
+ group.Subject.SetBy = c.PushName
1238
+ }
1239
+
1240
+ return group
1187
1241
  }
1188
1242
 
1189
1243
  // CallState represents the state of the call to synchronize with.
@@ -1228,3 +1282,25 @@ func newCallEvent(state CallState, meta types.BasicCallMeta) (EventKind, *EventP
1228
1282
  Timestamp: meta.Timestamp.Unix(),
1229
1283
  }}
1230
1284
  }
1285
+
1286
+ // GetPreferredJID returns one of the [type.JID] values for the given senders, preferring the first
1287
+ // non-empty, non-hidden sender; if none are found, mappings from LID to JID are tried, or otherwise,
1288
+ // the first JID given is returned.
1289
+ func getPreferredJID(ctx context.Context, client *whatsmeow.Client, def types.JID, alt ...types.JID) types.JID {
1290
+ var jids = append([]types.JID{def}, alt...)
1291
+ for _, s := range jids {
1292
+ if !s.IsEmpty() && s.Server != types.HiddenUserServer {
1293
+ return s
1294
+ }
1295
+ }
1296
+
1297
+ for _, s := range jids {
1298
+ if !s.IsEmpty() && s.Server == types.HiddenUserServer {
1299
+ if p, err := client.Store.LIDs.GetPNForLID(ctx, s); err == nil {
1300
+ return p
1301
+ }
1302
+ }
1303
+ }
1304
+
1305
+ return def
1306
+ }
@@ -3,9 +3,6 @@ package whatsapp
3
3
  import (
4
4
  // Standard library.
5
5
  "context"
6
- "fmt"
7
- "log/slog"
8
- "os"
9
6
  "runtime"
10
7
 
11
8
  // Internal packages.
@@ -40,6 +37,12 @@ func (d LinkedDevice) JID() types.JID {
40
37
  return jid
41
38
  }
42
39
 
40
+ // IsAnonymousJID returns true if the JID given is not addressible, that is, if it's actually a LID.
41
+ func IsAnonymousJID(id string) bool {
42
+ jid, _ := types.ParseJID(id)
43
+ return jid.Server == types.HiddenUserServer
44
+ }
45
+
43
46
  // A Gateway represents a persistent process for establishing individual sessions between linked
44
47
  // devices and WhatsApp.
45
48
  type Gateway struct {
@@ -63,13 +66,7 @@ func NewGateway() *Gateway {
63
66
  // Init performs initialization procedures for the Gateway, and is expected to be run before any
64
67
  // calls to [Gateway.Session].
65
68
  func (w *Gateway) Init() error {
66
- w.logger = logger{
67
- module: "Slidge",
68
- logger: slog.New(
69
- slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: logLevel(w.LogLevel)}),
70
- ),
71
- }
72
-
69
+ w.logger = walog.Stdout("slidge", w.LogLevel, false)
73
70
  container, err := sqlstore.New(context.Background(), "sqlite3", w.DBPath, w.logger)
74
71
  if err != nil {
75
72
  return err
@@ -130,56 +127,3 @@ func (w *Gateway) CleanupSession(device LinkedDevice) error {
130
127
 
131
128
  return nil
132
129
  }
133
-
134
- // A LogLevel represents a mapping between Python standard logging levels and Go standard logging
135
- // levels.
136
- type logLevel string
137
-
138
- var _ slog.Leveler = logLevel("")
139
-
140
- // Level returns the Go equivalent logging level for the Python logging level represented.
141
- func (l logLevel) Level() slog.Level {
142
- switch l {
143
- case "FATAL", "CRITICAL", "ERROR":
144
- return slog.LevelError
145
- case "WARN", "WARNING":
146
- return slog.LevelWarn
147
- case "DEBUG":
148
- return slog.LevelDebug
149
- default:
150
- return slog.LevelInfo
151
- }
152
- }
153
-
154
- // A Logger represents a mapping between a WhatsMeow logger and Go standard logging functions.
155
- type logger struct {
156
- module string
157
- logger *slog.Logger
158
- }
159
-
160
- var _ walog.Logger = logger{}
161
-
162
- // Errorf handles the given message as representing a (typically) fatal error.
163
- func (l logger) Errorf(msg string, args ...any) {
164
- l.logger.Error(fmt.Sprintf(msg, args...))
165
- }
166
-
167
- // Warn handles the given message as representing a non-fatal error or warning thereof.
168
- func (l logger) Warnf(msg string, args ...any) {
169
- l.logger.Warn(fmt.Sprintf(msg, args...))
170
- }
171
-
172
- // Infof handles the given message as representing an informational notice.
173
- func (l logger) Infof(msg string, args ...any) {
174
- l.logger.Info(fmt.Sprintf(msg, args...))
175
- }
176
-
177
- // Debugf handles the given message as representing an internal-only debug message.
178
- func (l logger) Debugf(msg string, args ...any) {
179
- l.logger.Debug(fmt.Sprintf(msg, args...))
180
- }
181
-
182
- // Sub is a no-op and will return the receiver itself.
183
- func (l logger) Sub(module string) walog.Logger {
184
- return logger{logger: l.logger.With(slog.String("module", l.module+"."+module))}
185
- }
@@ -2,7 +2,7 @@ from logging import getLevelName, getLogger
2
2
  from pathlib import Path
3
3
  from typing import TYPE_CHECKING
4
4
 
5
- from slidge import BaseGateway, FormField, GatewayUser, global_config
5
+ from slidge import BaseGateway, FormField, global_config
6
6
 
7
7
  from . import config
8
8
  from .generated import whatsapp
@@ -62,13 +62,12 @@ class Gateway(BaseGateway):
62
62
  """
63
63
  pass
64
64
 
65
- async def unregister(self, user: GatewayUser):
65
+ async def unregister(self, session: "Session"): # type:ignore[override]
66
66
  """
67
67
  Logout from the active WhatsApp session. This will also force a remote log-out, and thus
68
68
  require pairing on next login. For simply disconnecting the active session, look at the
69
69
  :meth:`.Session.disconnect` function.
70
70
  """
71
- session: "Session" = self.get_session_from_user(user) # type:ignore
72
71
  session.whatsapp.Logout()
73
72
  try:
74
73
  device_id = session.user.legacy_module_data["device_id"]