diff --git a/README.md b/README.md index 06930d6..02ee08d 100644 --- a/README.md +++ b/README.md @@ -695,6 +695,11 @@ await sock.sendMessage( const status = 'Hello World!' await sock.updateProfileStatus(status) ``` +- To change your profile name + ``` ts + const name = 'My name' + await sock.updateProfileName(name) + ``` - To get the display picture of some person/group ``` ts // for low res picture diff --git a/src/Socket/chats.ts b/src/Socket/chats.ts index bb85708..804a0eb 100644 --- a/src/Socket/chats.ts +++ b/src/Socket/chats.ts @@ -192,6 +192,10 @@ export const makeChatsSocket = (config: SocketConfig) => { }) } + const updateProfileName = async(name: string) => { + await chatModify({ pushNameSetting: name }, '') + } + const fetchBlocklist = async() => { const result = await query({ tag: 'iq', @@ -786,6 +790,7 @@ export const makeChatsSocket = (config: SocketConfig) => { fetchStatus, updateProfilePicture, updateProfileStatus, + updateProfileName, updateBlockStatus, getBusinessProfile, resyncAppState, diff --git a/src/Types/Chat.ts b/src/Types/Chat.ts index def05c1..e963b26 100644 --- a/src/Types/Chat.ts +++ b/src/Types/Chat.ts @@ -52,6 +52,9 @@ export type ChatModification = archive: boolean lastMessages: LastMessageList } | + { + pushNameSetting: string + } | { pin: boolean } | diff --git a/src/Utils/chat-utils.ts b/src/Utils/chat-utils.ts index 68dd142..52eb756 100644 --- a/src/Utils/chat-utils.ts +++ b/src/Utils/chat-utils.ts @@ -578,6 +578,18 @@ export const chatModificationToAppPatch = ( apiVersion: 6, operation: OP.SET } + } else if('pushNameSetting' in mod) { + patch = { + syncAction: { + pushNameSetting: { + name: mod.pushNameSetting + } + }, + index: ['setting_pushName'], + type: 'critical_block', + apiVersion: 1, + operation: OP.SET, + } } else { throw new Boom('not supported') }