Feat: Block messages from unknown numbers (#1071)

* Update Chat.ts

* Update chats.ts

* lint

* lint

* lint
This commit is contained in:
Bob
2025-03-01 13:20:22 -03:00
committed by GitHub
parent fdce228798
commit 1d88166613
2 changed files with 8 additions and 1 deletions

View File

@@ -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,

View File

@@ -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'