From aba3ecf9693dc4caa31151b3553778cdbedd77cb Mon Sep 17 00:00:00 2001 From: vini Date: Wed, 6 Aug 2025 19:50:24 -0300 Subject: [PATCH] feat: add enable/disable link preview privacy (#1675) --- src/Socket/chats.ts | 13 +++++++++++++ src/Types/Chat.ts | 1 + src/Utils/chat-utils.ts | 10 ++++++++++ 3 files changed, 24 insertions(+) diff --git a/src/Socket/chats.ts b/src/Socket/chats.ts index 3b03f86e..b1ebb55c 100644 --- a/src/Socket/chats.ts +++ b/src/Socket/chats.ts @@ -852,6 +852,18 @@ export const makeChatsSocket = (config: SocketConfig) => { return appPatch(patch) } + /** + * Enable/Disable link preview privacy, not related to baileys link preview generation + */ + const updateDisableLinkPreviewsPrivacy = (isPreviewsDisabled: boolean) => { + return chatModify( + { + disableLinkPreviews: { isPreviewsDisabled } + }, + '' + ) + } + /** * Star or Unstar a message */ @@ -1144,6 +1156,7 @@ export const makeChatsSocket = (config: SocketConfig) => { updateProfileStatus, updateProfileName, updateBlockStatus, + updateDisableLinkPreviewsPrivacy, updateCallPrivacy, updateMessagesPrivacy, updateLastSeenPrivacy, diff --git a/src/Types/Chat.ts b/src/Types/Chat.ts index 63f50d5a..9b47fa2b 100644 --- a/src/Types/Chat.ts +++ b/src/Types/Chat.ts @@ -111,6 +111,7 @@ export type ChatModification = } | { delete: true; lastMessages: LastMessageList } | { contact: proto.SyncActionValue.IContactAction | null } + | { disableLinkPreviews: proto.SyncActionValue.IPrivacySettingDisableLinkPreviewsAction } // Label | { addLabel: LabelActionBody } // Label assosiation diff --git a/src/Utils/chat-utils.ts b/src/Utils/chat-utils.ts index 3b482a20..e51abd58 100644 --- a/src/Utils/chat-utils.ts +++ b/src/Utils/chat-utils.ts @@ -619,6 +619,16 @@ export const chatModificationToAppPatch = (mod: ChatModification, jid: string) = apiVersion: 2, operation: mod.contact ? OP.SET : OP.REMOVE } + } else if ('disableLinkPreviews' in mod) { + patch = { + syncAction: { + privacySettingDisableLinkPreviewsAction: mod.disableLinkPreviews || {} + }, + index: ['setting_disableLinkPreviews'], + type: 'regular', + apiVersion: 8, + operation: OP.SET + } } else if ('star' in mod) { const key = mod.star.messages[0]! patch = {