From d396a03e65449cb1f4fbab317f6127e66fad6c98 Mon Sep 17 00:00:00 2001 From: Bob <115008575+bobslavtriev@users.noreply.github.com> Date: Wed, 3 Jul 2024 04:34:27 -0300 Subject: [PATCH] Feat: Mute unknown calls (privacy) (#872) * Update Chat.ts * Update chats.ts * export * fix sort --- src/Socket/chats.ts | 7 ++++++- src/Types/Chat.ts | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Socket/chats.ts b/src/Socket/chats.ts index cbfe361..6eb14d7 100644 --- a/src/Socket/chats.ts +++ b/src/Socket/chats.ts @@ -1,7 +1,7 @@ import { Boom } from '@hapi/boom' import { proto } from '../../WAProto' import { PROCESSABLE_HISTORY_TYPES } from '../Defaults' -import { ALL_WA_PATCH_NAMES, ChatModification, ChatMutation, LTHashState, MessageUpsertType, PresenceData, SocketConfig, WABusinessHoursConfig, WABusinessProfile, WAMediaUpload, WAMessage, WAPatchCreate, WAPatchName, WAPresence, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types' +import { ALL_WA_PATCH_NAMES, ChatModification, ChatMutation, LTHashState, MessageUpsertType, PresenceData, SocketConfig, WABusinessHoursConfig, WABusinessProfile, WAMediaUpload, WAMessage, WAPatchCreate, WAPatchName, WAPresence, WAPrivacyCallValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types' import { chatModificationToAppPatch, ChatMutationMap, decodePatches, decodeSyncdSnapshot, encodeSyncdPatch, extractSyncdPatches, generateProfilePicture, getHistoryMsg, newLTHashState, processSyncAction } from '../Utils' import { makeMutex } from '../Utils/make-mutex' import processMessage from '../Utils/process-message' @@ -83,6 +83,10 @@ export const makeChatsSocket = (config: SocketConfig) => { }) } + const updateCallPrivacy = async(value: WAPrivacyCallValue) => { + await privacyQuery('calladd', value) + } + const updateLastSeenPrivacy = async(value: WAPrivacyValue) => { await privacyQuery('last', value) } @@ -976,6 +980,7 @@ export const makeChatsSocket = (config: SocketConfig) => { updateProfileStatus, updateProfileName, updateBlockStatus, + updateCallPrivacy, updateLastSeenPrivacy, updateOnlinePrivacy, updateProfilePicturePrivacy, diff --git a/src/Types/Chat.ts b/src/Types/Chat.ts index 4077da8..2f7058f 100644 --- a/src/Types/Chat.ts +++ b/src/Types/Chat.ts @@ -12,6 +12,8 @@ export type WAPrivacyOnlineValue = 'all' | 'match_last_seen' export type WAReadReceiptsValue = 'all' | 'none' +export type WAPrivacyCallValue = 'all' | 'known' + /** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */ export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused' @@ -103,4 +105,4 @@ export type InitialReceivedChatsState = { export type InitialAppStateSyncOptions = { accountSettings: AccountSettings -} \ No newline at end of file +}