shellzapy 0.1.0__py3-none-any.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.
- shellzapy-0.1.0.dist-info/METADATA +112 -0
- shellzapy-0.1.0.dist-info/RECORD +345 -0
- shellzapy-0.1.0.dist-info/WHEEL +4 -0
- shellzapy-0.1.0.dist-info/licenses/LICENSE +21 -0
- shellzapy-0.1.0.dist-info/licenses/NOTICE +9 -0
- zapy/__init__.py +58 -0
- zapy/_appstate/__init__.py +59 -0
- zapy/_appstate/constants.py +82 -0
- zapy/_appstate/crypto/__init__.py +17 -0
- zapy/_appstate/crypto/app_state_crypto.py +401 -0
- zapy/_appstate/parsers/__init__.py +23 -0
- zapy/_appstate/parsers/encoding.py +157 -0
- zapy/_appstate/parsers/response_parser.py +135 -0
- zapy/_appstate/sync/__init__.py +11 -0
- zapy/_appstate/sync/sync_client.py +1559 -0
- zapy/_appstate/types.py +137 -0
- zapy/_appstate/utils.py +100 -0
- zapy/_auth/__init__.py +3 -0
- zapy/_auth/auth_client.py +618 -0
- zapy/_auth/credentials_flow.py +290 -0
- zapy/_auth/pairing/__init__.py +3 -0
- zapy/_auth/pairing/companion_host.py +239 -0
- zapy/_auth/pairing/flow.py +808 -0
- zapy/_auth/pairing/pairing_code_crypto.py +143 -0
- zapy/_auth/pairing/qr_flow.py +123 -0
- zapy/_auth/pairing/shortcake_crypto.py +122 -0
- zapy/_auth/pairing/shortcake_flow.py +393 -0
- zapy/_auth/types.py +110 -0
- zapy/_client/__init__.py +26 -0
- zapy/_client/client.py +972 -0
- zapy/_client/connection/__init__.py +6 -0
- zapy/_client/connection/manager.py +525 -0
- zapy/_client/connection/receipt_queue.py +74 -0
- zapy/_client/coordinators/__init__.py +81 -0
- zapy/_client/coordinators/ab_props.py +260 -0
- zapy/_client/coordinators/app_state_mutation.py +2538 -0
- zapy/_client/coordinators/bot.py +830 -0
- zapy/_client/coordinators/broadcast_list.py +101 -0
- zapy/_client/coordinators/business.py +247 -0
- zapy/_client/coordinators/email.py +158 -0
- zapy/_client/coordinators/group.py +1478 -0
- zapy/_client/coordinators/incoming_node.py +758 -0
- zapy/_client/coordinators/low_level.py +119 -0
- zapy/_client/coordinators/message.py +1153 -0
- zapy/_client/coordinators/message_dispatch.py +1637 -0
- zapy/_client/coordinators/newsletter.py +110 -0
- zapy/_client/coordinators/offline_resume.py +271 -0
- zapy/_client/coordinators/passive_tasks.py +447 -0
- zapy/_client/coordinators/presence.py +103 -0
- zapy/_client/coordinators/privacy.py +623 -0
- zapy/_client/coordinators/profile.py +1024 -0
- zapy/_client/coordinators/retry.py +1878 -0
- zapy/_client/coordinators/status.py +132 -0
- zapy/_client/coordinators/stream_control.py +260 -0
- zapy/_client/coordinators/trusted_contact_token.py +417 -0
- zapy/_client/events/__init__.py +266 -0
- zapy/_client/events/abprops.py +58 -0
- zapy/_client/events/appstate_mutation.py +248 -0
- zapy/_client/events/business.py +565 -0
- zapy/_client/events/call.py +144 -0
- zapy/_client/events/chatstate.py +41 -0
- zapy/_client/events/devices.py +122 -0
- zapy/_client/events/dirty.py +384 -0
- zapy/_client/events/group.py +655 -0
- zapy/_client/events/identity.py +40 -0
- zapy/_client/events/incoming.py +1079 -0
- zapy/_client/events/mex_notification.py +317 -0
- zapy/_client/events/offline.py +123 -0
- zapy/_client/events/picture.py +67 -0
- zapy/_client/events/presence.py +74 -0
- zapy/_client/events/privacy.py +187 -0
- zapy/_client/events/privacy_token.py +72 -0
- zapy/_client/events/receipt.py +109 -0
- zapy/_client/events/registration.py +70 -0
- zapy/_client/events/username.py +76 -0
- zapy/_client/factory.py +2020 -0
- zapy/_client/media.py +829 -0
- zapy/_client/newsletter/__init__.py +90 -0
- zapy/_client/newsletter/admin.py +323 -0
- zapy/_client/newsletter/content.py +499 -0
- zapy/_client/newsletter/discovery.py +233 -0
- zapy/_client/newsletter/messaging.py +396 -0
- zapy/_client/newsletter/mex.py +99 -0
- zapy/_client/newsletter/parse.py +406 -0
- zapy/_client/newsletter/types.py +393 -0
- zapy/_client/persistence/__init__.py +89 -0
- zapy/_client/persistence/companion_host.py +133 -0
- zapy/_client/persistence/ephemeral_setting.py +245 -0
- zapy/_client/persistence/group_history.py +361 -0
- zapy/_client/persistence/history_blob.py +169 -0
- zapy/_client/persistence/history_sync.py +646 -0
- zapy/_client/persistence/mailbox.py +232 -0
- zapy/_client/persistence/write_behind_persistence.py +368 -0
- zapy/_client/plugins/__init__.py +23 -0
- zapy/_client/plugins/define.py +44 -0
- zapy/_client/plugins/install.py +254 -0
- zapy/_client/plugins/types.py +64 -0
- zapy/_client/tokens/__init__.py +21 -0
- zapy/_client/tokens/cs_token.py +47 -0
- zapy/_client/tokens/tc_token.py +43 -0
- zapy/_client/types.py +988 -0
- zapy/_crypto/__init__.py +65 -0
- zapy/_crypto/core/__init__.py +62 -0
- zapy/_crypto/core/hkdf.py +41 -0
- zapy/_crypto/core/keys.py +51 -0
- zapy/_crypto/core/nonce.py +25 -0
- zapy/_crypto/core/primitives.py +179 -0
- zapy/_crypto/core/random.py +32 -0
- zapy/_crypto/core/xeddsa.py +72 -0
- zapy/_crypto/curves/__init__.py +3 -0
- zapy/_crypto/curves/constants.py +10 -0
- zapy/_crypto/curves/ed25519.py +61 -0
- zapy/_crypto/curves/types.py +18 -0
- zapy/_crypto/curves/x25519.py +117 -0
- zapy/_crypto/math/__init__.py +3 -0
- zapy/_crypto/math/constants.py +35 -0
- zapy/_crypto/math/edwards.py +174 -0
- zapy/_crypto/math/fe.py +120 -0
- zapy/_crypto/math/le.py +13 -0
- zapy/_crypto/math/mod.py +15 -0
- zapy/_crypto/math/prime.py +11 -0
- zapy/_crypto/math/types.py +25 -0
- zapy/_crypto/native_backend.py +40 -0
- zapy/_infra/__init__.py +3 -0
- zapy/_infra/log.py +142 -0
- zapy/_infra/perf.py +77 -0
- zapy/_media/__init__.py +64 -0
- zapy/_media/constants.py +133 -0
- zapy/_media/container.py +110 -0
- zapy/_media/crypto/__init__.py +19 -0
- zapy/_media/crypto/crypto.py +633 -0
- zapy/_media/crypto/media_retry.py +107 -0
- zapy/_media/processor.py +100 -0
- zapy/_media/sticker/__init__.py +8 -0
- zapy/_media/sticker/pack.py +188 -0
- zapy/_media/transfer/__init__.py +15 -0
- zapy/_media/transfer/client.py +635 -0
- zapy/_media/transfer/conn.py +48 -0
- zapy/_media/types.py +169 -0
- zapy/_message/__init__.py +121 -0
- zapy/_message/addons/__init__.py +5 -0
- zapy/_message/addons/link_preview/__init__.py +54 -0
- zapy/_message/addons/link_preview/builder.py +56 -0
- zapy/_message/addons/link_preview/detect.py +72 -0
- zapy/_message/addons/link_preview/fetcher.py +553 -0
- zapy/_message/addons/link_preview/types.py +100 -0
- zapy/_message/client.py +486 -0
- zapy/_message/context_info.py +424 -0
- zapy/_message/crypto/__init__.py +71 -0
- zapy/_message/crypto/addon_crypto.py +656 -0
- zapy/_message/crypto/icdc.py +138 -0
- zapy/_message/crypto/phash.py +87 -0
- zapy/_message/crypto/reporting_token.py +498 -0
- zapy/_message/crypto/use_case_secret.py +113 -0
- zapy/_message/encode/__init__.py +84 -0
- zapy/_message/encode/content.py +636 -0
- zapy/_message/encode/device_sent.py +88 -0
- zapy/_message/encode/media_payload.py +122 -0
- zapy/_message/encode/padding.py +27 -0
- zapy/_message/kinds/__init__.py +1 -0
- zapy/_message/kinds/bot.py +179 -0
- zapy/_message/kinds/group_history.py +206 -0
- zapy/_message/kinds/newsletter.py +388 -0
- zapy/_message/kinds/sticker_pack.py +74 -0
- zapy/_message/messaging/__init__.py +336 -0
- zapy/_message/messaging/companion_host.py +117 -0
- zapy/_message/messaging/fanout.py +311 -0
- zapy/_message/messaging/group_metadata.py +444 -0
- zapy/_message/messaging/ignore_key.py +264 -0
- zapy/_message/messaging/key_protocol.py +217 -0
- zapy/_message/messaging/link_preview.py +448 -0
- zapy/_message/messaging/messages.py +1429 -0
- zapy/_message/primitives/__init__.py +1 -0
- zapy/_message/primitives/ack.py +232 -0
- zapy/_message/primitives/incoming.py +1141 -0
- zapy/_message/primitives/media_retry.py +451 -0
- zapy/_message/primitives/peer_data_operation.py +271 -0
- zapy/_message/types.py +434 -0
- zapy/_proto/WAProto_pb2.py +2584 -0
- zapy/_proto/__init__.py +1 -0
- zapy/_protocol/__init__.py +3 -0
- zapy/_protocol/abprops_spec.py +6216 -0
- zapy/_protocol/auth.py +17 -0
- zapy/_protocol/browser.py +57 -0
- zapy/_protocol/defaults.py +38 -0
- zapy/_protocol/device_identity.py +54 -0
- zapy/_protocol/jid.py +241 -0
- zapy/_protocol/message.py +127 -0
- zapy/_protocol/nodes.py +144 -0
- zapy/_protocol/notification.py +18 -0
- zapy/_retry/__init__.py +77 -0
- zapy/_retry/codec.py +209 -0
- zapy/_retry/constants.py +28 -0
- zapy/_retry/parse.py +132 -0
- zapy/_retry/reason.py +65 -0
- zapy/_retry/replay.py +483 -0
- zapy/_retry/tracker.py +161 -0
- zapy/_retry/types.py +122 -0
- zapy/_signal/__init__.py +171 -0
- zapy/_signal/api/__init__.py +133 -0
- zapy/_signal/api/codec.py +164 -0
- zapy/_signal/api/constants.py +14 -0
- zapy/_signal/api/device_sync.py +915 -0
- zapy/_signal/api/digest_sync.py +363 -0
- zapy/_signal/api/identity_sync.py +250 -0
- zapy/_signal/api/missing_pre_keys_sync.py +267 -0
- zapy/_signal/api/prekeys.py +191 -0
- zapy/_signal/api/result_map.py +40 -0
- zapy/_signal/api/rotate_key.py +111 -0
- zapy/_signal/api/session_sync.py +297 -0
- zapy/_signal/attestation.py +145 -0
- zapy/_signal/constants.py +22 -0
- zapy/_signal/encoding.py +78 -0
- zapy/_signal/group/__init__.py +35 -0
- zapy/_signal/group/chain.py +139 -0
- zapy/_signal/group/codec.py +78 -0
- zapy/_signal/group/encoding.py +166 -0
- zapy/_signal/group/manager.py +361 -0
- zapy/_signal/registration/__init__.py +44 -0
- zapy/_signal/registration/keygen.py +46 -0
- zapy/_signal/registration/reg_encoding.py +66 -0
- zapy/_signal/registration/reg_utils.py +52 -0
- zapy/_signal/session/__init__.py +114 -0
- zapy/_signal/session/encoding.py +385 -0
- zapy/_signal/session/protocol.py +590 -0
- zapy/_signal/session/ratchet.py +381 -0
- zapy/_signal/session/resolver.py +630 -0
- zapy/_signal/session/serializer.py +96 -0
- zapy/_signal/session/session.py +272 -0
- zapy/_signal/types.py +214 -0
- zapy/_store/__init__.py +118 -0
- zapy/_store/cache/__init__.py +166 -0
- zapy/_store/cache/identity.py +130 -0
- zapy/_store/cache/privacy_token.py +116 -0
- zapy/_store/cache/sender_key.py +168 -0
- zapy/_store/cache/session.py +142 -0
- zapy/_store/contracts/__init__.py +84 -0
- zapy/_store/contracts/appstate.py +82 -0
- zapy/_store/contracts/auth.py +16 -0
- zapy/_store/contracts/chat_metadata.py +29 -0
- zapy/_store/contracts/contact.py +31 -0
- zapy/_store/contracts/device_list.py +35 -0
- zapy/_store/contracts/group_metadata.py +33 -0
- zapy/_store/contracts/identity.py +18 -0
- zapy/_store/contracts/message.py +36 -0
- zapy/_store/contracts/message_secret.py +41 -0
- zapy/_store/contracts/pre_key.py +32 -0
- zapy/_store/contracts/privacy_token.py +32 -0
- zapy/_store/contracts/retry.py +47 -0
- zapy/_store/contracts/sender_key.py +37 -0
- zapy/_store/contracts/session.py +21 -0
- zapy/_store/contracts/signal.py +23 -0
- zapy/_store/contracts/thread.py +35 -0
- zapy/_store/create_store.py +890 -0
- zapy/_store/locks.py +1154 -0
- zapy/_store/memory/__init__.py +40 -0
- zapy/_store/memory/appstate.py +200 -0
- zapy/_store/memory/auth.py +24 -0
- zapy/_store/memory/chat_metadata.py +124 -0
- zapy/_store/memory/contact.py +125 -0
- zapy/_store/memory/device_list.py +161 -0
- zapy/_store/memory/group_metadata.py +125 -0
- zapy/_store/memory/identity.py +86 -0
- zapy/_store/memory/message.py +85 -0
- zapy/_store/memory/message_secret.py +145 -0
- zapy/_store/memory/pre_key.py +112 -0
- zapy/_store/memory/privacy_token.py +103 -0
- zapy/_store/memory/retry.py +250 -0
- zapy/_store/memory/sender_key.py +162 -0
- zapy/_store/memory/session.py +111 -0
- zapy/_store/memory/signal.py +45 -0
- zapy/_store/memory/thread.py +66 -0
- zapy/_store/noop.py +279 -0
- zapy/_transport/__init__.py +3 -0
- zapy/_transport/binary/__init__.py +77 -0
- zapy/_transport/binary/constants.py +80 -0
- zapy/_transport/binary/decoder.py +260 -0
- zapy/_transport/binary/encoder.py +279 -0
- zapy/_transport/binary/tokens.py +1289 -0
- zapy/_transport/comms.py +759 -0
- zapy/_transport/keepalive/__init__.py +3 -0
- zapy/_transport/keepalive/keep_alive.py +252 -0
- zapy/_transport/node/__init__.py +3 -0
- zapy/_transport/node/builders/__init__.py +9 -0
- zapy/_transport/node/builders/abprops.py +33 -0
- zapy/_transport/node/builders/account_sync.py +120 -0
- zapy/_transport/node/builders/bot.py +56 -0
- zapy/_transport/node/builders/business.py +261 -0
- zapy/_transport/node/builders/chatstate.py +74 -0
- zapy/_transport/node/builders/community.py +116 -0
- zapy/_transport/node/builders/device.py +30 -0
- zapy/_transport/node/builders/email.py +181 -0
- zapy/_transport/node/builders/global_.py +74 -0
- zapy/_transport/node/builders/group.py +279 -0
- zapy/_transport/node/builders/media.py +21 -0
- zapy/_transport/node/builders/message.py +436 -0
- zapy/_transport/node/builders/mobile.py +227 -0
- zapy/_transport/node/builders/newsletter.py +293 -0
- zapy/_transport/node/builders/offline.py +20 -0
- zapy/_transport/node/builders/pairing.py +130 -0
- zapy/_transport/node/builders/passive.py +28 -0
- zapy/_transport/node/builders/prekeys.py +215 -0
- zapy/_transport/node/builders/presence.py +100 -0
- zapy/_transport/node/builders/privacy.py +243 -0
- zapy/_transport/node/builders/privacy_token.py +94 -0
- zapy/_transport/node/builders/profile.py +176 -0
- zapy/_transport/node/builders/retry.py +156 -0
- zapy/_transport/node/builders/shortcake.py +87 -0
- zapy/_transport/node/builders/tos.py +92 -0
- zapy/_transport/node/builders/usync.py +185 -0
- zapy/_transport/node/helpers.py +201 -0
- zapy/_transport/node/orchestrator.py +210 -0
- zapy/_transport/node/query.py +82 -0
- zapy/_transport/node/transport.py +105 -0
- zapy/_transport/node/usync.py +33 -0
- zapy/_transport/node/xml.py +38 -0
- zapy/_transport/noise/__init__.py +7 -0
- zapy/_transport/noise/cert.py +85 -0
- zapy/_transport/noise/client_payload.py +344 -0
- zapy/_transport/noise/constants.py +12 -0
- zapy/_transport/noise/frame_codec.py +120 -0
- zapy/_transport/noise/handshake.py +92 -0
- zapy/_transport/noise/session.py +493 -0
- zapy/_transport/noise/socket.py +45 -0
- zapy/_transport/noise/types.py +66 -0
- zapy/_transport/noise/version.json +3 -0
- zapy/_transport/proxy.py +35 -0
- zapy/_transport/types.py +19 -0
- zapy/_transport/wa_version_fetcher.py +159 -0
- zapy/_transport/web_socket.py +602 -0
- zapy/_util/__init__.py +3 -0
- zapy/_util/bytes.py +131 -0
- zapy/_util/coercion.py +29 -0
- zapy/_util/collections.py +45 -0
- zapy/_util/primitives.py +49 -0
- zapy/client.py +840 -0
- zapy/errors.py +148 -0
- zapy/events.py +564 -0
- zapy/jid.py +140 -0
- zapy/py.typed +0 -0
- zapy/stores/__init__.py +50 -0
- zapy/stores/base.py +1627 -0
- zapy/stores/json_file.py +359 -0
- zapy/stores/memory.py +322 -0
- zapy/stores/sqlite.py +343 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
"""Peer data operation requests.
|
|
2
|
+
|
|
3
|
+
Mirrors ``src/message/primitives/peer-data-operation.ts``.
|
|
4
|
+
|
|
5
|
+
Protocol messages are plain ``dict`` trees; the publish path
|
|
6
|
+
(``PublishProtocolMessageToDeviceFn`` from
|
|
7
|
+
``zapy._message.messaging.key_protocol``) takes dicts.
|
|
8
|
+
|
|
9
|
+
TEMPORARY (sibling layers not yet ported): :func:`_to_user_jid` is a verbatim
|
|
10
|
+
implementation of the used part of ``src/protocol/jid.ts``. It moves to
|
|
11
|
+
``zapy._protocol.jid`` once that lands.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import asyncio
|
|
17
|
+
from collections.abc import Awaitable, Callable
|
|
18
|
+
from dataclasses import dataclass
|
|
19
|
+
from typing import Any
|
|
20
|
+
|
|
21
|
+
from typing import Protocol
|
|
22
|
+
|
|
23
|
+
from zapy._auth.types import WaAuthCredentials
|
|
24
|
+
from zapy._infra.log import Logger
|
|
25
|
+
from zapy._message.encode.content import MessageDict
|
|
26
|
+
from zapy._proto import WAProto_pb2
|
|
27
|
+
from zapy._util.collections import set_bounded_map_entry
|
|
28
|
+
|
|
29
|
+
_DEFAULT_TIMEOUT_MS = 30_000
|
|
30
|
+
_DEFAULT_MAX_PENDING = 256
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _to_user_jid(jid: str) -> str:
|
|
34
|
+
at_index = jid.find("@")
|
|
35
|
+
if at_index < 1 or at_index >= len(jid) - 1:
|
|
36
|
+
raise ValueError(f"invalid jid: {jid}")
|
|
37
|
+
colon_index = jid.find(":")
|
|
38
|
+
if colon_index == -1 or colon_index > at_index:
|
|
39
|
+
return jid
|
|
40
|
+
if not jid[colon_index + 1 : at_index].isdigit():
|
|
41
|
+
raise ValueError(f"invalid jid device: {jid}")
|
|
42
|
+
return f"{jid[:colon_index]}@{jid[at_index + 1 :]}"
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _pdo_request_message_type() -> int:
|
|
46
|
+
return int(
|
|
47
|
+
WAProto_pb2.Message.ProtocolMessage.Type.Value(
|
|
48
|
+
"PEER_DATA_OPERATION_REQUEST_MESSAGE"
|
|
49
|
+
)
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _pdo_response_message_type() -> int:
|
|
54
|
+
return int(
|
|
55
|
+
WAProto_pb2.Message.ProtocolMessage.Type.Value(
|
|
56
|
+
"PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE"
|
|
57
|
+
)
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class PublishProtocolMessageResult(Protocol):
|
|
62
|
+
"""Structural publish receipt.
|
|
63
|
+
|
|
64
|
+
``WaMessagePublishResult`` travels with ``zapy._client``.
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
@property
|
|
68
|
+
def id(self) -> str: ...
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@dataclass(frozen=True, slots=True)
|
|
72
|
+
class PublishProtocolMessageOptions:
|
|
73
|
+
"""Mirrors the ``options`` param of ``PublishProtocolMessageToDeviceFn``."""
|
|
74
|
+
|
|
75
|
+
id: str | None = None
|
|
76
|
+
push_priority: str | None = None
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
PublishProtocolMessageToDeviceFn = Callable[
|
|
80
|
+
[str, MessageDict, PublishProtocolMessageOptions],
|
|
81
|
+
Awaitable[PublishProtocolMessageResult],
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@dataclass(frozen=True, slots=True)
|
|
86
|
+
class PeerDataOperationRequesterOptions:
|
|
87
|
+
logger: Logger
|
|
88
|
+
publish_protocol_message_to_device: PublishProtocolMessageToDeviceFn
|
|
89
|
+
get_current_credentials: Callable[[], WaAuthCredentials | None]
|
|
90
|
+
generate_outgoing_message_id: Callable[[], Awaitable[str]]
|
|
91
|
+
subscribe_to_protocol_message: Callable[[Callable[[Any], None]], Callable[[], None]]
|
|
92
|
+
default_timeout_ms: int | None = None
|
|
93
|
+
max_pending: int | None = None
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
@dataclass(frozen=True, slots=True)
|
|
97
|
+
class PeerDataOperationSendResult:
|
|
98
|
+
message_id: str = ""
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@dataclass
|
|
102
|
+
class _PendingPdo:
|
|
103
|
+
future: asyncio.Future[list[dict[str, Any]]]
|
|
104
|
+
timeout_handle: asyncio.TimerHandle
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def _build_request_protocol_message(
|
|
108
|
+
request_type: int, body: dict[str, Any]
|
|
109
|
+
) -> MessageDict:
|
|
110
|
+
message = dict(body)
|
|
111
|
+
message["peerDataOperationRequestType"] = request_type
|
|
112
|
+
return {
|
|
113
|
+
"type": _pdo_request_message_type(),
|
|
114
|
+
"peerDataOperationRequestMessage": message,
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class PeerDataOperationRequester:
|
|
119
|
+
"""Correlates peer data operation requests with their responses by stanza id."""
|
|
120
|
+
|
|
121
|
+
def __init__(self, options: PeerDataOperationRequesterOptions) -> None:
|
|
122
|
+
self._logger = options.logger
|
|
123
|
+
self._publish = options.publish_protocol_message_to_device
|
|
124
|
+
self._get_current_credentials = options.get_current_credentials
|
|
125
|
+
self._generate_outgoing_message_id = options.generate_outgoing_message_id
|
|
126
|
+
self._default_timeout_ms = (
|
|
127
|
+
options.default_timeout_ms
|
|
128
|
+
if options.default_timeout_ms is not None
|
|
129
|
+
else _DEFAULT_TIMEOUT_MS
|
|
130
|
+
)
|
|
131
|
+
self._max_pending = (
|
|
132
|
+
options.max_pending
|
|
133
|
+
if options.max_pending is not None
|
|
134
|
+
else _DEFAULT_MAX_PENDING
|
|
135
|
+
)
|
|
136
|
+
self._pending: dict[str, _PendingPdo] = {}
|
|
137
|
+
options.subscribe_to_protocol_message(self._on_protocol_message)
|
|
138
|
+
|
|
139
|
+
def _on_protocol_message(self, event: Any) -> None:
|
|
140
|
+
if isinstance(event, dict):
|
|
141
|
+
protocol_message = event.get("protocolMessage")
|
|
142
|
+
key = event.get("key")
|
|
143
|
+
else:
|
|
144
|
+
protocol_message = getattr(event, "protocol_message", None)
|
|
145
|
+
key = getattr(event, "key", None)
|
|
146
|
+
if not isinstance(protocol_message, dict):
|
|
147
|
+
return
|
|
148
|
+
if protocol_message.get("type") != _pdo_response_message_type():
|
|
149
|
+
return
|
|
150
|
+
response = protocol_message.get("peerDataOperationRequestResponseMessage")
|
|
151
|
+
if not isinstance(response, dict):
|
|
152
|
+
return
|
|
153
|
+
stanza_id = response.get("stanzaId")
|
|
154
|
+
results = response.get("peerDataOperationResult") or []
|
|
155
|
+
if not stanza_id:
|
|
156
|
+
self._logger.debug(
|
|
157
|
+
"pdo response without stanzaId",
|
|
158
|
+
{
|
|
159
|
+
"from": key.get("remoteJid") if isinstance(key, dict) else None,
|
|
160
|
+
"resultCount": len(results),
|
|
161
|
+
},
|
|
162
|
+
)
|
|
163
|
+
return
|
|
164
|
+
entry = self._pending.pop(stanza_id, None)
|
|
165
|
+
if entry is None:
|
|
166
|
+
self._logger.debug(
|
|
167
|
+
"pdo response for unknown stanzaId",
|
|
168
|
+
{"stanzaId": stanza_id, "resultCount": len(results)},
|
|
169
|
+
)
|
|
170
|
+
return
|
|
171
|
+
entry.timeout_handle.cancel()
|
|
172
|
+
if not entry.future.done():
|
|
173
|
+
entry.future.set_result(list(results))
|
|
174
|
+
|
|
175
|
+
async def request(
|
|
176
|
+
self,
|
|
177
|
+
request_type: int,
|
|
178
|
+
body: dict[str, Any],
|
|
179
|
+
timeout_ms: int | None = None,
|
|
180
|
+
) -> list[dict[str, Any]]:
|
|
181
|
+
"""Publish a request and resolve with the matching response results."""
|
|
182
|
+
message_id = await self._generate_outgoing_message_id()
|
|
183
|
+
limit_ms = timeout_ms if timeout_ms is not None else self._default_timeout_ms
|
|
184
|
+
loop = asyncio.get_running_loop()
|
|
185
|
+
future: asyncio.Future[list[dict[str, Any]]] = loop.create_future()
|
|
186
|
+
|
|
187
|
+
def on_timeout() -> None:
|
|
188
|
+
if self._pending.pop(message_id, None) is None:
|
|
189
|
+
return
|
|
190
|
+
self._logger.debug(
|
|
191
|
+
"pdo request timed out",
|
|
192
|
+
{"messageId": message_id, "timeoutMs": limit_ms, "type": request_type},
|
|
193
|
+
)
|
|
194
|
+
if not future.done():
|
|
195
|
+
future.set_exception(
|
|
196
|
+
ValueError(
|
|
197
|
+
"peer data operation timed out "
|
|
198
|
+
f"after {limit_ms}ms (id={message_id})"
|
|
199
|
+
)
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
handle = loop.call_later(limit_ms / 1000, on_timeout)
|
|
203
|
+
pending = _PendingPdo(future=future, timeout_handle=handle)
|
|
204
|
+
|
|
205
|
+
def on_evict(evicted_key: Any, evicted: _PendingPdo) -> None:
|
|
206
|
+
evicted.timeout_handle.cancel()
|
|
207
|
+
self._logger.warn(
|
|
208
|
+
"pdo pending entry evicted: capacity reached",
|
|
209
|
+
{"evictedId": evicted_key, "maxPending": self._max_pending},
|
|
210
|
+
)
|
|
211
|
+
if not evicted.future.done():
|
|
212
|
+
evicted.future.set_exception(
|
|
213
|
+
ValueError(
|
|
214
|
+
"peer data operation evicted "
|
|
215
|
+
f"from pending map (id={evicted_key})"
|
|
216
|
+
)
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
set_bounded_map_entry(
|
|
220
|
+
self._pending, message_id, pending, self._max_pending, on_evict
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
async def do_publish() -> None:
|
|
224
|
+
try:
|
|
225
|
+
await self._publish_request(request_type, body, message_id)
|
|
226
|
+
except Exception as error:
|
|
227
|
+
handle.cancel()
|
|
228
|
+
if (
|
|
229
|
+
self._pending.pop(message_id, None) is not None
|
|
230
|
+
and not future.done()
|
|
231
|
+
):
|
|
232
|
+
future.set_exception(
|
|
233
|
+
error
|
|
234
|
+
if isinstance(error, Exception)
|
|
235
|
+
else ValueError(str(error))
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
loop.create_task(do_publish())
|
|
239
|
+
try:
|
|
240
|
+
return await future
|
|
241
|
+
finally:
|
|
242
|
+
handle.cancel()
|
|
243
|
+
|
|
244
|
+
async def send(
|
|
245
|
+
self, request_type: int, body: dict[str, Any]
|
|
246
|
+
) -> PeerDataOperationSendResult:
|
|
247
|
+
"""Publish a request without waiting for its response."""
|
|
248
|
+
message_id = await self._generate_outgoing_message_id()
|
|
249
|
+
published_id = await self._publish_request(request_type, body, message_id)
|
|
250
|
+
return PeerDataOperationSendResult(message_id=published_id)
|
|
251
|
+
|
|
252
|
+
async def _publish_request(
|
|
253
|
+
self, request_type: int, body: dict[str, Any], message_id: str
|
|
254
|
+
) -> str:
|
|
255
|
+
credentials = self._get_current_credentials()
|
|
256
|
+
me_jid = credentials.me_jid if credentials is not None else None
|
|
257
|
+
if not me_jid:
|
|
258
|
+
raise ValueError("peer data operation requires current me jid")
|
|
259
|
+
result = await self._publish(
|
|
260
|
+
_to_user_jid(me_jid),
|
|
261
|
+
_build_request_protocol_message(request_type, body),
|
|
262
|
+
PublishProtocolMessageOptions(id=message_id, push_priority="high_force"),
|
|
263
|
+
)
|
|
264
|
+
return result.id
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
def create_peer_data_operation_requester(
|
|
268
|
+
options: PeerDataOperationRequesterOptions,
|
|
269
|
+
) -> PeerDataOperationRequester:
|
|
270
|
+
"""Create a peer data operation requester."""
|
|
271
|
+
return PeerDataOperationRequester(options)
|
zapy/_message/types.py
ADDED
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
"""Send-side message shapes (mirrors ``src/message/types.ts``).
|
|
2
|
+
|
|
3
|
+
``UserMediaFields<T>`` (the per-media proto fields the builder does not fill)
|
|
4
|
+
is represented as ``proto_fields``: an optional mapping merged over the
|
|
5
|
+
builder output. ``WaOutboundReceiptType`` values are verbatim from
|
|
6
|
+
``src/protocol/message.ts`` (``zapy._protocol.message``, landing with the
|
|
7
|
+
message layer).
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from dataclasses import dataclass
|
|
13
|
+
from typing import Any, BinaryIO, Literal, Mapping
|
|
14
|
+
|
|
15
|
+
from zapy._message.context_info import WaSendContextInfo
|
|
16
|
+
from zapy._message.encode.content import MessageDict
|
|
17
|
+
from zapy._transport.types import BinaryNode
|
|
18
|
+
|
|
19
|
+
WaOutboundReceiptType = Literal[
|
|
20
|
+
"read", "read-self", "played", "played-self", "inactive", "hist_sync"
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
MediaInput = bytes | bytearray | BinaryIO | str
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass(frozen=True, slots=True)
|
|
27
|
+
class WaMessagePublishOptions:
|
|
28
|
+
"""Retry policy for publishing one encrypted message."""
|
|
29
|
+
|
|
30
|
+
ack_timeout_ms: int | None = None
|
|
31
|
+
max_attempts: int | None = None
|
|
32
|
+
retry_delay_ms: int | None = None
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@dataclass(frozen=True, slots=True)
|
|
36
|
+
class WaMessageAckMetadata:
|
|
37
|
+
"""Parsed fields of an inbound ``ack`` for a published message."""
|
|
38
|
+
|
|
39
|
+
t: str | None = None
|
|
40
|
+
sync: str | None = None
|
|
41
|
+
phash: str | None = None
|
|
42
|
+
refresh_lid: bool = False
|
|
43
|
+
addressing_mode: Literal["pn", "lid"] | None = None
|
|
44
|
+
count: int | None = None
|
|
45
|
+
error: int | None = None
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@dataclass(frozen=True, slots=True)
|
|
49
|
+
class WaMessageUploadInfo:
|
|
50
|
+
"""Media upload result attached to a publish."""
|
|
51
|
+
|
|
52
|
+
url: str = ""
|
|
53
|
+
direct_path: str = ""
|
|
54
|
+
file_sha256: bytes = b""
|
|
55
|
+
file_length: int = 0
|
|
56
|
+
metadata_url: str | None = None
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@dataclass(frozen=True, slots=True)
|
|
60
|
+
class WaMessagePublishResult:
|
|
61
|
+
"""Outcome of publishing one message."""
|
|
62
|
+
|
|
63
|
+
id: str = ""
|
|
64
|
+
attempts: int = 0
|
|
65
|
+
ack_node: BinaryNode | None = None
|
|
66
|
+
ack: WaMessageAckMetadata | None = None
|
|
67
|
+
upload: WaMessageUploadInfo | None = None
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@dataclass(frozen=True, slots=True)
|
|
71
|
+
class WaMessageBuildResult:
|
|
72
|
+
"""Built message proto plus optional upload info."""
|
|
73
|
+
|
|
74
|
+
message: MessageDict | None = None
|
|
75
|
+
upload: WaMessageUploadInfo | None = None
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
@dataclass(frozen=True, slots=True)
|
|
79
|
+
class WaMessageKey:
|
|
80
|
+
"""Proto ``MessageKey`` shape used to target an existing message."""
|
|
81
|
+
|
|
82
|
+
remote_jid: str = ""
|
|
83
|
+
id: str = ""
|
|
84
|
+
from_me: bool = False
|
|
85
|
+
participant: str | None = None
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
@dataclass(frozen=True, slots=True)
|
|
89
|
+
class WaMessageRef:
|
|
90
|
+
"""A received ``message`` event passed verbatim as a target."""
|
|
91
|
+
|
|
92
|
+
raw_node: Any = None
|
|
93
|
+
key: WaMessageKey | None = None
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
WaMessageTargetInput = WaMessageKey | WaMessageRef
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
@dataclass(frozen=True, slots=True)
|
|
100
|
+
class WaSendTextMessage:
|
|
101
|
+
type: Literal["text"] = "text"
|
|
102
|
+
text: str = ""
|
|
103
|
+
context_info: WaSendContextInfo | None = None
|
|
104
|
+
link_preview: bool | Mapping[str, Any] | None = None
|
|
105
|
+
message_context_info: MessageDict | None = None
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@dataclass(frozen=True, slots=True)
|
|
109
|
+
class WaSendReactionMessage:
|
|
110
|
+
type: Literal["reaction"] = "reaction"
|
|
111
|
+
emoji: str = ""
|
|
112
|
+
target: WaMessageTargetInput | None = None
|
|
113
|
+
sender_timestamp_ms: int | None = None
|
|
114
|
+
message_context_info: MessageDict | None = None
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
@dataclass(frozen=True, slots=True)
|
|
118
|
+
class WaSendRevokeMessage:
|
|
119
|
+
type: Literal["revoke"] = "revoke"
|
|
120
|
+
target: WaMessageTargetInput | None = None
|
|
121
|
+
message_context_info: MessageDict | None = None
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
@dataclass(frozen=True, slots=True)
|
|
125
|
+
class WaSendPinMessage:
|
|
126
|
+
type: Literal["pin", "unpin"] = "pin"
|
|
127
|
+
target: WaMessageTargetInput | None = None
|
|
128
|
+
sender_timestamp_ms: int | None = None
|
|
129
|
+
duration_secs: int | None = None
|
|
130
|
+
message_context_info: MessageDict | None = None
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
@dataclass(frozen=True, slots=True)
|
|
134
|
+
class WaSendEditKey:
|
|
135
|
+
"""Id of the message being edited (``from_me`` forced true by the builder)."""
|
|
136
|
+
|
|
137
|
+
id: str = ""
|
|
138
|
+
participant: str | None = None
|
|
139
|
+
timestamp_ms: int | None = None
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
@dataclass(frozen=True, slots=True)
|
|
143
|
+
class WaSendKeepMessage:
|
|
144
|
+
type: Literal["keep", "unkeep"] = "keep"
|
|
145
|
+
target: WaMessageTargetInput | None = None
|
|
146
|
+
timestamp_ms: int | None = None
|
|
147
|
+
message_context_info: MessageDict | None = None
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
@dataclass(frozen=True, slots=True)
|
|
151
|
+
class WaSendPollOptionInput:
|
|
152
|
+
name: str = ""
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
@dataclass(frozen=True, slots=True)
|
|
156
|
+
class WaSendPollMessage:
|
|
157
|
+
type: Literal["poll"] = "poll"
|
|
158
|
+
name: str = ""
|
|
159
|
+
options: tuple[str | WaSendPollOptionInput, ...] = ()
|
|
160
|
+
selectable_count: int | None = None
|
|
161
|
+
allow_add_option: bool | None = None
|
|
162
|
+
hide_participant_name: bool | None = None
|
|
163
|
+
context_info: WaSendContextInfo | None = None
|
|
164
|
+
message_context_info: MessageDict | None = None
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
@dataclass(frozen=True, slots=True)
|
|
168
|
+
class WaSendPollParent:
|
|
169
|
+
"""Identity of the original poll a vote attaches to."""
|
|
170
|
+
|
|
171
|
+
id: str = ""
|
|
172
|
+
from_me: bool = False
|
|
173
|
+
participant: str | None = None
|
|
174
|
+
author_jid: str = ""
|
|
175
|
+
message_secret: bytes = b""
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
@dataclass(frozen=True, slots=True)
|
|
179
|
+
class WaSendPollVoteMessage:
|
|
180
|
+
type: Literal["poll-vote"] = "poll-vote"
|
|
181
|
+
poll: WaSendPollParent | None = None
|
|
182
|
+
selected_option_names: tuple[str, ...] = ()
|
|
183
|
+
sender_timestamp_ms: int | None = None
|
|
184
|
+
message_context_info: MessageDict | None = None
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
@dataclass(frozen=True, slots=True)
|
|
188
|
+
class WaSendEventLocation:
|
|
189
|
+
latitude: float = 0.0
|
|
190
|
+
longitude: float = 0.0
|
|
191
|
+
name: str | None = None
|
|
192
|
+
address: str | None = None
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
@dataclass(frozen=True, slots=True)
|
|
196
|
+
class WaSendEventMessage:
|
|
197
|
+
type: Literal["event"] = "event"
|
|
198
|
+
name: str = ""
|
|
199
|
+
description: str | None = None
|
|
200
|
+
start_time: int = 0
|
|
201
|
+
end_time: int | None = None
|
|
202
|
+
location: WaSendEventLocation | None = None
|
|
203
|
+
join_link: str | None = None
|
|
204
|
+
extra_guests_allowed: bool | None = None
|
|
205
|
+
is_schedule_call: bool | None = None
|
|
206
|
+
is_canceled: bool | None = None
|
|
207
|
+
has_reminder: bool | None = None
|
|
208
|
+
reminder_offset_sec: int | None = None
|
|
209
|
+
context_info: WaSendContextInfo | None = None
|
|
210
|
+
message_context_info: MessageDict | None = None
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
WaSendEventResponseType = Literal["going", "not_going", "maybe"]
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
@dataclass(frozen=True, slots=True)
|
|
217
|
+
class WaSendEventParent:
|
|
218
|
+
id: str = ""
|
|
219
|
+
from_me: bool = False
|
|
220
|
+
participant: str | None = None
|
|
221
|
+
author_jid: str = ""
|
|
222
|
+
message_secret: bytes = b""
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
@dataclass(frozen=True, slots=True)
|
|
226
|
+
class WaSendEventResponseMessage:
|
|
227
|
+
type: Literal["event-response"] = "event-response"
|
|
228
|
+
event: WaSendEventParent | None = None
|
|
229
|
+
response: WaSendEventResponseType = "going"
|
|
230
|
+
extra_guest_count: int | None = None
|
|
231
|
+
timestamp_ms: int | None = None
|
|
232
|
+
message_context_info: MessageDict | None = None
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
@dataclass(frozen=True, slots=True)
|
|
236
|
+
class WaSendMediaBase:
|
|
237
|
+
media: MediaInput = b""
|
|
238
|
+
mimetype: str | None = None
|
|
239
|
+
file_length: int | None = None
|
|
240
|
+
context_info: WaSendContextInfo | None = None
|
|
241
|
+
message_context_info: MessageDict | None = None
|
|
242
|
+
proto_fields: Mapping[str, Any] | None = None
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
@dataclass(frozen=True, slots=True)
|
|
246
|
+
class WaSendImageMessage(WaSendMediaBase):
|
|
247
|
+
type: Literal["image"] = "image"
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
@dataclass(frozen=True, slots=True)
|
|
251
|
+
class WaSendVideoMessage(WaSendMediaBase):
|
|
252
|
+
type: Literal["video"] = "video"
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
@dataclass(frozen=True, slots=True)
|
|
256
|
+
class WaSendPtvMessage(WaSendMediaBase):
|
|
257
|
+
type: Literal["ptv"] = "ptv"
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
@dataclass(frozen=True, slots=True)
|
|
261
|
+
class WaSendAudioMessage(WaSendMediaBase):
|
|
262
|
+
type: Literal["audio"] = "audio"
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
@dataclass(frozen=True, slots=True)
|
|
266
|
+
class WaSendDocumentMessage(WaSendMediaBase):
|
|
267
|
+
type: Literal["document"] = "document"
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
@dataclass(frozen=True, slots=True)
|
|
271
|
+
class WaSendStickerMessage(WaSendMediaBase):
|
|
272
|
+
type: Literal["sticker"] = "sticker"
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
@dataclass(frozen=True, slots=True)
|
|
276
|
+
class WaSendStickerPackStickerInput:
|
|
277
|
+
media: bytes | str = b""
|
|
278
|
+
file_name: str = ""
|
|
279
|
+
emojis: tuple[str, ...] = ()
|
|
280
|
+
is_animated: bool | None = None
|
|
281
|
+
is_lottie: bool | None = None
|
|
282
|
+
mimetype: str | None = None
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
@dataclass(frozen=True, slots=True)
|
|
286
|
+
class WaSendStickerPackTrayIcon:
|
|
287
|
+
media: bytes | str = b""
|
|
288
|
+
file_name: str = ""
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
@dataclass(frozen=True, slots=True)
|
|
292
|
+
class WaSendStickerPackMessage:
|
|
293
|
+
type: Literal["sticker-pack"] = "sticker-pack"
|
|
294
|
+
sticker_pack_id: str = ""
|
|
295
|
+
name: str = ""
|
|
296
|
+
publisher: str = ""
|
|
297
|
+
stickers: tuple[WaSendStickerPackStickerInput, ...] = ()
|
|
298
|
+
tray_icon: WaSendStickerPackTrayIcon | None = None
|
|
299
|
+
cover_thumbnail: bytes | str | None = None
|
|
300
|
+
context_info: WaSendContextInfo | None = None
|
|
301
|
+
message_context_info: MessageDict | None = None
|
|
302
|
+
proto_fields: Mapping[str, Any] | None = None
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
WaSendMediaMessage = (
|
|
306
|
+
WaSendImageMessage
|
|
307
|
+
| WaSendVideoMessage
|
|
308
|
+
| WaSendPtvMessage
|
|
309
|
+
| WaSendAudioMessage
|
|
310
|
+
| WaSendDocumentMessage
|
|
311
|
+
| WaSendStickerMessage
|
|
312
|
+
| WaSendStickerPackMessage
|
|
313
|
+
)
|
|
314
|
+
|
|
315
|
+
WaSendTypedMessage = (
|
|
316
|
+
WaSendTextMessage
|
|
317
|
+
| WaSendReactionMessage
|
|
318
|
+
| WaSendRevokeMessage
|
|
319
|
+
| WaSendPinMessage
|
|
320
|
+
| WaSendKeepMessage
|
|
321
|
+
| WaSendPollMessage
|
|
322
|
+
| WaSendPollVoteMessage
|
|
323
|
+
| WaSendEventMessage
|
|
324
|
+
| WaSendEventResponseMessage
|
|
325
|
+
| WaSendMediaMessage
|
|
326
|
+
)
|
|
327
|
+
|
|
328
|
+
WaSendMessageContent = str | WaSendTypedMessage | MessageDict
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
@dataclass(frozen=True, slots=True)
|
|
332
|
+
class WaEncryptedMessageInput:
|
|
333
|
+
"""One encrypted payload plus its stanza addressing."""
|
|
334
|
+
|
|
335
|
+
to: str = ""
|
|
336
|
+
enc_type: Literal["msg", "pkmsg", "skmsg"] = "msg"
|
|
337
|
+
ciphertext: bytes = b""
|
|
338
|
+
device_identity: bytes | None = None
|
|
339
|
+
addressing_mode: Literal["pn", "lid"] | None = None
|
|
340
|
+
enc_count: int | None = None
|
|
341
|
+
id: str | None = None
|
|
342
|
+
type: str | None = None
|
|
343
|
+
edit: str | None = None
|
|
344
|
+
mediatype: str | None = None
|
|
345
|
+
category: str | None = None
|
|
346
|
+
push_priority: str | None = None
|
|
347
|
+
participant: str | None = None
|
|
348
|
+
device_fanout: str | None = None
|
|
349
|
+
meta_node: BinaryNode | None = None
|
|
350
|
+
privacy_token_node: BinaryNode | None = None
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
@dataclass(frozen=True, slots=True)
|
|
354
|
+
class WaSendReceiptInput:
|
|
355
|
+
to: str = ""
|
|
356
|
+
id: str = ""
|
|
357
|
+
type: WaOutboundReceiptType | None = None
|
|
358
|
+
participant: str | None = None
|
|
359
|
+
recipient: str | None = None
|
|
360
|
+
category: str | None = None
|
|
361
|
+
from_: str | None = None
|
|
362
|
+
t: str | None = None
|
|
363
|
+
peer_participant_pn: str | None = None
|
|
364
|
+
list_ids: tuple[str, ...] | None = None
|
|
365
|
+
content: tuple[BinaryNode, ...] | None = None
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
@dataclass(frozen=True, slots=True)
|
|
369
|
+
class WaSendReceiptOptions:
|
|
370
|
+
type: WaOutboundReceiptType | None = None
|
|
371
|
+
participant: str | None = None
|
|
372
|
+
recipient: str | None = None
|
|
373
|
+
category: str | None = None
|
|
374
|
+
from_: str | None = None
|
|
375
|
+
t: str | None = None
|
|
376
|
+
peer_participant_pn: str | None = None
|
|
377
|
+
content: tuple[BinaryNode, ...] | None = None
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
@dataclass(frozen=True, slots=True)
|
|
381
|
+
class WaSendReceiptEventOptions:
|
|
382
|
+
type: WaOutboundReceiptType | None = None
|
|
383
|
+
recipient: str | None = None
|
|
384
|
+
category: str | None = None
|
|
385
|
+
from_: str | None = None
|
|
386
|
+
t: str | None = None
|
|
387
|
+
peer_participant_pn: str | None = None
|
|
388
|
+
content: tuple[BinaryNode, ...] | None = None
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
__all__ = [
|
|
392
|
+
"MediaInput",
|
|
393
|
+
"WaEncryptedMessageInput",
|
|
394
|
+
"WaMessageAckMetadata",
|
|
395
|
+
"WaMessageBuildResult",
|
|
396
|
+
"WaMessageKey",
|
|
397
|
+
"WaMessagePublishOptions",
|
|
398
|
+
"WaMessagePublishResult",
|
|
399
|
+
"WaMessageRef",
|
|
400
|
+
"WaMessageTargetInput",
|
|
401
|
+
"WaMessageUploadInfo",
|
|
402
|
+
"WaOutboundReceiptType",
|
|
403
|
+
"WaSendAudioMessage",
|
|
404
|
+
"WaSendDocumentMessage",
|
|
405
|
+
"WaSendEditKey",
|
|
406
|
+
"WaSendEventLocation",
|
|
407
|
+
"WaSendEventMessage",
|
|
408
|
+
"WaSendEventParent",
|
|
409
|
+
"WaSendEventResponseMessage",
|
|
410
|
+
"WaSendEventResponseType",
|
|
411
|
+
"WaSendImageMessage",
|
|
412
|
+
"WaSendKeepMessage",
|
|
413
|
+
"WaSendMediaBase",
|
|
414
|
+
"WaSendMediaMessage",
|
|
415
|
+
"WaSendMessageContent",
|
|
416
|
+
"WaSendPinMessage",
|
|
417
|
+
"WaSendPollMessage",
|
|
418
|
+
"WaSendPollOptionInput",
|
|
419
|
+
"WaSendPollParent",
|
|
420
|
+
"WaSendPollVoteMessage",
|
|
421
|
+
"WaSendPtvMessage",
|
|
422
|
+
"WaSendReactionMessage",
|
|
423
|
+
"WaSendReceiptEventOptions",
|
|
424
|
+
"WaSendReceiptInput",
|
|
425
|
+
"WaSendReceiptOptions",
|
|
426
|
+
"WaSendRevokeMessage",
|
|
427
|
+
"WaSendStickerMessage",
|
|
428
|
+
"WaSendStickerPackMessage",
|
|
429
|
+
"WaSendStickerPackStickerInput",
|
|
430
|
+
"WaSendStickerPackTrayIcon",
|
|
431
|
+
"WaSendTextMessage",
|
|
432
|
+
"WaSendTypedMessage",
|
|
433
|
+
"WaSendVideoMessage",
|
|
434
|
+
]
|