Compare commits
82 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 38fb9bcf81 | |||
| 703b5da554 | |||
| 8c61ce5f8e | |||
| 000932accd | |||
| 8df39c320e | |||
| 22e758b1e6 | |||
| f473484852 | |||
| 4dde4c5500 | |||
| e3cf104b59 | |||
| aa0a3c2b71 | |||
| bdbad50074 | |||
| 45b322abac | |||
| 3c3cf32027 | |||
| 99d85498fb | |||
| d6414f203b | |||
| b98df92d8c | |||
| 00a8113d47 | |||
| 670ac582f9 | |||
| 08910c61e1 | |||
| cb5e42c46e | |||
| 30e986ee67 | |||
| 60302d73d5 | |||
| 3baa494fad | |||
| 59cad85544 | |||
| ad53bc0982 | |||
| fb8f51be52 | |||
| 9a7d43d4ba | |||
| 578efe945f | |||
| e999fc1aa1 | |||
| 9fd88b533d | |||
| 43f3525437 | |||
| fdcbd3fc1d | |||
| cdc89316f0 | |||
| 3050c329c5 | |||
| 3ef7474842 | |||
| 9dfd31d109 | |||
| e686c5a2e1 | |||
| 466c14ff82 | |||
| 03bc03b318 | |||
| d83971d15e | |||
| 14f0321d7c | |||
| b65a8a334b | |||
| 28e9e5b912 | |||
| 962e7de0bf | |||
| c6cb29fd80 | |||
| a283d858c6 | |||
| 9c626801b0 | |||
| 4ca1878705 | |||
| 452df5d409 | |||
| e633d62a3b | |||
| 2a321b881e | |||
| 802d5f6efa | |||
| e0038bde36 | |||
| 1cbf1b18b7 | |||
| c3a021fcde | |||
| e6ea7e4563 | |||
| 3ab578aadf | |||
| d2db4cec97 | |||
| be44c5fdb0 | |||
| f63f0a766f | |||
| fbefa6a0ad | |||
| 9c4cdc3e02 | |||
| ba1c1b0fdb | |||
| 876af2e96c | |||
| 5bb18da6bf | |||
| 52d8ddae32 | |||
| 8c8c5a312e | |||
| 52756fb50d | |||
| bd8465d9b8 | |||
| 6c52b01ea7 | |||
| 5926da9493 | |||
| a9e926b907 | |||
| 2b2c3f9155 | |||
| 71fe69fd21 | |||
| eecf6df2a2 | |||
| d077902695 | |||
| c4e5d1262a | |||
| 6afde71691 | |||
| 6060293793 | |||
| afce764ce9 | |||
| ad5ea817f7 | |||
| 3841abca35 |
+71
-3
@@ -1,7 +1,7 @@
|
||||
syntax = "proto3";
|
||||
package proto;
|
||||
|
||||
/// WhatsApp Version: 2.3000.1035370989
|
||||
/// WhatsApp Version: 2.3000.1037082622
|
||||
|
||||
message ADVDeviceIdentity {
|
||||
optional uint32 rawId = 1;
|
||||
@@ -417,9 +417,16 @@ message BotCapabilityMetadata {
|
||||
JSON_PATCH_STREAMING = 58;
|
||||
AI_TAB_FORCE_CLIPPY = 59;
|
||||
UNIFIED_RESPONSE_EMBEDDED_SCREENS = 60;
|
||||
AI_SUBSCRIPTION_ENABLED = 61;
|
||||
}
|
||||
}
|
||||
|
||||
message BotCommandMetadata {
|
||||
optional string commandName = 1;
|
||||
optional string commandDescription = 2;
|
||||
optional string commandPrompt = 3;
|
||||
}
|
||||
|
||||
message BotDocumentMessageMetadata {
|
||||
optional DocumentPluginType pluginType = 1;
|
||||
enum DocumentPluginType {
|
||||
@@ -651,6 +658,7 @@ message BotMetadata {
|
||||
optional BotRenderingConfigMetadata botRenderingConfigMetadata = 36;
|
||||
optional BotInfrastructureDiagnostics botInfrastructureDiagnostics = 37;
|
||||
optional AIMediaCollectionMetadata aiMediaCollectionMetadata = 38;
|
||||
optional BotCommandMetadata commandMetadata = 39;
|
||||
optional bytes internalMetadata = 999;
|
||||
}
|
||||
|
||||
@@ -702,6 +710,7 @@ enum BotMetricsEntryPoint {
|
||||
WEB_NAVIGATION_BAR = 47;
|
||||
GROUP_MEMBER = 54;
|
||||
CHATLIST_SEARCH = 55;
|
||||
NEW_CHAT_LIST = 56;
|
||||
}
|
||||
message BotMetricsMetadata {
|
||||
optional string destinationId = 1;
|
||||
@@ -1466,6 +1475,10 @@ message ContextInfo {
|
||||
optional string wtwaWebsiteUrl = 26;
|
||||
optional string adPreviewUrl = 27;
|
||||
optional bool containsCtwaFlowsAutoReply = 28;
|
||||
optional int32 agmThumbnailStrategy = 29;
|
||||
optional int32 agmTitleStrategy = 30;
|
||||
optional int32 agmSubtitleStrategy = 31;
|
||||
optional int32 agmHeaderInteractionStrategy = 32;
|
||||
enum AdType {
|
||||
CTWA = 0;
|
||||
CAWC = 1;
|
||||
@@ -1651,6 +1664,7 @@ message DeviceCapabilities {
|
||||
optional bool companionSupportEnabled = 2;
|
||||
optional bool campaignSyncEnabled = 3;
|
||||
optional bool insightsSyncEnabled = 4;
|
||||
optional int32 recipientLimit = 5;
|
||||
}
|
||||
|
||||
enum ChatLockSupportLevel {
|
||||
@@ -1726,6 +1740,8 @@ message DeviceProps {
|
||||
optional uint32 initialSyncMaxMessagesPerChat = 20;
|
||||
optional bool supportManusHistory = 21;
|
||||
optional bool supportHatchHistory = 22;
|
||||
repeated string supportedBotChannelFbids = 23;
|
||||
optional bool supportInlineContacts = 24;
|
||||
}
|
||||
|
||||
enum PlatformType {
|
||||
@@ -1912,6 +1928,16 @@ message GroupParticipant {
|
||||
}
|
||||
}
|
||||
|
||||
message GroupRootKeyShare {
|
||||
repeated GroupRootKeyShareEntry keys = 1;
|
||||
}
|
||||
|
||||
message GroupRootKeyShareEntry {
|
||||
optional bytes groupRootKey = 1;
|
||||
optional string keyId = 2;
|
||||
optional int64 expiryTimestampMs = 3;
|
||||
}
|
||||
|
||||
message HandshakeMessage {
|
||||
optional ClientHello clientHello = 2;
|
||||
optional ServerHello serverHello = 3;
|
||||
@@ -1934,6 +1960,7 @@ message HandshakeMessage {
|
||||
optional bool sendServerHelloPaddedBytes = 7;
|
||||
optional bool simulateXxkemFs = 8;
|
||||
optional HandshakeMessage.HandshakePqMode pqMode = 9;
|
||||
optional bytes extendedEphemeral = 10;
|
||||
}
|
||||
|
||||
enum HandshakePqMode {
|
||||
@@ -1953,6 +1980,7 @@ message HandshakeMessage {
|
||||
optional bytes payload = 3;
|
||||
optional bytes extendedStatic = 4;
|
||||
optional bytes paddingBytes = 5;
|
||||
optional bytes extendedCiphertext = 6;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1976,6 +2004,8 @@ message HistorySync {
|
||||
optional bytes shareableChatIdentifierEncryptionKey = 17;
|
||||
repeated Account accounts = 18;
|
||||
optional bytes nctSalt = 19;
|
||||
repeated InlineContact inlineContacts = 20;
|
||||
optional bool inlineContactsProvided = 21;
|
||||
enum BotAIWaitListState {
|
||||
IN_WAITLIST = 0;
|
||||
AI_AVAILABLE = 1;
|
||||
@@ -2070,6 +2100,14 @@ message InThreadSurveyMetadata {
|
||||
|
||||
}
|
||||
|
||||
message InlineContact {
|
||||
optional string pnJid = 1;
|
||||
optional string lidJid = 2;
|
||||
optional string fullName = 3;
|
||||
optional string firstName = 4;
|
||||
optional string username = 5;
|
||||
}
|
||||
|
||||
message InteractiveAnnotation {
|
||||
repeated Point polygonVertices = 1;
|
||||
optional bool shouldSkipConfirmation = 4;
|
||||
@@ -2148,7 +2186,6 @@ message LimitSharing {
|
||||
CHAT_SETTING = 1;
|
||||
BIZ_SUPPORTS_FB_HOSTING = 2;
|
||||
UNKNOWN_GROUP = 3;
|
||||
DEPRECATION = 4;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2310,6 +2347,7 @@ message Message {
|
||||
optional ConditionalRevealMessage conditionalRevealMessage = 120;
|
||||
optional PollAddOptionMessage pollAddOptionMessage = 121;
|
||||
optional EventInviteMessage eventInviteMessage = 122;
|
||||
optional GroupRootKeyShare groupRootKeyShare = 123;
|
||||
message AlbumMessage {
|
||||
optional uint32 expectedImageCount = 2;
|
||||
optional uint32 expectedVideoCount = 3;
|
||||
@@ -2501,6 +2539,7 @@ message Message {
|
||||
UNKNOWN = 0;
|
||||
CONTROL_PASSED = 1;
|
||||
CONTROL_TAKEN = 2;
|
||||
INFO = 3;
|
||||
}
|
||||
message CloudAPIThreadControlNotificationContent {
|
||||
optional string handoffNotificationText = 1;
|
||||
@@ -3282,6 +3321,7 @@ message Message {
|
||||
optional int32 onDemandMsgCount = 4;
|
||||
optional int64 oldestMsgTimestampMs = 5;
|
||||
optional string accountLid = 6;
|
||||
optional bool supportInlineResponse = 7;
|
||||
}
|
||||
|
||||
message PlaceholderMessageResendRequest {
|
||||
@@ -3368,6 +3408,7 @@ message Message {
|
||||
ERROR_REQUEST_ON_NON_SMB_PRIMARY = 4;
|
||||
ERROR_HOSTED_DEVICE_NOT_CONNECTED = 5;
|
||||
ERROR_HOSTED_DEVICE_LOGIN_TIME_NOT_SET = 6;
|
||||
ERROR_MULTI_PROVIDER_NOT_CONFIGURED = 7;
|
||||
}
|
||||
message HistorySyncChunkRetryResponse {
|
||||
optional Message.HistorySyncType syncType = 1;
|
||||
@@ -3616,7 +3657,6 @@ message Message {
|
||||
GROUP_MEMBER_LABEL_CHANGE = 30;
|
||||
AI_MEDIA_COLLECTION_MESSAGE = 31;
|
||||
MESSAGE_UNSCHEDULE = 32;
|
||||
BOT_UNLINK_MESSAGE = 33;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3767,6 +3807,7 @@ message Message {
|
||||
optional bool isLottie = 21;
|
||||
optional string accessibilityLabel = 22;
|
||||
optional int32 premium = 24;
|
||||
optional string emojis = 25;
|
||||
}
|
||||
|
||||
message StickerPackMessage {
|
||||
@@ -3987,6 +4028,7 @@ message MessageContextInfo {
|
||||
optional LimitSharing limitSharingV2 = 14;
|
||||
repeated ThreadID threadId = 15;
|
||||
optional WebLinkRenderConfig weblinkRenderConfig = 16;
|
||||
optional bytes teeBotMetadata = 17;
|
||||
enum MessageAddonExpiryType {
|
||||
STATIC = 1;
|
||||
DEPENDENT_ON_PARENT = 2;
|
||||
@@ -4492,6 +4534,12 @@ message ReportingTokenInfo {
|
||||
optional bytes reportingTag = 1;
|
||||
}
|
||||
|
||||
message ScheduledMessageMetadata {
|
||||
optional string revealKeyId = 1;
|
||||
optional bytes revealKey = 2;
|
||||
optional uint64 scheduledTime = 3;
|
||||
}
|
||||
|
||||
message SenderKeyDistributionMessage {
|
||||
optional uint32 id = 1;
|
||||
optional uint32 iteration = 2;
|
||||
@@ -4892,6 +4940,7 @@ message SyncActionValue {
|
||||
repeated SyncActionValue.BroadcastListParticipant participants = 2;
|
||||
optional string listName = 3;
|
||||
repeated string labelIds = 4;
|
||||
optional string audienceExpression = 5;
|
||||
}
|
||||
|
||||
message CallLogAction {
|
||||
@@ -5021,6 +5070,7 @@ message SyncActionValue {
|
||||
DRAFTED = 8;
|
||||
AI_HANDOFF = 9;
|
||||
CHANNELS = 10;
|
||||
AI_RESPONDING = 11;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5236,6 +5286,8 @@ message SyncActionValue {
|
||||
optional bool isStatusNotificationEnabled = 29;
|
||||
optional int32 statusNotificationToneId = 30;
|
||||
optional bool shouldPlaySoundForCallNotification = 31;
|
||||
optional string chatThemeId = 32;
|
||||
optional string colorSchemeId = 33;
|
||||
enum DisplayMode {
|
||||
DISPLAY_MODE_UNKNOWN = 0;
|
||||
ALWAYS = 1;
|
||||
@@ -5280,6 +5332,8 @@ message SyncActionValue {
|
||||
IS_STATUS_NOTIFICATION_ENABLED = 29;
|
||||
STATUS_NOTIFICATION_TONE_ID = 30;
|
||||
SHOULD_PLAY_SOUND_FOR_CALL_NOTIFICATION = 31;
|
||||
CHAT_THEME_ID = 32;
|
||||
COLOR_SCHEME_ID = 33;
|
||||
}
|
||||
enum SettingPlatform {
|
||||
PLATFORM_UNKNOWN = 0;
|
||||
@@ -5303,11 +5357,21 @@ message SyncActionValue {
|
||||
repeated string userJid = 2;
|
||||
optional bool shareToFB = 3;
|
||||
optional bool shareToIG = 4;
|
||||
repeated CustomList customLists = 5;
|
||||
message CustomList {
|
||||
optional string listId = 1;
|
||||
optional string name = 2;
|
||||
optional string emoji = 3;
|
||||
optional bool isSelected = 4;
|
||||
repeated string userJid = 5;
|
||||
}
|
||||
|
||||
enum StatusDistributionMode {
|
||||
ALLOW_LIST = 0;
|
||||
DENY_LIST = 1;
|
||||
CONTACTS = 2;
|
||||
CLOSE_FRIENDS = 3;
|
||||
CUSTOM_LIST = 4;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5694,6 +5758,8 @@ message WebMessageInfo {
|
||||
optional QuarantinedMessage quarantinedMessage = 77;
|
||||
optional uint32 nonJidMentions = 78;
|
||||
optional string hsmTag = 79;
|
||||
optional uint64 ephemeralExpirationTimestamp = 80;
|
||||
optional ScheduledMessageMetadata scheduledMessageMetadata = 81;
|
||||
enum BizPrivacyStatus {
|
||||
E2EE = 0;
|
||||
FB = 2;
|
||||
@@ -5933,6 +5999,8 @@ message WebMessageInfo {
|
||||
GROUP_MEMBER_SHARE_GROUP_HISTORY_MODE = 221;
|
||||
GROUP_OPEN_BOT_ADDED = 222;
|
||||
GROUP_TEE_BOT_ADDED = 223;
|
||||
CONTACT_INFO = 224;
|
||||
SCHEDULED_MESSAGE_CREATED = 225;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+188
-12
@@ -1092,10 +1092,31 @@ export namespace proto {
|
||||
RICH_RESPONSE_UR_IMAGINE_VIDEO = 57,
|
||||
JSON_PATCH_STREAMING = 58,
|
||||
AI_TAB_FORCE_CLIPPY = 59,
|
||||
UNIFIED_RESPONSE_EMBEDDED_SCREENS = 60
|
||||
UNIFIED_RESPONSE_EMBEDDED_SCREENS = 60,
|
||||
AI_SUBSCRIPTION_ENABLED = 61
|
||||
}
|
||||
}
|
||||
|
||||
interface IBotCommandMetadata {
|
||||
commandName?: (string|null);
|
||||
commandDescription?: (string|null);
|
||||
commandPrompt?: (string|null);
|
||||
}
|
||||
|
||||
class BotCommandMetadata implements IBotCommandMetadata {
|
||||
constructor(p?: proto.IBotCommandMetadata);
|
||||
public commandName?: (string|null);
|
||||
public commandDescription?: (string|null);
|
||||
public commandPrompt?: (string|null);
|
||||
public static create(properties?: proto.IBotCommandMetadata): proto.BotCommandMetadata;
|
||||
public static encode(m: proto.IBotCommandMetadata, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): proto.BotCommandMetadata;
|
||||
public static fromObject(d: { [k: string]: any }): proto.BotCommandMetadata;
|
||||
public static toObject(m: proto.BotCommandMetadata, o?: $protobuf.IConversionOptions): { [k: string]: any };
|
||||
public toJSON(): { [k: string]: any };
|
||||
public static getTypeUrl(typeUrlPrefix?: string): string;
|
||||
}
|
||||
|
||||
interface IBotDocumentMessageMetadata {
|
||||
pluginType?: (proto.BotDocumentMessageMetadata.DocumentPluginType|null);
|
||||
}
|
||||
@@ -1680,6 +1701,7 @@ export namespace proto {
|
||||
botRenderingConfigMetadata?: (proto.IBotRenderingConfigMetadata|null);
|
||||
botInfrastructureDiagnostics?: (proto.IBotInfrastructureDiagnostics|null);
|
||||
aiMediaCollectionMetadata?: (proto.IAIMediaCollectionMetadata|null);
|
||||
commandMetadata?: (proto.IBotCommandMetadata|null);
|
||||
internalMetadata?: (Uint8Array|null);
|
||||
}
|
||||
|
||||
@@ -1722,6 +1744,7 @@ export namespace proto {
|
||||
public botRenderingConfigMetadata?: (proto.IBotRenderingConfigMetadata|null);
|
||||
public botInfrastructureDiagnostics?: (proto.IBotInfrastructureDiagnostics|null);
|
||||
public aiMediaCollectionMetadata?: (proto.IAIMediaCollectionMetadata|null);
|
||||
public commandMetadata?: (proto.IBotCommandMetadata|null);
|
||||
public internalMetadata?: (Uint8Array|null);
|
||||
public static create(properties?: proto.IBotMetadata): proto.BotMetadata;
|
||||
public static encode(m: proto.IBotMetadata, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
@@ -1779,7 +1802,8 @@ export namespace proto {
|
||||
WEB_INTRO_PANEL = 46,
|
||||
WEB_NAVIGATION_BAR = 47,
|
||||
GROUP_MEMBER = 54,
|
||||
CHATLIST_SEARCH = 55
|
||||
CHATLIST_SEARCH = 55,
|
||||
NEW_CHAT_LIST = 56
|
||||
}
|
||||
|
||||
interface IBotMetricsMetadata {
|
||||
@@ -3591,6 +3615,10 @@ export namespace proto {
|
||||
wtwaWebsiteUrl?: (string|null);
|
||||
adPreviewUrl?: (string|null);
|
||||
containsCtwaFlowsAutoReply?: (boolean|null);
|
||||
agmThumbnailStrategy?: (number|null);
|
||||
agmTitleStrategy?: (number|null);
|
||||
agmSubtitleStrategy?: (number|null);
|
||||
agmHeaderInteractionStrategy?: (number|null);
|
||||
}
|
||||
|
||||
class ExternalAdReplyInfo implements IExternalAdReplyInfo {
|
||||
@@ -3623,6 +3651,10 @@ export namespace proto {
|
||||
public wtwaWebsiteUrl?: (string|null);
|
||||
public adPreviewUrl?: (string|null);
|
||||
public containsCtwaFlowsAutoReply?: (boolean|null);
|
||||
public agmThumbnailStrategy?: (number|null);
|
||||
public agmTitleStrategy?: (number|null);
|
||||
public agmSubtitleStrategy?: (number|null);
|
||||
public agmHeaderInteractionStrategy?: (number|null);
|
||||
public static create(properties?: proto.ContextInfo.IExternalAdReplyInfo): proto.ContextInfo.ExternalAdReplyInfo;
|
||||
public static encode(m: proto.ContextInfo.IExternalAdReplyInfo, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): proto.ContextInfo.ExternalAdReplyInfo;
|
||||
@@ -4027,6 +4059,7 @@ export namespace proto {
|
||||
companionSupportEnabled?: (boolean|null);
|
||||
campaignSyncEnabled?: (boolean|null);
|
||||
insightsSyncEnabled?: (boolean|null);
|
||||
recipientLimit?: (number|null);
|
||||
}
|
||||
|
||||
class BusinessBroadcast implements IBusinessBroadcast {
|
||||
@@ -4035,6 +4068,7 @@ export namespace proto {
|
||||
public companionSupportEnabled?: (boolean|null);
|
||||
public campaignSyncEnabled?: (boolean|null);
|
||||
public insightsSyncEnabled?: (boolean|null);
|
||||
public recipientLimit?: (number|null);
|
||||
public static create(properties?: proto.DeviceCapabilities.IBusinessBroadcast): proto.DeviceCapabilities.BusinessBroadcast;
|
||||
public static encode(m: proto.DeviceCapabilities.IBusinessBroadcast, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): proto.DeviceCapabilities.BusinessBroadcast;
|
||||
@@ -4210,6 +4244,8 @@ export namespace proto {
|
||||
initialSyncMaxMessagesPerChat?: (number|null);
|
||||
supportManusHistory?: (boolean|null);
|
||||
supportHatchHistory?: (boolean|null);
|
||||
supportedBotChannelFbids?: (string[]|null);
|
||||
supportInlineContacts?: (boolean|null);
|
||||
}
|
||||
|
||||
class HistorySyncConfig implements IHistorySyncConfig {
|
||||
@@ -4236,6 +4272,8 @@ export namespace proto {
|
||||
public initialSyncMaxMessagesPerChat?: (number|null);
|
||||
public supportManusHistory?: (boolean|null);
|
||||
public supportHatchHistory?: (boolean|null);
|
||||
public supportedBotChannelFbids: string[];
|
||||
public supportInlineContacts?: (boolean|null);
|
||||
public static create(properties?: proto.DeviceProps.IHistorySyncConfig): proto.DeviceProps.HistorySyncConfig;
|
||||
public static encode(m: proto.DeviceProps.IHistorySyncConfig, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): proto.DeviceProps.HistorySyncConfig;
|
||||
@@ -4704,6 +4742,42 @@ export namespace proto {
|
||||
}
|
||||
}
|
||||
|
||||
interface IGroupRootKeyShare {
|
||||
keys?: (proto.IGroupRootKeyShareEntry[]|null);
|
||||
}
|
||||
|
||||
class GroupRootKeyShare implements IGroupRootKeyShare {
|
||||
constructor(p?: proto.IGroupRootKeyShare);
|
||||
public keys: proto.IGroupRootKeyShareEntry[];
|
||||
public static create(properties?: proto.IGroupRootKeyShare): proto.GroupRootKeyShare;
|
||||
public static encode(m: proto.IGroupRootKeyShare, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): proto.GroupRootKeyShare;
|
||||
public static fromObject(d: { [k: string]: any }): proto.GroupRootKeyShare;
|
||||
public static toObject(m: proto.GroupRootKeyShare, o?: $protobuf.IConversionOptions): { [k: string]: any };
|
||||
public toJSON(): { [k: string]: any };
|
||||
public static getTypeUrl(typeUrlPrefix?: string): string;
|
||||
}
|
||||
|
||||
interface IGroupRootKeyShareEntry {
|
||||
groupRootKey?: (Uint8Array|null);
|
||||
keyId?: (string|null);
|
||||
expiryTimestampMs?: (number|Long|null);
|
||||
}
|
||||
|
||||
class GroupRootKeyShareEntry implements IGroupRootKeyShareEntry {
|
||||
constructor(p?: proto.IGroupRootKeyShareEntry);
|
||||
public groupRootKey?: (Uint8Array|null);
|
||||
public keyId?: (string|null);
|
||||
public expiryTimestampMs?: (number|Long|null);
|
||||
public static create(properties?: proto.IGroupRootKeyShareEntry): proto.GroupRootKeyShareEntry;
|
||||
public static encode(m: proto.IGroupRootKeyShareEntry, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): proto.GroupRootKeyShareEntry;
|
||||
public static fromObject(d: { [k: string]: any }): proto.GroupRootKeyShareEntry;
|
||||
public static toObject(m: proto.GroupRootKeyShareEntry, o?: $protobuf.IConversionOptions): { [k: string]: any };
|
||||
public toJSON(): { [k: string]: any };
|
||||
public static getTypeUrl(typeUrlPrefix?: string): string;
|
||||
}
|
||||
|
||||
interface IHandshakeMessage {
|
||||
clientHello?: (proto.HandshakeMessage.IClientHello|null);
|
||||
serverHello?: (proto.HandshakeMessage.IServerHello|null);
|
||||
@@ -4760,6 +4834,7 @@ export namespace proto {
|
||||
sendServerHelloPaddedBytes?: (boolean|null);
|
||||
simulateXxkemFs?: (boolean|null);
|
||||
pqMode?: (proto.HandshakeMessage.HandshakePqMode|null);
|
||||
extendedEphemeral?: (Uint8Array|null);
|
||||
}
|
||||
|
||||
class ClientHello implements IClientHello {
|
||||
@@ -4773,6 +4848,7 @@ export namespace proto {
|
||||
public sendServerHelloPaddedBytes?: (boolean|null);
|
||||
public simulateXxkemFs?: (boolean|null);
|
||||
public pqMode?: (proto.HandshakeMessage.HandshakePqMode|null);
|
||||
public extendedEphemeral?: (Uint8Array|null);
|
||||
public static create(properties?: proto.HandshakeMessage.IClientHello): proto.HandshakeMessage.ClientHello;
|
||||
public static encode(m: proto.HandshakeMessage.IClientHello, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): proto.HandshakeMessage.ClientHello;
|
||||
@@ -4800,6 +4876,7 @@ export namespace proto {
|
||||
payload?: (Uint8Array|null);
|
||||
extendedStatic?: (Uint8Array|null);
|
||||
paddingBytes?: (Uint8Array|null);
|
||||
extendedCiphertext?: (Uint8Array|null);
|
||||
}
|
||||
|
||||
class ServerHello implements IServerHello {
|
||||
@@ -4809,6 +4886,7 @@ export namespace proto {
|
||||
public payload?: (Uint8Array|null);
|
||||
public extendedStatic?: (Uint8Array|null);
|
||||
public paddingBytes?: (Uint8Array|null);
|
||||
public extendedCiphertext?: (Uint8Array|null);
|
||||
public static create(properties?: proto.HandshakeMessage.IServerHello): proto.HandshakeMessage.ServerHello;
|
||||
public static encode(m: proto.HandshakeMessage.IServerHello, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): proto.HandshakeMessage.ServerHello;
|
||||
@@ -4838,6 +4916,8 @@ export namespace proto {
|
||||
shareableChatIdentifierEncryptionKey?: (Uint8Array|null);
|
||||
accounts?: (proto.IAccount[]|null);
|
||||
nctSalt?: (Uint8Array|null);
|
||||
inlineContacts?: (proto.IInlineContact[]|null);
|
||||
inlineContactsProvided?: (boolean|null);
|
||||
}
|
||||
|
||||
class HistorySync implements IHistorySync {
|
||||
@@ -4860,6 +4940,8 @@ export namespace proto {
|
||||
public shareableChatIdentifierEncryptionKey?: (Uint8Array|null);
|
||||
public accounts: proto.IAccount[];
|
||||
public nctSalt?: (Uint8Array|null);
|
||||
public inlineContacts: proto.IInlineContact[];
|
||||
public inlineContactsProvided?: (boolean|null);
|
||||
public static create(properties?: proto.IHistorySync): proto.HistorySync;
|
||||
public static encode(m: proto.IHistorySync, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): proto.HistorySync;
|
||||
@@ -5127,6 +5209,30 @@ export namespace proto {
|
||||
}
|
||||
}
|
||||
|
||||
interface IInlineContact {
|
||||
pnJid?: (string|null);
|
||||
lidJid?: (string|null);
|
||||
fullName?: (string|null);
|
||||
firstName?: (string|null);
|
||||
username?: (string|null);
|
||||
}
|
||||
|
||||
class InlineContact implements IInlineContact {
|
||||
constructor(p?: proto.IInlineContact);
|
||||
public pnJid?: (string|null);
|
||||
public lidJid?: (string|null);
|
||||
public fullName?: (string|null);
|
||||
public firstName?: (string|null);
|
||||
public username?: (string|null);
|
||||
public static create(properties?: proto.IInlineContact): proto.InlineContact;
|
||||
public static encode(m: proto.IInlineContact, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): proto.InlineContact;
|
||||
public static fromObject(d: { [k: string]: any }): proto.InlineContact;
|
||||
public static toObject(m: proto.InlineContact, o?: $protobuf.IConversionOptions): { [k: string]: any };
|
||||
public toJSON(): { [k: string]: any };
|
||||
public static getTypeUrl(typeUrlPrefix?: string): string;
|
||||
}
|
||||
|
||||
interface IInteractiveAnnotation {
|
||||
polygonVertices?: (proto.IPoint[]|null);
|
||||
shouldSkipConfirmation?: (boolean|null);
|
||||
@@ -5355,8 +5461,7 @@ export namespace proto {
|
||||
UNKNOWN = 0,
|
||||
CHAT_SETTING = 1,
|
||||
BIZ_SUPPORTS_FB_HOSTING = 2,
|
||||
UNKNOWN_GROUP = 3,
|
||||
DEPRECATION = 4
|
||||
UNKNOWN_GROUP = 3
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5619,6 +5724,7 @@ export namespace proto {
|
||||
conditionalRevealMessage?: (proto.Message.IConditionalRevealMessage|null);
|
||||
pollAddOptionMessage?: (proto.Message.IPollAddOptionMessage|null);
|
||||
eventInviteMessage?: (proto.Message.IEventInviteMessage|null);
|
||||
groupRootKeyShare?: (proto.IGroupRootKeyShare|null);
|
||||
}
|
||||
|
||||
class Message implements IMessage {
|
||||
@@ -5725,6 +5831,7 @@ export namespace proto {
|
||||
public conditionalRevealMessage?: (proto.Message.IConditionalRevealMessage|null);
|
||||
public pollAddOptionMessage?: (proto.Message.IPollAddOptionMessage|null);
|
||||
public eventInviteMessage?: (proto.Message.IEventInviteMessage|null);
|
||||
public groupRootKeyShare?: (proto.IGroupRootKeyShare|null);
|
||||
public static create(properties?: proto.IMessage): proto.Message;
|
||||
public static encode(m: proto.IMessage, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): proto.Message;
|
||||
@@ -6264,7 +6371,8 @@ export namespace proto {
|
||||
enum CloudAPIThreadControl {
|
||||
UNKNOWN = 0,
|
||||
CONTROL_PASSED = 1,
|
||||
CONTROL_TAKEN = 2
|
||||
CONTROL_TAKEN = 2,
|
||||
INFO = 3
|
||||
}
|
||||
|
||||
interface ICloudAPIThreadControlNotificationContent {
|
||||
@@ -8372,6 +8480,7 @@ export namespace proto {
|
||||
onDemandMsgCount?: (number|null);
|
||||
oldestMsgTimestampMs?: (number|Long|null);
|
||||
accountLid?: (string|null);
|
||||
supportInlineResponse?: (boolean|null);
|
||||
}
|
||||
|
||||
class HistorySyncOnDemandRequest implements IHistorySyncOnDemandRequest {
|
||||
@@ -8382,6 +8491,7 @@ export namespace proto {
|
||||
public onDemandMsgCount?: (number|null);
|
||||
public oldestMsgTimestampMs?: (number|Long|null);
|
||||
public accountLid?: (string|null);
|
||||
public supportInlineResponse?: (boolean|null);
|
||||
public static create(properties?: proto.Message.PeerDataOperationRequestMessage.IHistorySyncOnDemandRequest): proto.Message.PeerDataOperationRequestMessage.HistorySyncOnDemandRequest;
|
||||
public static encode(m: proto.Message.PeerDataOperationRequestMessage.IHistorySyncOnDemandRequest, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): proto.Message.PeerDataOperationRequestMessage.HistorySyncOnDemandRequest;
|
||||
@@ -8655,7 +8765,8 @@ export namespace proto {
|
||||
GENERIC_ERROR = 3,
|
||||
ERROR_REQUEST_ON_NON_SMB_PRIMARY = 4,
|
||||
ERROR_HOSTED_DEVICE_NOT_CONNECTED = 5,
|
||||
ERROR_HOSTED_DEVICE_LOGIN_TIME_NOT_SET = 6
|
||||
ERROR_HOSTED_DEVICE_LOGIN_TIME_NOT_SET = 6,
|
||||
ERROR_MULTI_PROVIDER_NOT_CONFIGURED = 7
|
||||
}
|
||||
|
||||
interface IHistorySyncChunkRetryResponse {
|
||||
@@ -9281,8 +9392,7 @@ export namespace proto {
|
||||
AI_QUERY_FANOUT = 29,
|
||||
GROUP_MEMBER_LABEL_CHANGE = 30,
|
||||
AI_MEDIA_COLLECTION_MESSAGE = 31,
|
||||
MESSAGE_UNSCHEDULE = 32,
|
||||
BOT_UNLINK_MESSAGE = 33
|
||||
MESSAGE_UNSCHEDULE = 32
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9661,6 +9771,7 @@ export namespace proto {
|
||||
isLottie?: (boolean|null);
|
||||
accessibilityLabel?: (string|null);
|
||||
premium?: (number|null);
|
||||
emojis?: (string|null);
|
||||
}
|
||||
|
||||
class StickerMessage implements IStickerMessage {
|
||||
@@ -9686,6 +9797,7 @@ export namespace proto {
|
||||
public isLottie?: (boolean|null);
|
||||
public accessibilityLabel?: (string|null);
|
||||
public premium?: (number|null);
|
||||
public emojis?: (string|null);
|
||||
public static create(properties?: proto.Message.IStickerMessage): proto.Message.StickerMessage;
|
||||
public static encode(m: proto.Message.IStickerMessage, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): proto.Message.StickerMessage;
|
||||
@@ -10181,6 +10293,7 @@ export namespace proto {
|
||||
limitSharingV2?: (proto.ILimitSharing|null);
|
||||
threadId?: (proto.IThreadID[]|null);
|
||||
weblinkRenderConfig?: (proto.WebLinkRenderConfig|null);
|
||||
teeBotMetadata?: (Uint8Array|null);
|
||||
}
|
||||
|
||||
class MessageContextInfo implements IMessageContextInfo {
|
||||
@@ -10201,6 +10314,7 @@ export namespace proto {
|
||||
public limitSharingV2?: (proto.ILimitSharing|null);
|
||||
public threadId: proto.IThreadID[];
|
||||
public weblinkRenderConfig?: (proto.WebLinkRenderConfig|null);
|
||||
public teeBotMetadata?: (Uint8Array|null);
|
||||
public static create(properties?: proto.IMessageContextInfo): proto.MessageContextInfo;
|
||||
public static encode(m: proto.IMessageContextInfo, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): proto.MessageContextInfo;
|
||||
@@ -11389,6 +11503,26 @@ export namespace proto {
|
||||
public static getTypeUrl(typeUrlPrefix?: string): string;
|
||||
}
|
||||
|
||||
interface IScheduledMessageMetadata {
|
||||
revealKeyId?: (string|null);
|
||||
revealKey?: (Uint8Array|null);
|
||||
scheduledTime?: (number|Long|null);
|
||||
}
|
||||
|
||||
class ScheduledMessageMetadata implements IScheduledMessageMetadata {
|
||||
constructor(p?: proto.IScheduledMessageMetadata);
|
||||
public revealKeyId?: (string|null);
|
||||
public revealKey?: (Uint8Array|null);
|
||||
public scheduledTime?: (number|Long|null);
|
||||
public static create(properties?: proto.IScheduledMessageMetadata): proto.ScheduledMessageMetadata;
|
||||
public static encode(m: proto.IScheduledMessageMetadata, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): proto.ScheduledMessageMetadata;
|
||||
public static fromObject(d: { [k: string]: any }): proto.ScheduledMessageMetadata;
|
||||
public static toObject(m: proto.ScheduledMessageMetadata, o?: $protobuf.IConversionOptions): { [k: string]: any };
|
||||
public toJSON(): { [k: string]: any };
|
||||
public static getTypeUrl(typeUrlPrefix?: string): string;
|
||||
}
|
||||
|
||||
interface ISenderKeyDistributionMessage {
|
||||
id?: (number|null);
|
||||
iteration?: (number|null);
|
||||
@@ -12482,6 +12616,7 @@ export namespace proto {
|
||||
participants?: (proto.SyncActionValue.IBroadcastListParticipant[]|null);
|
||||
listName?: (string|null);
|
||||
labelIds?: (string[]|null);
|
||||
audienceExpression?: (string|null);
|
||||
}
|
||||
|
||||
class BusinessBroadcastListAction implements IBusinessBroadcastListAction {
|
||||
@@ -12490,6 +12625,7 @@ export namespace proto {
|
||||
public participants: proto.SyncActionValue.IBroadcastListParticipant[];
|
||||
public listName?: (string|null);
|
||||
public labelIds: string[];
|
||||
public audienceExpression?: (string|null);
|
||||
public static create(properties?: proto.SyncActionValue.IBusinessBroadcastListAction): proto.SyncActionValue.BusinessBroadcastListAction;
|
||||
public static encode(m: proto.SyncActionValue.IBusinessBroadcastListAction, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): proto.SyncActionValue.BusinessBroadcastListAction;
|
||||
@@ -12918,7 +13054,8 @@ export namespace proto {
|
||||
SERVER_ASSIGNED = 7,
|
||||
DRAFTED = 8,
|
||||
AI_HANDOFF = 9,
|
||||
CHANNELS = 10
|
||||
CHANNELS = 10,
|
||||
AI_RESPONDING = 11
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13560,6 +13697,8 @@ export namespace proto {
|
||||
isStatusNotificationEnabled?: (boolean|null);
|
||||
statusNotificationToneId?: (number|null);
|
||||
shouldPlaySoundForCallNotification?: (boolean|null);
|
||||
chatThemeId?: (string|null);
|
||||
colorSchemeId?: (string|null);
|
||||
}
|
||||
|
||||
class SettingsSyncAction implements ISettingsSyncAction {
|
||||
@@ -13595,6 +13734,8 @@ export namespace proto {
|
||||
public isStatusNotificationEnabled?: (boolean|null);
|
||||
public statusNotificationToneId?: (number|null);
|
||||
public shouldPlaySoundForCallNotification?: (boolean|null);
|
||||
public chatThemeId?: (string|null);
|
||||
public colorSchemeId?: (string|null);
|
||||
public static create(properties?: proto.SyncActionValue.ISettingsSyncAction): proto.SyncActionValue.SettingsSyncAction;
|
||||
public static encode(m: proto.SyncActionValue.ISettingsSyncAction, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): proto.SyncActionValue.SettingsSyncAction;
|
||||
@@ -13651,7 +13792,9 @@ export namespace proto {
|
||||
IS_GROUP_REACTIONS_NOTIFICATION_ENABLED = 28,
|
||||
IS_STATUS_NOTIFICATION_ENABLED = 29,
|
||||
STATUS_NOTIFICATION_TONE_ID = 30,
|
||||
SHOULD_PLAY_SOUND_FOR_CALL_NOTIFICATION = 31
|
||||
SHOULD_PLAY_SOUND_FOR_CALL_NOTIFICATION = 31,
|
||||
CHAT_THEME_ID = 32,
|
||||
COLOR_SCHEME_ID = 33
|
||||
}
|
||||
|
||||
enum SettingPlatform {
|
||||
@@ -13700,6 +13843,7 @@ export namespace proto {
|
||||
userJid?: (string[]|null);
|
||||
shareToFB?: (boolean|null);
|
||||
shareToIG?: (boolean|null);
|
||||
customLists?: (proto.SyncActionValue.StatusPrivacyAction.ICustomList[]|null);
|
||||
}
|
||||
|
||||
class StatusPrivacyAction implements IStatusPrivacyAction {
|
||||
@@ -13708,6 +13852,7 @@ export namespace proto {
|
||||
public userJid: string[];
|
||||
public shareToFB?: (boolean|null);
|
||||
public shareToIG?: (boolean|null);
|
||||
public customLists: proto.SyncActionValue.StatusPrivacyAction.ICustomList[];
|
||||
public static create(properties?: proto.SyncActionValue.IStatusPrivacyAction): proto.SyncActionValue.StatusPrivacyAction;
|
||||
public static encode(m: proto.SyncActionValue.IStatusPrivacyAction, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): proto.SyncActionValue.StatusPrivacyAction;
|
||||
@@ -13719,11 +13864,36 @@ export namespace proto {
|
||||
|
||||
namespace StatusPrivacyAction {
|
||||
|
||||
interface ICustomList {
|
||||
listId?: (string|null);
|
||||
name?: (string|null);
|
||||
emoji?: (string|null);
|
||||
isSelected?: (boolean|null);
|
||||
userJid?: (string[]|null);
|
||||
}
|
||||
|
||||
class CustomList implements ICustomList {
|
||||
constructor(p?: proto.SyncActionValue.StatusPrivacyAction.ICustomList);
|
||||
public listId?: (string|null);
|
||||
public name?: (string|null);
|
||||
public emoji?: (string|null);
|
||||
public isSelected?: (boolean|null);
|
||||
public userJid: string[];
|
||||
public static create(properties?: proto.SyncActionValue.StatusPrivacyAction.ICustomList): proto.SyncActionValue.StatusPrivacyAction.CustomList;
|
||||
public static encode(m: proto.SyncActionValue.StatusPrivacyAction.ICustomList, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): proto.SyncActionValue.StatusPrivacyAction.CustomList;
|
||||
public static fromObject(d: { [k: string]: any }): proto.SyncActionValue.StatusPrivacyAction.CustomList;
|
||||
public static toObject(m: proto.SyncActionValue.StatusPrivacyAction.CustomList, o?: $protobuf.IConversionOptions): { [k: string]: any };
|
||||
public toJSON(): { [k: string]: any };
|
||||
public static getTypeUrl(typeUrlPrefix?: string): string;
|
||||
}
|
||||
|
||||
enum StatusDistributionMode {
|
||||
ALLOW_LIST = 0,
|
||||
DENY_LIST = 1,
|
||||
CONTACTS = 2,
|
||||
CLOSE_FRIENDS = 3
|
||||
CLOSE_FRIENDS = 3,
|
||||
CUSTOM_LIST = 4
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14731,6 +14901,8 @@ export namespace proto {
|
||||
quarantinedMessage?: (proto.IQuarantinedMessage|null);
|
||||
nonJidMentions?: (number|null);
|
||||
hsmTag?: (string|null);
|
||||
ephemeralExpirationTimestamp?: (number|Long|null);
|
||||
scheduledMessageMetadata?: (proto.IScheduledMessageMetadata|null);
|
||||
}
|
||||
|
||||
class WebMessageInfo implements IWebMessageInfo {
|
||||
@@ -14803,6 +14975,8 @@ export namespace proto {
|
||||
public quarantinedMessage?: (proto.IQuarantinedMessage|null);
|
||||
public nonJidMentions?: (number|null);
|
||||
public hsmTag?: (string|null);
|
||||
public ephemeralExpirationTimestamp?: (number|Long|null);
|
||||
public scheduledMessageMetadata?: (proto.IScheduledMessageMetadata|null);
|
||||
public static create(properties?: proto.IWebMessageInfo): proto.WebMessageInfo;
|
||||
public static encode(m: proto.IWebMessageInfo, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): proto.WebMessageInfo;
|
||||
@@ -15054,7 +15228,9 @@ export namespace proto {
|
||||
QUARANTINED_MESSAGE = 220,
|
||||
GROUP_MEMBER_SHARE_GROUP_HISTORY_MODE = 221,
|
||||
GROUP_OPEN_BOT_ADDED = 222,
|
||||
GROUP_TEE_BOT_ADDED = 223
|
||||
GROUP_TEE_BOT_ADDED = 223,
|
||||
CONTACT_INFO = 224,
|
||||
SCHEDULED_MESSAGE_CREATED = 225
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1421
-14
File diff suppressed because it is too large
Load Diff
+725
-409
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,531 @@
|
||||
# Mensagens View-Once (Visualização Única) — Guia de Implementação
|
||||
|
||||
**Data:** 2026-03-23
|
||||
**Versão:** 1.0
|
||||
|
||||
---
|
||||
|
||||
## 1. O que é View-Once
|
||||
|
||||
Mensagem de visualização única é um tipo especial de mídia (imagem, vídeo ou áudio) que o destinatário pode abrir apenas uma vez. Após abrir, o conteúdo some permanentemente.
|
||||
|
||||
---
|
||||
|
||||
> ## ⚠️ RESTRIÇÃO CRÍTICA — Contas Hosted (Meta Business Cloud API)
|
||||
>
|
||||
> **Contas registradas como "hosted" na Meta Business Cloud API têm view-once bloqueado pelo servidor do WhatsApp.**
|
||||
>
|
||||
> Essa restrição se aplica a **todos os clientes** (Android, iOS, WA Web) e **não há como contornar por código** — é uma política imposta diretamente pelo servidor WA para contas hosted.
|
||||
>
|
||||
> **Como identificar se sua conta é hosted:**
|
||||
> - A conta foi criada via Meta Business Cloud API (WABA)
|
||||
> - Aparece como "Meta" ou "Business Cloud" nas configurações do WhatsApp Business Manager
|
||||
>
|
||||
> **Contas não-hosted** (registradas diretamente via QR code ou pair code) **funcionam normalmente** com view-once.
|
||||
|
||||
---
|
||||
|
||||
**Comportamento em cada dispositivo após envio via API (contas não-hosted):**
|
||||
|
||||
| Dispositivo | O que aparece |
|
||||
|---|---|
|
||||
| Destinatário (Android/iOS) | Recebe a mídia com ícone de olhinho — pode abrir uma vez |
|
||||
| Android principal do remetente | Mostra na conversa que a mensagem foi enviada (ícone de olhinho) |
|
||||
| WA Web do remetente | "Aguardando mensagem. Abra o WhatsApp no seu celular." |
|
||||
|
||||
> **Nota:** A mensagem "Aguardando mensagem..." no WA Web é o comportamento correto e esperado quando o envio vem de um companion (API). É uma limitação do protocolo WhatsApp — o servidor só permite que o celular principal notifique companions com o conteúdo da view-once.
|
||||
|
||||
---
|
||||
|
||||
## 2. Como Enviar via API
|
||||
|
||||
### 2.1 Imagem
|
||||
|
||||
```bash
|
||||
curl -X POST https://sua-api.com/v1/messages/send_image \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "x-api-key: SEU_API_KEY" \
|
||||
-d '{
|
||||
"instance": "nome-da-instancia",
|
||||
"to": "5511999999999",
|
||||
"caption": "Olha só isso!",
|
||||
"imageUrl": "https://exemplo.com/foto.jpg",
|
||||
"viewOnce": true
|
||||
}'
|
||||
```
|
||||
|
||||
**Resposta de sucesso:**
|
||||
```json
|
||||
{ "ok": true }
|
||||
```
|
||||
|
||||
### 2.2 Vídeo
|
||||
|
||||
```bash
|
||||
curl -X POST https://sua-api.com/v1/messages/send_video \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "x-api-key: SEU_API_KEY" \
|
||||
-d '{
|
||||
"instance": "nome-da-instancia",
|
||||
"to": "5511999999999",
|
||||
"caption": "Assista uma vez",
|
||||
"videoUrl": "https://exemplo.com/video.mp4",
|
||||
"viewOnce": true
|
||||
}'
|
||||
```
|
||||
|
||||
### 2.3 Áudio
|
||||
|
||||
```bash
|
||||
curl -X POST https://sua-api.com/v1/messages/send_audio \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "x-api-key: SEU_API_KEY" \
|
||||
-d '{
|
||||
"instance": "nome-da-instancia",
|
||||
"to": "5511999999999",
|
||||
"audioUrl": "https://exemplo.com/audio.ogg",
|
||||
"ptt": false,
|
||||
"viewOnce": true
|
||||
}'
|
||||
```
|
||||
|
||||
### 2.4 Usando Base64 (sem URL pública)
|
||||
|
||||
```bash
|
||||
curl -X POST https://sua-api.com/v1/messages/send_image \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "x-api-key: SEU_API_KEY" \
|
||||
-d '{
|
||||
"instance": "nome-da-instancia",
|
||||
"to": "5511999999999",
|
||||
"imageBase64": "data:image/jpeg;base64,/9j/4AAQSkZJRgAB...",
|
||||
"viewOnce": true
|
||||
}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Como Receber via Webhook
|
||||
|
||||
Quando um contato envia uma mensagem de visualização única para o número conectado na API, o webhook recebe o evento com `key.isViewOnce = true`.
|
||||
|
||||
### 3.1 Estrutura do evento recebido
|
||||
|
||||
```json
|
||||
{
|
||||
"event": "messages.upsert",
|
||||
"instance": "nome-da-instancia",
|
||||
"data": {
|
||||
"messages": [
|
||||
{
|
||||
"key": {
|
||||
"remoteJid": "5511999999999@s.whatsapp.net",
|
||||
"fromMe": false,
|
||||
"id": "3EB0ABCDEF123456",
|
||||
"isViewOnce": true
|
||||
},
|
||||
"message": {
|
||||
"viewOnceMessageV2": {
|
||||
"message": {
|
||||
"imageMessage": {
|
||||
"url": "https://mmg.whatsapp.net/...",
|
||||
"mimetype": "image/jpeg",
|
||||
"mediaKey": "base64...",
|
||||
"fileEncSha256": "base64...",
|
||||
"directPath": "/v/...",
|
||||
"viewOnce": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"messageTimestamp": 1742700000,
|
||||
"pushName": "João Silva"
|
||||
}
|
||||
],
|
||||
"type": "notify"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 3.2 Como identificar que é view-once
|
||||
|
||||
O campo principal para identificar é `key.isViewOnce = true`. Existem dois caminhos para confirmar:
|
||||
|
||||
```javascript
|
||||
function isViewOnce(msg) {
|
||||
// Caminho 1: flag direta (mais simples)
|
||||
if (msg.key?.isViewOnce) return true
|
||||
|
||||
// Caminho 2: verificar o wrapper da mensagem
|
||||
const inner =
|
||||
msg.message?.viewOnceMessageV2?.message ||
|
||||
msg.message?.viewOnceMessage?.message ||
|
||||
msg.message?.viewOnceMessageV2Extension?.message
|
||||
|
||||
return !!(
|
||||
inner?.imageMessage?.viewOnce ||
|
||||
inner?.videoMessage?.viewOnce ||
|
||||
inner?.audioMessage?.viewOnce
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
### 3.3 Como acessar a mídia
|
||||
|
||||
```javascript
|
||||
function getViewOnceMedia(msg) {
|
||||
const inner =
|
||||
msg.message?.viewOnceMessageV2?.message ||
|
||||
msg.message?.viewOnceMessage?.message ||
|
||||
msg.message?.viewOnceMessageV2Extension?.message
|
||||
|
||||
if (!inner) return null
|
||||
|
||||
if (inner.imageMessage) return { type: 'image', media: inner.imageMessage }
|
||||
if (inner.videoMessage) return { type: 'video', media: inner.videoMessage }
|
||||
if (inner.audioMessage) return { type: 'audio', media: inner.audioMessage }
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
// Uso:
|
||||
const media = getViewOnceMedia(msg)
|
||||
if (media) {
|
||||
console.log(`View-once ${media.type}`)
|
||||
console.log('URL:', media.media.url)
|
||||
console.log('DirectPath:', media.media.directPath)
|
||||
console.log('MediaKey:', media.media.mediaKey) // necessário para download
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. Como Exibir numa Ferramenta (Frontend/CRM)
|
||||
|
||||
### 4.1 Lógica de detecção e exibição
|
||||
|
||||
```javascript
|
||||
function renderMessage(msg) {
|
||||
if (!isViewOnce(msg)) {
|
||||
// Renderizar mensagem normal
|
||||
return renderNormalMessage(msg)
|
||||
}
|
||||
|
||||
const media = getViewOnceMedia(msg)
|
||||
if (!media) return
|
||||
|
||||
// Verificar se já foi aberta (controle local da ferramenta)
|
||||
const alreadyOpened = localStorage.getItem(`vo_${msg.key.id}`)
|
||||
|
||||
if (alreadyOpened) {
|
||||
// Mostrar placeholder de "já visualizado"
|
||||
return renderViewOncePlaceholder(media.type, msg.key.fromMe)
|
||||
}
|
||||
|
||||
if (msg.key.fromMe) {
|
||||
// Mensagem enviada por mim — nunca mostrar conteúdo
|
||||
return renderSentViewOnce(media.type)
|
||||
}
|
||||
|
||||
// Mensagem recebida — mostrar botão para "abrir uma vez"
|
||||
return renderViewOnceButton(media.type, msg)
|
||||
}
|
||||
```
|
||||
|
||||
### 4.2 Componente de exibição — mensagem recebida
|
||||
|
||||
```javascript
|
||||
function renderViewOnceButton(type, msg) {
|
||||
const icons = { image: '📷', video: '🎥', audio: '🎵' }
|
||||
const labels = { image: 'Foto', video: 'Vídeo', áudio: 'Áudio' }
|
||||
|
||||
return `
|
||||
<div class="view-once-bubble received">
|
||||
<span class="view-once-icon">${icons[type]}</span>
|
||||
<span class="view-once-label">${labels[type]} de visualização única</span>
|
||||
<button onclick="openViewOnce('${msg.key.id}', '${type}')">
|
||||
Abrir
|
||||
</button>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
|
||||
async function openViewOnce(msgId, type) {
|
||||
// 1. Marcar como aberta ANTES de mostrar (só uma chance)
|
||||
localStorage.setItem(`vo_${msgId}`, '1')
|
||||
|
||||
// 2. Baixar e mostrar a mídia
|
||||
const mediaUrl = await downloadViewOnceMedia(msgId)
|
||||
showMedia(type, mediaUrl)
|
||||
|
||||
// 3. Após fechar/visualizar, substituir pelo placeholder
|
||||
onMediaClosed(() => {
|
||||
replaceWithPlaceholder(msgId, type)
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
### 4.3 Componente de exibição — mensagem enviada
|
||||
|
||||
```javascript
|
||||
function renderSentViewOnce(type) {
|
||||
const labels = { image: 'Foto', video: 'Vídeo', audio: 'Áudio' }
|
||||
return `
|
||||
<div class="view-once-bubble sent">
|
||||
<span class="view-once-icon">👁️</span>
|
||||
<span>${labels[type]} de visualização única</span>
|
||||
<span class="view-once-status">Enviada</span>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
```
|
||||
|
||||
### 4.4 Placeholder após visualização
|
||||
|
||||
```javascript
|
||||
function renderViewOncePlaceholder(type, fromMe) {
|
||||
const labels = { image: 'foto', video: 'vídeo', audio: 'áudio' }
|
||||
const text = fromMe
|
||||
? `Você enviou uma ${labels[type]} de visualização única`
|
||||
: `${labels[type]} de visualização única aberta`
|
||||
|
||||
return `
|
||||
<div class="view-once-bubble placeholder">
|
||||
<span class="view-once-icon">🚫</span>
|
||||
<span>${text}</span>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
```
|
||||
|
||||
### 4.5 CSS sugerido
|
||||
|
||||
```css
|
||||
.view-once-bubble {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 10px 14px;
|
||||
border-radius: 12px;
|
||||
max-width: 280px;
|
||||
}
|
||||
|
||||
.view-once-bubble.received {
|
||||
background: #f0f0f0;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.view-once-bubble.sent {
|
||||
background: #dcf8c6;
|
||||
color: #333;
|
||||
align-self: flex-end;
|
||||
}
|
||||
|
||||
.view-once-bubble.placeholder {
|
||||
background: #e8e8e8;
|
||||
color: #999;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.view-once-bubble button {
|
||||
background: #25d366;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
padding: 6px 12px;
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. Código Implementado na API
|
||||
|
||||
### 5.1 Geração da mensagem — `src/Utils/messages.ts`
|
||||
|
||||
Quando `viewOnce: true` é passado, a mídia é encapsulada no wrapper moderno `viewOnceMessageV2` (campo 55 do proto) e o flag `viewOnce=true` é setado na mídia interna:
|
||||
|
||||
```typescript
|
||||
if (hasOptionalProperty(message, 'viewOnce') && !!message.viewOnce) {
|
||||
// Seta viewOnce=true na mensagem de mídia interna
|
||||
if (m.imageMessage) m.imageMessage.viewOnce = true
|
||||
else if (m.videoMessage) m.videoMessage.viewOnce = true
|
||||
else if (m.audioMessage) m.audioMessage.viewOnce = true
|
||||
// Usa viewOnceMessageV2 (campo 55) — formato atual do WA
|
||||
m = { viewOnceMessageV2: { message: m } }
|
||||
}
|
||||
```
|
||||
|
||||
### 5.2 Envio — `src/Socket/messages-send.ts`
|
||||
|
||||
**Detecção de view-once real** (não confunde com botões/listas que também usam o wrapper `viewOnceMessage`):
|
||||
|
||||
```typescript
|
||||
// Detecta view-once real pela flag viewOnce na mídia interna.
|
||||
// viewOnceMessage* wrappers são também usados por botões/listas/carrosséis
|
||||
// (que carregam interactiveMessage dentro) — esses NÃO têm viewOnce=true na mídia.
|
||||
const viewOnceInner =
|
||||
message.viewOnceMessageV2?.message ||
|
||||
message.viewOnceMessage?.message ||
|
||||
message.viewOnceMessageV2Extension?.message
|
||||
const isViewOnceMsg = !!(
|
||||
viewOnceInner?.imageMessage?.viewOnce ||
|
||||
viewOnceInner?.videoMessage?.viewOnce ||
|
||||
viewOnceInner?.audioMessage?.viewOnce
|
||||
)
|
||||
|
||||
// Para view-once: DSM enviado apenas para o celular principal (device=0).
|
||||
// Companions (device>0) são omitidos — o servidor WA gera
|
||||
// <unavailable type="view_once"/> automaticamente para eles.
|
||||
const viewOnceMeRecipients = isViewOnceMsg
|
||||
? meRecipients.filter(jid => !jidDecode(jid)?.device)
|
||||
: meRecipients
|
||||
|
||||
// assertSessions apenas para quem vai realmente receber
|
||||
await assertSessions([...viewOnceMeRecipients, ...otherRecipients])
|
||||
|
||||
const [meNodes, otherNodes] = await Promise.all([
|
||||
createParticipantNodes(viewOnceMeRecipients, meMsg || message, extraAttrs),
|
||||
createParticipantNodes(otherRecipients, message, extraAttrs)
|
||||
])
|
||||
participants.push(...meNodes)
|
||||
participants.push(...otherNodes)
|
||||
|
||||
// phash recalculado com os participantes reais
|
||||
const phashRecipients = isViewOnceMsg
|
||||
? [...viewOnceMeRecipients, ...otherRecipients]
|
||||
: [...meRecipients, ...otherRecipients]
|
||||
if (phashRecipients.length > 0) {
|
||||
extraAttrs['phash'] = generateParticipantHashV2(phashRecipients)
|
||||
}
|
||||
```
|
||||
|
||||
**`getMediaType()` — garante que vídeo e áudio view-once sejam entregues:**
|
||||
|
||||
```typescript
|
||||
const getMediaType = (message: proto.IMessage) => {
|
||||
// Desencapsula wrapper view-once antes de verificar o tipo de mídia.
|
||||
// Sem isso, message.videoMessage e message.audioMessage são undefined
|
||||
// (estão dentro do wrapper) e o atributo mediatype ficaria ausente no
|
||||
// enc node — o servidor WA descarta silenciosamente vídeo/áudio view-once.
|
||||
const inner =
|
||||
message.viewOnceMessage?.message ||
|
||||
message.viewOnceMessageV2?.message ||
|
||||
message.viewOnceMessageV2Extension?.message
|
||||
if (inner) {
|
||||
return getMediaType(inner)
|
||||
}
|
||||
|
||||
if (message.imageMessage) return 'image'
|
||||
else if (message.videoMessage) return 'video'
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
### 5.3 Recepção — `src/Utils/decode-wa-message.ts`
|
||||
|
||||
Quando a API recebe uma view-once como companion (linked device), o servidor envia dois stanzas:
|
||||
|
||||
- **Stanza 1** (`enc`): conteúdo completo com metadados da mídia
|
||||
- **Stanza 2** (`unavailable type="view_once"`): sinal de sync
|
||||
|
||||
O stanza 1 é detectado e marcado corretamente:
|
||||
|
||||
```typescript
|
||||
// Detecta view-once na stanza 1 recebida por linked device.
|
||||
// O wrapper viewOnceMessage também é usado por mensagens interativas
|
||||
// (interactiveMessage, listMessage) — esses NÃO têm viewOnce=true na mídia.
|
||||
const viewOnceInner =
|
||||
msg.viewOnceMessage?.message ||
|
||||
msg.viewOnceMessageV2?.message ||
|
||||
msg.viewOnceMessageV2Extension?.message
|
||||
if (
|
||||
viewOnceInner?.imageMessage?.viewOnce ||
|
||||
viewOnceInner?.videoMessage?.viewOnce ||
|
||||
viewOnceInner?.audioMessage?.viewOnce
|
||||
) {
|
||||
fullMessage.key.isViewOnce = true
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 6. Fluxo Completo
|
||||
|
||||
```
|
||||
API envia view-once para destinatário
|
||||
│
|
||||
├── Protobuf gerado:
|
||||
│ viewOnceMessageV2 {
|
||||
│ message {
|
||||
│ imageMessage { viewOnce: true, url, mediaKey, ... }
|
||||
│ }
|
||||
│ }
|
||||
│
|
||||
├── Stanza enviado ao servidor WA:
|
||||
│ <message to="destinatario@s.whatsapp.net" type="media">
|
||||
│ <enc type="pkmsg">...viewOnceMessageV2 cifrado...</enc> ← para o destinatário
|
||||
│ <participants>
|
||||
│ <to jid="meu-numero:0@lid"> ← celular principal
|
||||
│ <enc type="msg">...DSM{viewOnceMessageV2}...</enc>
|
||||
│ </to>
|
||||
│ <!-- device>0 omitidos — servidor gera unavailable -->
|
||||
│ </participants>
|
||||
│ </message>
|
||||
│
|
||||
└── Distribuição pelo servidor:
|
||||
├── Destinatário → recebe enc → abre uma vez ✅
|
||||
├── Celular principal → recebe DSM → mostra "você enviou" ✅
|
||||
└── WA Web → recebe <unavailable> → "Aguardando..." ✅
|
||||
|
||||
|
||||
Destinatário envia view-once de volta para a API
|
||||
│
|
||||
├── Stanza recebido pela API (stanza 1 — enc com conteúdo):
|
||||
│ <message from="destinatario@s.whatsapp.net" type="media">
|
||||
│ <enc type="msg">...viewOnceMessageV2 cifrado...</enc>
|
||||
│ </message>
|
||||
│
|
||||
├── decode-wa-message.ts:
|
||||
│ └── Descriptografa → detecta viewOnce=true → seta key.isViewOnce=true
|
||||
│
|
||||
├── Stanza recebido (stanza 2 — unavailable, ignorado):
|
||||
│ <message from="...">
|
||||
│ <unavailable type="view_once"/>
|
||||
│ </message>
|
||||
│
|
||||
└── Webhook emitido:
|
||||
messages.upsert → msg.key.isViewOnce = true ✅
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 7. Limitações
|
||||
|
||||
| Situação | Comportamento | Motivo |
|
||||
|---|---|---|
|
||||
| **Conta hosted (Meta Business Cloud API)** | **View-once bloqueado para todos os clientes** | **Política do servidor WA para contas hosted — sem workaround** |
|
||||
| WA Web do remetente | "Aguardando mensagem. Abra no celular." | Servidor WA só aceita `<unavailable>` vindo do celular principal, não de companions |
|
||||
| View-once de documento/sticker | Não suportado | Limitação do protocolo WA — só imagem, vídeo e áudio |
|
||||
| `error_479` nos logs | Normal, não é erro | TcToken é atualizado após o envio de view-once |
|
||||
| Companion não consegue abrir | Por design | O conteúdo não é entregue para linked devices |
|
||||
|
||||
---
|
||||
|
||||
## 8. Checklist de Validação
|
||||
|
||||
**Envio:**
|
||||
- [ ] Destinatário recebe com ícone de olhinho
|
||||
- [ ] Destinatário consegue abrir a mídia
|
||||
- [ ] Após abrir, a mídia some
|
||||
- [ ] Celular principal do remetente mostra "você enviou" com ícone de olhinho
|
||||
- [ ] WA Web do remetente mostra "Aguardando mensagem..."
|
||||
- [ ] Funciona para imagem, vídeo e áudio
|
||||
- [ ] Logs mostram `📤 Message sent` (error_479 é normal)
|
||||
|
||||
**Recepção:**
|
||||
- [ ] Webhook recebe `key.isViewOnce = true`
|
||||
- [ ] `viewOnceMessageV2.message.imageMessage` (ou video/audio) está presente
|
||||
- [ ] API não crasha ao receber view-once de outro dispositivo
|
||||
- [ ] Mensagem interativa (botão/lista) enviada após view-once não é afetada
|
||||
@@ -1 +1 @@
|
||||
{"version":[2,3000,1035406580]}
|
||||
{"version":[2,3000,1037137890]}
|
||||
|
||||
+24
-5
@@ -154,7 +154,20 @@ export const MEDIA_PATH_MAP: { [T in MediaType]?: string } = {
|
||||
'md-msg-hist': '/mms/md-app-state',
|
||||
'biz-cover-photo': '/pps/biz-cover-photo',
|
||||
'sticker-pack': '/mms/sticker-pack',
|
||||
'thumbnail-sticker-pack': '/mms/thumbnail-sticker-pack'
|
||||
'thumbnail-sticker-pack': '/mms/thumbnail-sticker-pack',
|
||||
// View-once types — same upload path as regular media (server CDN routing TBD)
|
||||
'viewonce-image': '/mms/image',
|
||||
'viewonce-video': '/mms/video',
|
||||
'viewonce-audio': '/mms/audio'
|
||||
}
|
||||
|
||||
export const NEWSLETTER_MEDIA_PATH_MAP: { [T in MediaType]?: string } = {
|
||||
image: '/newsletter/newsletter-image',
|
||||
video: '/newsletter/newsletter-video',
|
||||
document: '/newsletter/newsletter-document',
|
||||
audio: '/newsletter/newsletter-audio',
|
||||
sticker: '/newsletter/newsletter-image',
|
||||
'thumbnail-link': '/newsletter/newsletter-image'
|
||||
}
|
||||
|
||||
export const MEDIA_HKDF_KEY_MAPPING = {
|
||||
@@ -178,7 +191,11 @@ export const MEDIA_HKDF_KEY_MAPPING = {
|
||||
ptv: 'Video',
|
||||
'biz-cover-photo': 'Image',
|
||||
'sticker-pack': 'Sticker Pack',
|
||||
'thumbnail-sticker-pack': 'Sticker Pack Thumbnail'
|
||||
'thumbnail-sticker-pack': 'Sticker Pack Thumbnail',
|
||||
// View-once types — same HKDF keys as regular types (recipients decrypt with normal keys)
|
||||
'viewonce-image': 'Image',
|
||||
'viewonce-video': 'Video',
|
||||
'viewonce-audio': 'Audio'
|
||||
}
|
||||
|
||||
export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING
|
||||
@@ -188,10 +205,12 @@ export const MEDIA_KEYS = Object.keys(MEDIA_PATH_MAP) as MediaType[]
|
||||
/** 120s timeout for history sync stall detection, same as WA Web's handleChunkProgress / restartPausedTimer (g = 120) */
|
||||
export const HISTORY_SYNC_PAUSED_TIMEOUT_MS = 120_000
|
||||
|
||||
export const MIN_PREKEY_COUNT = 5
|
||||
// Replenishment threshold: when server count drops below this, top-up back to INITIAL_PREKEY_COUNT
|
||||
export const MIN_PREKEY_COUNT = 200
|
||||
|
||||
// Moderate prekey count (upstream uses 812, reduced to balance rate limiting and availability)
|
||||
export const INITIAL_PREKEY_COUNT = 200
|
||||
// Initial pool size matching WA Business (CDP IDB capture: prekey-store = 812 on registration)
|
||||
// Rounded to 800 for cleanliness; replenishment always tops up to this value
|
||||
export const INITIAL_PREKEY_COUNT = 800
|
||||
|
||||
export const UPLOAD_TIMEOUT = 30000 // 30 seconds
|
||||
// Moderate upload interval to balance rate limiting and responsiveness (was 5000)
|
||||
|
||||
+68
-44
@@ -7,6 +7,7 @@ import { proto } from '../../WAProto/index.js'
|
||||
import {
|
||||
DEFAULT_CACHE_TTLS,
|
||||
DEFAULT_SESSION_CLEANUP_CONFIG,
|
||||
INITIAL_PREKEY_COUNT,
|
||||
KEY_BUNDLE_TYPE,
|
||||
MIN_PREKEY_COUNT,
|
||||
PLACEHOLDER_MAX_AGE_SECONDS,
|
||||
@@ -48,9 +49,12 @@ import {
|
||||
getStatusFromReceiptType,
|
||||
handleIdentityChange,
|
||||
hkdf,
|
||||
BAD_MAC_ERROR_TEXT,
|
||||
DECRYPTION_RETRY_CONFIG,
|
||||
MISSING_KEYS_ERROR_TEXT,
|
||||
NACK_REASONS,
|
||||
NO_MESSAGE_FOUND_ERROR_TEXT,
|
||||
RetryReason,
|
||||
normalizeKeyLidToPn,
|
||||
normalizeMessageJids,
|
||||
resolveLidToPn,
|
||||
@@ -1212,7 +1216,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
return await query(stanza)
|
||||
}
|
||||
|
||||
const sendRetryRequest = async (node: BinaryNode, forceIncludeKeys = false) => {
|
||||
const sendRetryRequest = async (node: BinaryNode, forceIncludeKeys = false, decryptionError?: string) => {
|
||||
const { fullMessage } = decodeMessageNode(node, authState.creds.me!.id, authState.creds.me!.lid || '')
|
||||
const { key: msgKey } = fullMessage
|
||||
const msgId = msgKey.id!
|
||||
@@ -1310,39 +1314,39 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
const { account, signedPreKey, signedIdentityKey: identityKey } = authState.creds
|
||||
const fromJid = node.attrs.from!
|
||||
|
||||
// Check if we should recreate the session
|
||||
let shouldRecreateSession = false
|
||||
let recreateReason = ''
|
||||
|
||||
if (enableAutoSessionRecreation && messageRetryManager && retryCount >= 1) {
|
||||
try {
|
||||
// Check if we have a session with this JID
|
||||
const sessionId = signalRepository.jidToSignalProtocolAddress(fromJid)
|
||||
const hasSession = await signalRepository.validateSession(fromJid)
|
||||
|
||||
// Extract error code from retry node if present (for MAC error detection)
|
||||
const retryNode = getBinaryNodeChild(node, 'retry')
|
||||
const errorAttr = retryNode?.attrs?.error
|
||||
const errorCode = messageRetryManager.parseRetryErrorCode(errorAttr)
|
||||
|
||||
const result = messageRetryManager.shouldRecreateSession(fromJid, hasSession.exists, errorCode)
|
||||
shouldRecreateSession = result.recreate
|
||||
recreateReason = result.reason
|
||||
|
||||
if (shouldRecreateSession) {
|
||||
logger.debug({ fromJid, retryCount, reason: recreateReason, errorCode }, 'recreating session for retry')
|
||||
// Delete existing session to force recreation
|
||||
// CRITICAL: Use same transaction key as encrypt/decrypt operations to prevent race
|
||||
// Using meId ensures this delete serializes with sendMessage() and other session operations
|
||||
await authState.keys.transaction(async () => {
|
||||
await authState.keys.set({ session: { [sessionId]: null } })
|
||||
}, authState.creds.me?.id || 'session-operation')
|
||||
forceIncludeKeys = true
|
||||
}
|
||||
} catch (error) {
|
||||
logger.warn({ error, fromJid }, 'failed to check session recreation')
|
||||
}
|
||||
}
|
||||
// Derive the Signal error code from the actual decryption failure message.
|
||||
// Sent in the retry receipt so the peer (even another InfiniteAPI instance)
|
||||
// knows the exact failure type and can recreate the session immediately
|
||||
// instead of falling back to the 1-hour timeout.
|
||||
//
|
||||
// Codes mirror RetryReason enum in message-retry-manager.ts:
|
||||
// 0 = UnknownError | 1 = NoSession | 2 = InvalidKey
|
||||
// 3 = InvalidKeyId | 4 = InvalidMessage | 7 = BadMac
|
||||
//
|
||||
// Uses DECRYPTION_RETRY_CONFIG error lists (single source of truth in
|
||||
// decode-wa-message.ts) so additions to those lists are picked up here
|
||||
// automatically.
|
||||
//
|
||||
// NOTE: We do NOT delete the session here (receiver side). The Signal Protocol
|
||||
// recovers automatically when the sender's pkmsg arrives — it overwrites the
|
||||
// corrupted session. Deleting prematurely creates a race window where no session
|
||||
// exists, which can cause "No Session" errors on concurrent messages.
|
||||
const retryErrorCode = (() => {
|
||||
if (!decryptionError) return RetryReason.UnknownError
|
||||
// Bad MAC must be checked first — it is also in corruptedSessionErrors
|
||||
// but warrants the more specific code 7 over the generic code 4.
|
||||
if (decryptionError.includes(BAD_MAC_ERROR_TEXT)) return RetryReason.SignalErrorBadMac
|
||||
// MessageCounterError and other corrupted-session variants
|
||||
if (DECRYPTION_RETRY_CONFIG.corruptedSessionErrors.some(e => decryptionError.includes(e))) return RetryReason.SignalErrorInvalidMessage
|
||||
// Missing / invalid session record
|
||||
if (DECRYPTION_RETRY_CONFIG.sessionRecordErrors.some(e => decryptionError.includes(e)) ||
|
||||
/no\s+(open\s+)?sessions?/i.test(decryptionError)) return RetryReason.SignalErrorNoSession
|
||||
// PreKey / key-id errors
|
||||
if (/pre\s*key/i.test(decryptionError)) return RetryReason.SignalErrorInvalidKeyId
|
||||
// Identity / key errors
|
||||
if (/invalid\s*key|untrusted\s*identity/i.test(decryptionError)) return RetryReason.SignalErrorInvalidKey
|
||||
return RetryReason.UnknownError
|
||||
})()
|
||||
|
||||
if (retryCount <= 2) {
|
||||
// Use new retry manager for phone requests if available
|
||||
@@ -1383,8 +1387,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
id: node.attrs.id!,
|
||||
t: node.attrs.t!,
|
||||
v: '1',
|
||||
// ADD ERROR FIELD
|
||||
error: '0'
|
||||
error: retryErrorCode.toString()
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -1403,7 +1406,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
receipt.attrs.participant = node.attrs.participant
|
||||
}
|
||||
|
||||
if (retryCount > 1 || forceIncludeKeys || shouldRecreateSession) {
|
||||
if (retryCount > 1 || forceIncludeKeys) {
|
||||
const { update, preKeys } = await getNextPreKeys(authState, 1)
|
||||
|
||||
const [keyId] = Object.keys(preKeys)
|
||||
@@ -1440,7 +1443,8 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
|
||||
logger.debug({ count, shouldUploadMorePreKeys }, 'recv pre-key count')
|
||||
if (shouldUploadMorePreKeys) {
|
||||
await uploadPreKeys()
|
||||
// Top-up back to INITIAL_PREKEY_COUNT so the pool is always restored to full size
|
||||
await uploadPreKeys(Math.max(1, INITIAL_PREKEY_COUNT - count))
|
||||
}
|
||||
} else {
|
||||
const result = await handleIdentityChange(node, {
|
||||
@@ -2247,10 +2251,16 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
}
|
||||
|
||||
const encNode = getBinaryNodeChild(node, 'enc')
|
||||
// TODO: temporary fix for crashes and issues resulting of failed msmsg decryption
|
||||
if (encNode?.attrs.type === 'msmsg') {
|
||||
logger.debug({ key: node.attrs.key }, 'ignored msmsg')
|
||||
await sendMessageAck(node, NACK_REASONS.MissingMessageSecret)
|
||||
// msmsg block removed — allow msmsg decryption (required for view-once on linked devices)
|
||||
|
||||
// Handle view-once unavailable sync from primary device.
|
||||
// When the primary device sends a view-once, linked companions receive
|
||||
// <unavailable type="view_once"/> — no enc content, just a sync signal.
|
||||
// Acknowledge and skip decryption (nothing to decrypt).
|
||||
const unavailableNode = getBinaryNodeChild(node, 'unavailable')
|
||||
if (unavailableNode?.attrs?.type === 'view_once') {
|
||||
logger.debug({ id: node.attrs.id, from: node.attrs.from }, 'received view_once unavailable sync from primary device')
|
||||
await sendMessageAck(node)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2367,6 +2377,15 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
{ msgId: msg.key?.id, messageType },
|
||||
'CTWA: Skipping placeholder resend for unavailable fanout type'
|
||||
)
|
||||
// For view-once: emit the message as a stub so consumers know it arrived.
|
||||
// Use 'notify' for live messages so realtime consumers get the event.
|
||||
if (messageType === 'view_once_unavailable_fanout') {
|
||||
msg.key.isViewOnce = true
|
||||
msg.messageStubType = proto.WebMessageInfo.StubType.CIPHERTEXT
|
||||
msg.messageStubParameters = ['view_once_unavailable']
|
||||
const upsertType = node.attrs.offline ? 'append' : 'notify'
|
||||
await upsertMessage(msg, upsertType)
|
||||
}
|
||||
metrics.ctwaRecoveryFailures.inc({ reason: 'unavailable_fanout' })
|
||||
return sendMessageAck(node)
|
||||
}
|
||||
@@ -2505,7 +2524,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
}
|
||||
|
||||
const encNode = getBinaryNodeChild(node, 'enc')
|
||||
await sendRetryRequest(node, !encNode)
|
||||
await sendRetryRequest(node, !encNode, errorMessage)
|
||||
if (retryRequestDelayMs) {
|
||||
await delay(retryRequestDelayMs)
|
||||
}
|
||||
@@ -2514,7 +2533,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
// Still attempt retry even if pre-key upload failed
|
||||
try {
|
||||
const encNode = getBinaryNodeChild(node, 'enc')
|
||||
await sendRetryRequest(node, !encNode)
|
||||
await sendRetryRequest(node, !encNode, errorMessage)
|
||||
} catch (retryErr) {
|
||||
logger.error({ retryErr }, 'Failed to send retry after error handling')
|
||||
}
|
||||
@@ -2548,6 +2567,11 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
|
||||
await sendReceipt(msg.key.remoteJid!, participant!, [msg.key.id!], type)
|
||||
|
||||
// NOTE: do NOT send view_once_read from a linked device (API).
|
||||
// WA shows view-once as view_once_unavailable_fanout on linked devices — only the
|
||||
// primary phone sends view_once_read when the user actually opens it.
|
||||
// Sending it from a linked device causes WA to flag the account and disables view-once.
|
||||
|
||||
// send ack for history message
|
||||
const isAnyHistoryMsg = getHistoryMsg(msg.message!)
|
||||
if (isAnyHistoryMsg) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import type {
|
||||
AlbumMessageOptions,
|
||||
AlbumSendResult,
|
||||
AnyMessageContent,
|
||||
LIDMapping,
|
||||
MediaConnInfo,
|
||||
MessageReceiptType,
|
||||
MessageRelayOptions,
|
||||
@@ -338,6 +339,33 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
}
|
||||
}
|
||||
|
||||
// 4th LID→PN source: device-list entries sharing the same raw_id
|
||||
// WA Business uses this for accounts where HistorySync sends zero phoneNumberToLidMappings
|
||||
const allEntries = [...result.list, ...result.sideList]
|
||||
const rawIdMap = new Map<number, { pn?: string; lid?: string }>()
|
||||
for (const item of allEntries) {
|
||||
if (typeof item.rawId !== 'number' || isNaN(item.rawId)) continue
|
||||
const decoded = jidDecode(item.id)
|
||||
if (!decoded) continue
|
||||
const entry = rawIdMap.get(item.rawId) || {}
|
||||
if (decoded.server === 'lid' || decoded.server === 'hosted.lid') {
|
||||
entry.lid = item.id
|
||||
} else if (decoded.server === 's.whatsapp.net' || decoded.server === 'c.us') {
|
||||
entry.pn = item.id
|
||||
}
|
||||
rawIdMap.set(item.rawId, entry)
|
||||
}
|
||||
const rawIdMappings: LIDMapping[] = []
|
||||
for (const { pn, lid } of rawIdMap.values()) {
|
||||
if (pn && lid) {
|
||||
rawIdMappings.push({ lid: jidNormalizedUser(lid), pn: jidNormalizedUser(pn) })
|
||||
}
|
||||
}
|
||||
if (rawIdMappings.length > 0) {
|
||||
await signalRepository.lidMapping.storeLIDPNMappings(rawIdMappings)
|
||||
logger.debug({ count: rawIdMappings.length }, 'stored LID-PN mappings from raw_id pairing')
|
||||
}
|
||||
|
||||
const meId = authState.creds.me?.id
|
||||
if (!meId) throw new Boom('Not authenticated', { statusCode: 401 })
|
||||
const meLid = authState.creds.me?.lid || ''
|
||||
@@ -1013,7 +1041,8 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
}
|
||||
|
||||
await authState.keys.transaction(async () => {
|
||||
const mediaType = getMediaType(message)
|
||||
// normalizeMessageContent unwraps viewOnceMessage/viewOnceMessageV2 so getMediaType works correctly
|
||||
const mediaType = getMediaType(normalizeMessageContent(message) || message)
|
||||
if (mediaType) {
|
||||
extraAttrs['mediatype'] = mediaType
|
||||
}
|
||||
@@ -1023,7 +1052,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
const bytes = encodeNewsletterMessage(patched as proto.IMessage)
|
||||
binaryNodeContent.push({
|
||||
tag: 'plaintext',
|
||||
attrs: {},
|
||||
attrs: mediaType ? { mediatype: mediaType } : {},
|
||||
content: bytes
|
||||
})
|
||||
const stanza: BinaryNode = {
|
||||
@@ -1045,6 +1074,8 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
extraAttrs['decrypt-fail'] = 'hide' // todo: expand for reactions and other types
|
||||
}
|
||||
|
||||
// view_once_write disabled — causes server to drop message (validation fails for linked device sessions)
|
||||
|
||||
if (isGroupOrStatus && !isRetryResend) {
|
||||
const [groupData, senderKeyMap] = await Promise.all([
|
||||
(async () => {
|
||||
@@ -1249,21 +1280,48 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
: otherRecipients
|
||||
const effectiveAllRecipients = [...effectiveMeRecipients, ...effectiveOtherRecipients]
|
||||
|
||||
await assertSessions(effectiveAllRecipients)
|
||||
// P2: detect actual view-once media by checking inner message's viewOnce flag.
|
||||
// viewOnceMessage wrapper is also used for interactive messages (buttons, lists, etc)
|
||||
// which do NOT carry viewOnce=true on the media — those must NOT be filtered.
|
||||
const viewOnceInner =
|
||||
message.viewOnceMessageV2?.message ||
|
||||
message.viewOnceMessage?.message ||
|
||||
message.viewOnceMessageV2Extension?.message
|
||||
const isViewOnceMsg = !!(
|
||||
viewOnceInner?.imageMessage?.viewOnce ||
|
||||
viewOnceInner?.videoMessage?.viewOnce ||
|
||||
viewOnceInner?.audioMessage?.viewOnce
|
||||
)
|
||||
|
||||
// For view-once: only send DSM to primary phone (device=0).
|
||||
// Companion devices (device>0) are omitted — WA server generates
|
||||
// <unavailable type="view_once"/> for them automatically.
|
||||
// Sending explicit <unavailable> from a companion is rejected by the server.
|
||||
const viewOnceMeRecipients = isViewOnceMsg
|
||||
? effectiveMeRecipients.filter(jid => !jidDecode(jid)?.device)
|
||||
: effectiveMeRecipients
|
||||
|
||||
// P3: assert sessions only for recipients we actually encrypt for.
|
||||
// For view-once, companions are omitted — asserting their sessions is wasteful
|
||||
// and could block the send if a companion session is corrupted.
|
||||
await assertSessions([...viewOnceMeRecipients, ...effectiveOtherRecipients])
|
||||
|
||||
const [
|
||||
{ nodes: meNodes, shouldIncludeDeviceIdentity: s1 },
|
||||
{ nodes: otherNodes, shouldIncludeDeviceIdentity: s2 }
|
||||
] = await Promise.all([
|
||||
// For own devices: use DSM (deviceSentMessage) wrapper
|
||||
createParticipantNodes(effectiveMeRecipients, meMsg || message, extraAttrs),
|
||||
createParticipantNodes(viewOnceMeRecipients, meMsg || message, extraAttrs),
|
||||
createParticipantNodes(effectiveOtherRecipients, message, extraAttrs)
|
||||
])
|
||||
participants.push(...meNodes)
|
||||
participants.push(...otherNodes)
|
||||
|
||||
if (effectiveMeRecipients.length > 0 || effectiveOtherRecipients.length > 0) {
|
||||
extraAttrs['phash'] = generateParticipantHashV2(effectiveAllRecipients)
|
||||
// phash: para view-once inclui só celular principal + destinatários
|
||||
const phashRecipients = isViewOnceMsg
|
||||
? [...viewOnceMeRecipients, ...effectiveOtherRecipients]
|
||||
: effectiveAllRecipients
|
||||
if (phashRecipients.length > 0) {
|
||||
extraAttrs['phash'] = generateParticipantHashV2(phashRecipients)
|
||||
}
|
||||
|
||||
shouldIncludeDeviceIdentity = shouldIncludeDeviceIdentity || s1 || s2
|
||||
@@ -1869,6 +1927,15 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
}
|
||||
|
||||
const getMediaType = (message: proto.IMessage) => {
|
||||
// For view-once media, unwrap the viewOnceMessage wrapper before checking media type
|
||||
const inner =
|
||||
message.viewOnceMessage?.message ||
|
||||
message.viewOnceMessageV2?.message ||
|
||||
message.viewOnceMessageV2Extension?.message
|
||||
if (inner) {
|
||||
return getMediaType(inner)
|
||||
}
|
||||
|
||||
if (message.imageMessage) {
|
||||
return 'image'
|
||||
} else if (message.videoMessage) {
|
||||
|
||||
@@ -123,11 +123,11 @@ export const makeNewsletterSocket = (config: SocketConfig) => {
|
||||
},
|
||||
|
||||
newsletterMute: (jid: string) => {
|
||||
return executeWMexQuery({ newsletter_id: jid }, QueryIds.MUTE, XWAPaths.xwa2_newsletter_mute_v2)
|
||||
return executeWMexQuery({ input: { newsletter_id: jid, type: 'MUTE_ADMIN_ACTIVITY', value: 'OFF' } }, QueryIds.MUTE, XWAPaths.xwa2_newsletter_mute_v2)
|
||||
},
|
||||
|
||||
newsletterUnmute: (jid: string) => {
|
||||
return executeWMexQuery({ newsletter_id: jid }, QueryIds.UNMUTE, XWAPaths.xwa2_newsletter_unmute_v2)
|
||||
return executeWMexQuery({ input: { newsletter_id: jid, type: 'MUTE_ADMIN_ACTIVITY', value: 'ON' } }, QueryIds.UNMUTE, XWAPaths.xwa2_newsletter_unmute_v2)
|
||||
},
|
||||
|
||||
newsletterUpdateName: async (jid: string, name: string) => {
|
||||
|
||||
+28
-8
@@ -701,10 +701,12 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Prevent multiple concurrent uploads
|
||||
// Prevent multiple concurrent uploads — if one is already running, wait for it and return:
|
||||
// the concurrent upload already replenished the pool, so there is nothing left to do.
|
||||
if (uploadPreKeysPromise) {
|
||||
logger.debug('Pre-key upload already in progress, waiting for completion')
|
||||
await uploadPreKeysPromise
|
||||
return
|
||||
}
|
||||
|
||||
const uploadLogic = async () => {
|
||||
@@ -784,14 +786,15 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
try {
|
||||
let count = 0
|
||||
const preKeyCount = await getAvailablePreKeysOnServer()
|
||||
if (preKeyCount === 0) count = INITIAL_PREKEY_COUNT
|
||||
else count = MIN_PREKEY_COUNT
|
||||
// How many to upload: top-up to INITIAL_PREKEY_COUNT from whatever remains on server
|
||||
count = Math.max(0, INITIAL_PREKEY_COUNT - preKeyCount)
|
||||
const { exists: currentPreKeyExists, currentPreKeyId } = await verifyCurrentPreKeyExists()
|
||||
|
||||
logger.info(`${preKeyCount} pre-keys found on server`)
|
||||
logger.info(`Current prekey ID: ${currentPreKeyId}, exists in storage: ${currentPreKeyExists}`)
|
||||
|
||||
const lowServerCount = preKeyCount <= count
|
||||
// Trigger upload when below the replenishment threshold, not when count < topUp amount
|
||||
const lowServerCount = preKeyCount < MIN_PREKEY_COUNT
|
||||
const missingCurrentPreKey = !currentPreKeyExists && currentPreKeyId > 0
|
||||
|
||||
const shouldUpload = lowServerCount || missingCurrentPreKey
|
||||
@@ -1151,7 +1154,7 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
// Decrement active connections
|
||||
decrementActiveConnections()
|
||||
|
||||
clearInterval(keepAliveReq)
|
||||
clearTimeout(keepAliveReq)
|
||||
clearTimeout(qrTimer)
|
||||
|
||||
// Clear offline-buffer safety timer so its callback cannot call ev.flush()
|
||||
@@ -1262,8 +1265,16 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
})
|
||||
}
|
||||
|
||||
const startKeepAliveRequest = () =>
|
||||
(keepAliveReq = setInterval(() => {
|
||||
const startKeepAliveRequest = () => {
|
||||
// Use recursive setTimeout with ±15% jitter to match WA Desktop behaviour
|
||||
// (WA Business Desktop: ~25-30s intervals with natural variance)
|
||||
const scheduleNextKeepAlive = () => {
|
||||
const jitter = keepAliveIntervalMs * 0.15
|
||||
const delay = keepAliveIntervalMs + Math.floor((Math.random() * 2 - 1) * jitter)
|
||||
keepAliveReq = setTimeout(onKeepAliveTick, delay)
|
||||
}
|
||||
|
||||
const onKeepAliveTick = () => {
|
||||
if (!lastDateRecv) {
|
||||
lastDateRecv = new Date()
|
||||
}
|
||||
@@ -1275,6 +1286,7 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
*/
|
||||
if (diff > keepAliveIntervalMs + 5000) {
|
||||
void end(new Boom('Connection was lost', { statusCode: DisconnectReason.connectionLost }))
|
||||
return // connection closing — do not reschedule
|
||||
} else if (ws.isOpen) {
|
||||
// Send keep-alive ping via sendNode() (fire-and-forget) instead of query().
|
||||
// query() wraps the ping in the query circuit breaker — when that breaker is
|
||||
@@ -1297,7 +1309,15 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
} else {
|
||||
logger.warn('keep alive called when WS not open')
|
||||
}
|
||||
}, keepAliveIntervalMs))
|
||||
|
||||
// Do not reschedule once shutdown has started (closed set by end() on any concurrent path)
|
||||
if (!closed) {
|
||||
scheduleNextKeepAlive()
|
||||
}
|
||||
}
|
||||
|
||||
scheduleNextKeepAlive()
|
||||
}
|
||||
/** i have no idea why this exists. pls enlighten me */
|
||||
const sendPassiveIq = (tag: 'passive' | 'active') =>
|
||||
query({
|
||||
|
||||
@@ -27,6 +27,8 @@ export type BaileysEventMap = {
|
||||
chats: Chat[]
|
||||
contacts: Contact[]
|
||||
messages: WAMessage[]
|
||||
/** Past participants for group chats (people who left/were removed). userJid is always a phone number (PN), never a LID. */
|
||||
pastParticipants?: proto.IPastParticipants[] | null
|
||||
isLatest?: boolean
|
||||
progress?: number | null
|
||||
syncType?: proto.HistorySync.HistorySyncType | null
|
||||
@@ -185,6 +187,8 @@ export type BufferedEventData = {
|
||||
chats: { [jid: string]: Chat }
|
||||
contacts: { [jid: string]: Contact }
|
||||
messages: { [uqId: string]: WAMessage }
|
||||
/** Keyed by groupJid for O(1) deduplication across chunks */
|
||||
pastParticipants: { [groupJid: string]: proto.IPastParticipant[] }
|
||||
empty: boolean
|
||||
isLatest: boolean
|
||||
progress?: number | null
|
||||
|
||||
+13
-2
@@ -155,6 +155,7 @@ export type MessageReceiptType =
|
||||
| 'sender'
|
||||
| 'inactive'
|
||||
| 'played'
|
||||
| 'view_once_read'
|
||||
| undefined
|
||||
|
||||
export type MediaConnInfo = {
|
||||
@@ -178,6 +179,8 @@ export interface WAUrlInfo {
|
||||
type Mentionable = {
|
||||
/** list of jids that are mentioned in the accompanying text */
|
||||
mentions?: string[]
|
||||
/** mention all participants in the group */
|
||||
mentionAll?: boolean
|
||||
}
|
||||
type Contextable = {
|
||||
/** add contextInfo to the message */
|
||||
@@ -990,8 +993,16 @@ export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions &
|
||||
|
||||
export type WAMediaUploadFunction = (
|
||||
encFilePath: string,
|
||||
opts: { fileEncSha256B64: string; mediaType: MediaType; timeoutMs?: number }
|
||||
) => Promise<{ mediaUrl: string; directPath: string; meta_hmac?: string; ts?: number; fbid?: number }>
|
||||
opts: { fileEncSha256B64: string; mediaType: MediaType; timeoutMs?: number; newsletter?: boolean }
|
||||
) => Promise<{
|
||||
mediaUrl: string | undefined
|
||||
directPath: string
|
||||
meta_hmac?: string
|
||||
ts?: number
|
||||
fbid?: number
|
||||
thumbnailDirectPath?: string
|
||||
thumbnailSha256?: string
|
||||
}>
|
||||
|
||||
export type MediaGenerationOptions = {
|
||||
logger?: ILogger
|
||||
|
||||
@@ -4,10 +4,10 @@ export enum XWAPaths {
|
||||
xwa2_newsletter_view = 'xwa2_newsletter_view',
|
||||
xwa2_newsletter_metadata = 'xwa2_newsletter',
|
||||
xwa2_newsletter_admin_count = 'xwa2_newsletter_admin',
|
||||
xwa2_newsletter_mute_v2 = 'xwa2_newsletter_mute_v2',
|
||||
xwa2_newsletter_unmute_v2 = 'xwa2_newsletter_unmute_v2',
|
||||
xwa2_newsletter_follow = 'xwa2_newsletter_follow',
|
||||
xwa2_newsletter_unfollow = 'xwa2_newsletter_unfollow',
|
||||
xwa2_newsletter_mute_v2 = 'xwa2_newsletter_update_user_setting',
|
||||
xwa2_newsletter_unmute_v2 = 'xwa2_newsletter_update_user_setting',
|
||||
xwa2_newsletter_follow = 'xwa2_newsletter_join_v2',
|
||||
xwa2_newsletter_unfollow = 'xwa2_newsletter_leave_v2',
|
||||
xwa2_newsletter_change_owner = 'xwa2_newsletter_change_owner',
|
||||
xwa2_newsletter_demote = 'xwa2_newsletter_demote',
|
||||
xwa2_newsletter_delete_v2 = 'xwa2_newsletter_delete_v2'
|
||||
@@ -17,10 +17,10 @@ export enum QueryIds {
|
||||
UPDATE_METADATA = '24250201037901610',
|
||||
METADATA = '6563316087068696',
|
||||
SUBSCRIBERS = '9783111038412085',
|
||||
FOLLOW = '7871414976211147',
|
||||
UNFOLLOW = '7238632346214362',
|
||||
MUTE = '29766401636284406',
|
||||
UNMUTE = '9864994326891137',
|
||||
FOLLOW = '24404358912487870',
|
||||
UNFOLLOW = '9767147403369991',
|
||||
MUTE = '31938993655691868',
|
||||
UNMUTE = '31938993655691868',
|
||||
ADMIN_COUNT = '7130823597031706',
|
||||
CHANGE_OWNER = '7341777602580933',
|
||||
DEMOTE = '6551828931592903',
|
||||
|
||||
@@ -392,6 +392,23 @@ export const decryptMessageNode = (
|
||||
} else {
|
||||
fullMessage.message = msg
|
||||
}
|
||||
|
||||
// Detect view-once media on stanza 1 received by linked device.
|
||||
// viewOnceMessage wrapper is also used for interactive messages
|
||||
// (interactiveMessage, listMessage, nativeFlowMessage) -- those do NOT have
|
||||
// imageMessage.viewOnce / videoMessage.viewOnce / audioMessage.viewOnce = true.
|
||||
// Only real view-once media carries viewOnce: true on the inner media message.
|
||||
const viewOnceInner =
|
||||
msg.viewOnceMessage?.message ||
|
||||
msg.viewOnceMessageV2?.message ||
|
||||
msg.viewOnceMessageV2Extension?.message
|
||||
if (
|
||||
viewOnceInner?.imageMessage?.viewOnce ||
|
||||
viewOnceInner?.videoMessage?.viewOnce ||
|
||||
viewOnceInner?.audioMessage?.viewOnce
|
||||
) {
|
||||
fullMessage.key.isViewOnce = true
|
||||
}
|
||||
} catch (err: any) {
|
||||
// Check if this is a final failure after all retries exhausted
|
||||
const isRetryExhausted = err instanceof RetryExhaustedError
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import EventEmitter from 'events'
|
||||
import { proto } from '../../WAProto/index.js'
|
||||
import type {
|
||||
BaileysEvent,
|
||||
BaileysEventEmitter,
|
||||
@@ -890,6 +891,7 @@ const makeBufferData = (): BufferedEventData => {
|
||||
chats: {},
|
||||
messages: {},
|
||||
contacts: {},
|
||||
pastParticipants: {},
|
||||
isLatest: false,
|
||||
empty: true
|
||||
},
|
||||
@@ -967,6 +969,28 @@ function append<E extends BufferableEvent>(
|
||||
}
|
||||
}
|
||||
|
||||
// Merge pastParticipants with deduplication by groupJid and by userJid within each group.
|
||||
// Multiple HistorySync chunks can carry the same group -- we merge rather than concatenate
|
||||
// to avoid duplicate entries in the final event delivered to the consumer.
|
||||
for (const group of (eventData.pastParticipants ?? []) as proto.IPastParticipants[]) {
|
||||
const groupJid = group.groupJid
|
||||
if (!groupJid) continue
|
||||
|
||||
if (!data.historySets.pastParticipants[groupJid]) {
|
||||
data.historySets.pastParticipants[groupJid] = []
|
||||
}
|
||||
|
||||
const existing = data.historySets.pastParticipants[groupJid]
|
||||
const seenJids = new Set(existing.map(p => p.userJid).filter(Boolean))
|
||||
|
||||
for (const participant of (group.pastParticipants ?? []) as proto.IPastParticipant[]) {
|
||||
if (participant.userJid && !seenJids.has(participant.userJid)) {
|
||||
existing.push(participant)
|
||||
seenJids.add(participant.userJid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data.historySets.empty = false
|
||||
data.historySets.syncType = eventData.syncType
|
||||
data.historySets.progress = eventData.progress
|
||||
@@ -1292,6 +1316,10 @@ function consolidateEvents(data: BufferedEventData) {
|
||||
chats: Object.values(data.historySets.chats),
|
||||
messages: Object.values(data.historySets.messages),
|
||||
contacts: Object.values(data.historySets.contacts),
|
||||
// Convert dedup map back to array. Each entry has groupJid + participants (all unique userJids).
|
||||
pastParticipants: Object.entries(data.historySets.pastParticipants).map(
|
||||
([groupJid, participants]) => ({ groupJid, pastParticipants: participants })
|
||||
),
|
||||
syncType: data.historySets.syncType,
|
||||
progress: data.historySets.progress,
|
||||
isLatest: data.historySets.isLatest,
|
||||
|
||||
+34
-2
@@ -15,7 +15,8 @@ import {
|
||||
import { toNumber } from './generics'
|
||||
import type { ILogger } from './logger.js'
|
||||
import { normalizeMessageContent } from './messages'
|
||||
import { downloadContentFromMessage } from './messages-media'
|
||||
import { DEFAULT_ORIGIN } from '../Defaults'
|
||||
import { downloadContentFromMessage, getUrlFromDirectPath } from './messages-media'
|
||||
|
||||
const inflatePromise = promisify(inflate)
|
||||
|
||||
@@ -374,10 +375,25 @@ export const processHistoryMessage = (item: proto.IHistorySync, logger?: ILogger
|
||||
// Convert Map back to array for return
|
||||
const lidPnMappings = Array.from(lidPnMap.values())
|
||||
|
||||
// Normalize pastParticipants: resolve LID userJids → PN so the consumer always
|
||||
// receives a phone number, never an opaque LID identifier.
|
||||
// Uses the lidPnMap built above (populated from phoneNumberToLidMappings + conversations).
|
||||
// If a LID cannot be resolved, the original value is kept rather than dropping the participant.
|
||||
const pastParticipants: proto.IPastParticipants[] = (item.pastParticipants ?? []).map(group => ({
|
||||
groupJid: group.groupJid,
|
||||
pastParticipants: (group.pastParticipants ?? []).map(participant => {
|
||||
const userJid = participant.userJid
|
||||
if (!userJid || !isAnyLidUser(userJid)) return participant
|
||||
const mapping = lidPnMap.get(jidNormalizedUser(userJid))
|
||||
return mapping?.pn ? { ...participant, userJid: mapping.pn } : participant
|
||||
})
|
||||
}))
|
||||
|
||||
return {
|
||||
chats,
|
||||
contacts,
|
||||
messages,
|
||||
pastParticipants,
|
||||
lidPnMappings,
|
||||
syncType: item.syncType,
|
||||
progress: item.progress
|
||||
@@ -408,7 +424,23 @@ export const downloadAndProcessHistorySyncNotification = async (
|
||||
historyMsg = await downloadHistory(msg, options)
|
||||
}
|
||||
|
||||
return processHistoryMessage(historyMsg, logger)
|
||||
const result = processHistoryMessage(historyMsg, logger)
|
||||
|
||||
// Mirror WA Desktop behaviour: DELETE the CDN blob only after processing succeeds.
|
||||
// Doing this earlier (e.g. inside downloadHistory) risks permanent history loss if
|
||||
// processing throws — the server copy would be gone and retry after reconnect would fail.
|
||||
if (msg.directPath) {
|
||||
const cdnUrl = getUrlFromDirectPath(msg.directPath)
|
||||
fetch(cdnUrl, {
|
||||
...options,
|
||||
method: 'DELETE',
|
||||
headers: { ...((options as RequestInit).headers ?? {}), Origin: DEFAULT_ORIGIN }
|
||||
}).catch(() => {
|
||||
// non-fatal — server will expire it anyway
|
||||
})
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,7 +10,13 @@ import { join } from 'path'
|
||||
import { Readable, Transform } from 'stream'
|
||||
import { URL } from 'url'
|
||||
import { proto } from '../../WAProto/index.js'
|
||||
import { DEFAULT_ORIGIN, MEDIA_HKDF_KEY_MAPPING, MEDIA_PATH_MAP, type MediaType } from '../Defaults'
|
||||
import {
|
||||
DEFAULT_ORIGIN,
|
||||
MEDIA_HKDF_KEY_MAPPING,
|
||||
MEDIA_PATH_MAP,
|
||||
type MediaType,
|
||||
NEWSLETTER_MEDIA_PATH_MAP
|
||||
} from '../Defaults'
|
||||
import type {
|
||||
BaileysEventMap,
|
||||
DownloadableMessage,
|
||||
@@ -681,6 +687,10 @@ type MediaUploadResult = {
|
||||
meta_hmac?: string
|
||||
ts?: number
|
||||
fbid?: number
|
||||
thumbnail_info?: {
|
||||
thumbnail_sha256?: string
|
||||
thumbnail_direct_path?: string
|
||||
}
|
||||
}
|
||||
|
||||
export type UploadParams = {
|
||||
@@ -825,11 +835,21 @@ export const getWAUploadToServer = (
|
||||
{ customUploadHosts, fetchAgent, logger, options }: SocketConfig,
|
||||
refreshMediaConn: (force: boolean) => Promise<MediaConnInfo>
|
||||
): WAMediaUploadFunction => {
|
||||
return async (filePath, { mediaType, fileEncSha256B64, timeoutMs }) => {
|
||||
return async (filePath, { mediaType, fileEncSha256B64, timeoutMs, newsletter }) => {
|
||||
// send a query JSON to obtain the url & auth token to upload our media
|
||||
let uploadInfo = await refreshMediaConn(false)
|
||||
|
||||
let urls: { mediaUrl: string; directPath: string; meta_hmac?: string; ts?: number; fbid?: number } | undefined
|
||||
let urls:
|
||||
| {
|
||||
mediaUrl: string
|
||||
directPath: string
|
||||
meta_hmac?: string
|
||||
ts?: number
|
||||
fbid?: number
|
||||
thumbnailDirectPath?: string
|
||||
thumbnailSha256?: string
|
||||
}
|
||||
| undefined
|
||||
const hosts = [...customUploadHosts, ...uploadInfo.hosts]
|
||||
|
||||
fileEncSha256B64 = encodeBase64EncodedStringForUpload(fileEncSha256B64)
|
||||
@@ -851,7 +871,11 @@ export const getWAUploadToServer = (
|
||||
logger.debug(`uploading to "${hostname}"`)
|
||||
|
||||
const auth = encodeURIComponent(uploadInfo.auth)
|
||||
const url = `https://${hostname}${MEDIA_PATH_MAP[mediaType]}/${fileEncSha256B64}?auth=${auth}&token=${fileEncSha256B64}`
|
||||
const mediaPath = (newsletter ? NEWSLETTER_MEDIA_PATH_MAP[mediaType] : undefined) || MEDIA_PATH_MAP[mediaType]
|
||||
let url = `https://${hostname}${mediaPath}/${fileEncSha256B64}?auth=${auth}&token=${fileEncSha256B64}`
|
||||
if (newsletter) {
|
||||
url += '&server_thumb_gen=1'
|
||||
}
|
||||
|
||||
let result: MediaUploadResult | undefined
|
||||
try {
|
||||
@@ -868,11 +892,13 @@ export const getWAUploadToServer = (
|
||||
|
||||
if (result?.url || result?.direct_path) {
|
||||
urls = {
|
||||
mediaUrl: result.url!,
|
||||
mediaUrl: result.url || result.direct_path!,
|
||||
directPath: result.direct_path!,
|
||||
meta_hmac: result.meta_hmac,
|
||||
fbid: result.fbid,
|
||||
ts: result.ts
|
||||
ts: result.ts,
|
||||
thumbnailDirectPath: result.thumbnail_info?.thumbnail_direct_path,
|
||||
thumbnailSha256: result.thumbnail_info?.thumbnail_sha256
|
||||
}
|
||||
break
|
||||
} else {
|
||||
|
||||
+45
-13
@@ -196,10 +196,11 @@ export const prepareWAMessageMedia = async (
|
||||
)
|
||||
|
||||
const fileSha256B64 = fileSha256.toString('base64')
|
||||
const { mediaUrl, directPath } = await options.upload(filePath, {
|
||||
const { directPath, thumbnailDirectPath, thumbnailSha256 } = await options.upload(filePath, {
|
||||
fileEncSha256B64: fileSha256B64,
|
||||
mediaType: mediaType,
|
||||
timeoutMs: options.mediaUploadTimeoutMs
|
||||
timeoutMs: options.mediaUploadTimeoutMs,
|
||||
newsletter: true
|
||||
})
|
||||
|
||||
await fs.unlink(filePath)
|
||||
@@ -207,10 +208,12 @@ export const prepareWAMessageMedia = async (
|
||||
const obj = WAProto.Message.fromObject({
|
||||
// todo: add more support here
|
||||
[`${mediaType}Message`]: (MessageTypeProto as any)[mediaType].fromObject({
|
||||
url: mediaUrl,
|
||||
// url intentionally omitted — newsletters use directPath only
|
||||
directPath,
|
||||
fileSha256,
|
||||
fileLength,
|
||||
thumbnailDirectPath,
|
||||
thumbnailSha256: thumbnailSha256 ? Buffer.from(thumbnailSha256, 'base64') : undefined,
|
||||
...uploadData,
|
||||
media: undefined
|
||||
})
|
||||
@@ -236,7 +239,7 @@ export const prepareWAMessageMedia = async (
|
||||
const requiresDurationComputation = mediaType === 'audio' && typeof uploadData.seconds === 'undefined'
|
||||
const requiresThumbnailComputation =
|
||||
(mediaType === 'image' || mediaType === 'video') && typeof uploadData['jpegThumbnail'] === 'undefined'
|
||||
const requiresWaveformProcessing = mediaType === 'audio' && uploadData.ptt === true
|
||||
const requiresWaveformProcessing = mediaType === 'audio' && uploadData.ptt === true && typeof uploadData.waveform === 'undefined'
|
||||
const requiresAudioBackground = options.backgroundColor && mediaType === 'audio' && uploadData.ptt === true
|
||||
const requiresOriginalForSomeProcessing = requiresDurationComputation || requiresThumbnailComputation
|
||||
const { mediaKey, encFilePath, originalFilePath, fileEncSha256, fileSha256, fileLength } = await encryptedStream(
|
||||
@@ -254,7 +257,9 @@ export const prepareWAMessageMedia = async (
|
||||
(async () => {
|
||||
const result = await options.upload(encFilePath, {
|
||||
fileEncSha256B64,
|
||||
mediaType,
|
||||
// Use mediaTypeOverride for upload path (e.g. 'viewonce-image' → /o1/mms/image)
|
||||
// Encryption already used the override via encryptedStream above
|
||||
mediaType: options.mediaTypeOverride || mediaType,
|
||||
timeoutMs: options.mediaUploadTimeoutMs
|
||||
})
|
||||
logger?.debug({ mediaType, cacheableKey }, 'uploaded media')
|
||||
@@ -292,7 +297,7 @@ export const prepareWAMessageMedia = async (
|
||||
logger?.debug('computed audio duration')
|
||||
}
|
||||
|
||||
if (requiresWaveformProcessing) {
|
||||
if (requiresWaveformProcessing && !uploadData.waveform) {
|
||||
uploadData.waveform = await getAudioWaveform(filePath, logger)
|
||||
logger?.debug('processed waveform')
|
||||
}
|
||||
@@ -1747,22 +1752,49 @@ export const generateWAMessageContent = async (
|
||||
}
|
||||
}
|
||||
} else {
|
||||
m = await prepareWAMessageMedia(message, options)
|
||||
// For view-once media, upload to the one-time CDN (/o1/mms/*) instead of regular CDN
|
||||
// WA Web view-once messages always have directPath: /o1/v/t24/... (not /v/t62.7118-24/...)
|
||||
// Using the wrong CDN causes WA server to flag the account and breaks view-once capability
|
||||
const isViewOnce = hasOptionalProperty(message, 'viewOnce') && !!message.viewOnce
|
||||
const viewOnceTypeMap: Record<string, string> = {
|
||||
image: 'viewonce-image',
|
||||
video: 'viewonce-video',
|
||||
audio: 'viewonce-audio'
|
||||
}
|
||||
const viewOnceOverride = isViewOnce
|
||||
? viewOnceTypeMap[Object.keys(message).find(k => k in viewOnceTypeMap) || '']
|
||||
: undefined
|
||||
m = await prepareWAMessageMedia(message, {
|
||||
...options,
|
||||
mediaTypeOverride: (viewOnceOverride as any) || options.mediaTypeOverride
|
||||
})
|
||||
}
|
||||
|
||||
if (hasOptionalProperty(message, 'viewOnce') && !!message.viewOnce) {
|
||||
m = { viewOnceMessage: { message: m } }
|
||||
// Also set viewOnce=true on the inner media message (required by WA app to render as view-once)
|
||||
if (m.imageMessage) m.imageMessage.viewOnce = true
|
||||
else if (m.videoMessage) m.videoMessage.viewOnce = true
|
||||
else if (m.audioMessage) m.audioMessage.viewOnce = true
|
||||
// Use viewOnceMessageV2 (field 55) — modern WA clients use this wrapper
|
||||
// viewOnceMessage (field 37) is the old format which WA server no longer accepts with view_once_write
|
||||
m = { viewOnceMessageV2: { message: m } }
|
||||
}
|
||||
|
||||
if (hasOptionalProperty(message, 'mentions') && message.mentions?.length) {
|
||||
if (
|
||||
(hasOptionalProperty(message, 'mentions') && message.mentions?.length) ||
|
||||
(hasOptionalProperty(message, 'mentionAll') && message.mentionAll)
|
||||
) {
|
||||
const messageType = Object.keys(m)[0] as Extract<keyof proto.IMessage, MessageWithContextInfo>
|
||||
if (messageType) {
|
||||
const key = m[messageType]
|
||||
if (key && 'contextInfo' in key && !!key.contextInfo) {
|
||||
if (key && 'contextInfo' in key) {
|
||||
key.contextInfo = key.contextInfo || {}
|
||||
if (message.mentions?.length) {
|
||||
key.contextInfo.mentionedJid = message.mentions
|
||||
} else if (key) {
|
||||
key.contextInfo = {
|
||||
mentionedJid: message.mentions
|
||||
}
|
||||
|
||||
if (message.mentionAll) {
|
||||
key.contextInfo.nonJidMentions = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from './Protocols'
|
||||
import { USyncUser } from './USyncUser'
|
||||
|
||||
export type USyncQueryResultList = { [protocol: string]: unknown; id: string }
|
||||
export type USyncQueryResultList = { [protocol: string]: unknown; id: string; rawId?: number }
|
||||
|
||||
export type USyncQueryResult = {
|
||||
list: USyncQueryResultList[]
|
||||
@@ -68,10 +68,8 @@ export class USyncQuery {
|
||||
//TODO: see if there are any errors in the result node
|
||||
//const resultNode = getBinaryNodeChild(usyncNode, 'result')
|
||||
|
||||
const listNode = usyncNode ? getBinaryNodeChild(usyncNode, 'list') : undefined
|
||||
|
||||
if (listNode?.content && Array.isArray(listNode.content)) {
|
||||
queryResult.list = listNode.content.reduce((acc: USyncQueryResultList[], node) => {
|
||||
const parseNodeList = (content: BinaryNode[]): USyncQueryResultList[] =>
|
||||
content.reduce((acc: USyncQueryResultList[], node) => {
|
||||
const id = node?.attrs.jid
|
||||
if (id) {
|
||||
const data = Array.isArray(node?.content)
|
||||
@@ -89,15 +87,24 @@ export class USyncQuery {
|
||||
.filter(([, b]) => b !== null) as [string, unknown][]
|
||||
)
|
||||
: {}
|
||||
acc.push({ ...data, id })
|
||||
const rawIdAttr = node?.attrs?.['raw_id']
|
||||
const rawId = rawIdAttr !== undefined ? Number(rawIdAttr) : undefined
|
||||
acc.push({ ...data, id, ...(rawId !== undefined && !isNaN(rawId) ? { rawId } : {}) })
|
||||
}
|
||||
|
||||
return acc
|
||||
}, [])
|
||||
|
||||
const listNode = usyncNode ? getBinaryNodeChild(usyncNode, 'list') : undefined
|
||||
if (listNode?.content && Array.isArray(listNode.content)) {
|
||||
queryResult.list = parseNodeList(listNode.content)
|
||||
}
|
||||
|
||||
const sideListNode = usyncNode ? getBinaryNodeChild(usyncNode, 'side_list') : undefined
|
||||
if (sideListNode?.content && Array.isArray(sideListNode.content)) {
|
||||
queryResult.sideList = parseNodeList(sideListNode.content)
|
||||
}
|
||||
|
||||
//TODO: implement side list
|
||||
//const sideListNode = getBinaryNodeChild(usyncNode, 'side_list')
|
||||
return queryResult
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user