Skip to content

Commit

Permalink
Feat: Block messages from unknown numbers (#1071)
Browse files Browse the repository at this point in the history
* Update Chat.ts

* Update chats.ts

* lint

* lint

* lint
  • Loading branch information
bobslavtriev authored Mar 1, 2025
1 parent fdce228 commit 1d88166
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Socket/chats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -993,6 +997,7 @@ export const makeChatsSocket = (config: SocketConfig) => {
updateProfileName,
updateBlockStatus,
updateCallPrivacy,
updateMessagesPrivacy,
updateLastSeenPrivacy,
updateOnlinePrivacy,
updateProfilePicturePrivacy,
Expand Down
2 changes: 2 additions & 0 deletions src/Types/Chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down

0 comments on commit 1d88166

Please sign in to comment.