From 1d88166613500bef13186a7c9bd234f98a7bfd16 Mon Sep 17 00:00:00 2001 From: Bob <115008575+bobslavtriev@users.noreply.github.com> Date: Sat, 1 Mar 2025 13:20:22 -0300 Subject: [PATCH] Feat: Block messages from unknown numbers (#1071) * Update Chat.ts * Update chats.ts * lint * lint * lint --- src/Socket/chats.ts | 7 ++++++- src/Types/Chat.ts | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Socket/chats.ts b/src/Socket/chats.ts index 09229d3..2ebc51a 100644 --- a/src/Socket/chats.ts +++ b/src/Socket/chats.ts @@ -2,7 +2,7 @@ import { Boom } from '@hapi/boom' import NodeCache from '@cacheable/node-cache' import { proto } from '../../WAProto' import { DEFAULT_CACHE_TTLS, PROCESSABLE_HISTORY_TYPES } from '../Defaults' -import { ALL_WA_PATCH_NAMES, ChatModification, ChatMutation, LTHashState, MessageUpsertType, PresenceData, SocketConfig, WABusinessHoursConfig, WABusinessProfile, WAMediaUpload, WAMessage, WAPatchCreate, WAPatchName, WAPresence, WAPrivacyCallValue, WAPrivacyGroupAddValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types' +import { ALL_WA_PATCH_NAMES, ChatModification, ChatMutation, LTHashState, MessageUpsertType, PresenceData, SocketConfig, WABusinessHoursConfig, WABusinessProfile, WAMediaUpload, WAMessage, WAPatchCreate, WAPatchName, WAPresence, WAPrivacyCallValue, WAPrivacyGroupAddValue, WAPrivacyMessagesValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types' import { LabelActionBody } from '../Types/Label' import { chatModificationToAppPatch, ChatMutationMap, decodePatches, decodeSyncdSnapshot, encodeSyncdPatch, extractSyncdPatches, generateProfilePicture, getHistoryMsg, newLTHashState, processSyncAction } from '../Utils' import { makeMutex } from '../Utils/make-mutex' @@ -95,6 +95,10 @@ export const makeChatsSocket = (config: SocketConfig) => { }) } + const updateMessagesPrivacy = async(value: WAPrivacyMessagesValue) => { + await privacyQuery('messages', value) + } + const updateCallPrivacy = async(value: WAPrivacyCallValue) => { await privacyQuery('calladd', value) } @@ -993,6 +997,7 @@ export const makeChatsSocket = (config: SocketConfig) => { updateProfileName, updateBlockStatus, updateCallPrivacy, + updateMessagesPrivacy, updateLastSeenPrivacy, updateOnlinePrivacy, updateProfilePicturePrivacy, diff --git a/src/Types/Chat.ts b/src/Types/Chat.ts index 5801889..32b8af0 100644 --- a/src/Types/Chat.ts +++ b/src/Types/Chat.ts @@ -17,6 +17,8 @@ export type WAReadReceiptsValue = 'all' | 'none' export type WAPrivacyCallValue = 'all' | 'known' +export type WAPrivacyMessagesValue = 'all' | 'contacts' + /** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */ export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused'