update profile pic in legacy version (#1611)

Co-authored-by: Henrique <qplok02@gmail.com>
This commit is contained in:
P
2022-05-23 04:55:31 -03:00
committed by GitHub
parent 4c95f8f0c5
commit 44834d29fa

View File

@@ -1,6 +1,7 @@
import { BaileysEventMap, Chat, ChatModification, Contact, LastMessageList, LegacySocketConfig, PresenceData, WABusinessProfile, WAFlag, WAMessageKey, WAMessageUpdate, WAMetric, WAPresence } from '../Types'
import { debouncedTimeout, unixTimestampSeconds } from '../Utils/generics'
import { BinaryNode, jidNormalizedUser } from '../WABinary'
import { generateProfilePicture } from '../Utils'
import makeAuthSocket from './auth'
const makeChatsSocket = (config: LegacySocketConfig) => {
@@ -474,16 +475,17 @@ const makeChatsSocket = (config: LegacySocketConfig) => {
* @param jid
* @param img
*/
async updateProfilePicture(jid: string, img: Buffer) {
async updateProfilePicture(jid: string, imgBuffer: Buffer) {
jid = jidNormalizedUser (jid)
const data = { img: Buffer.from([]), preview: Buffer.from([]) } //await generateProfilePicture(img) TODO
const { img } = await generateProfilePicture(imgBuffer)
const tag = this.generateMessageTag ()
const query: BinaryNode = {
tag: 'picture',
attrs: { jid: jid, id: tag, type: 'set' },
content: [
{ tag: 'image', attrs: {}, content: data.img },
{ tag: 'preview', attrs: {}, content: data.preview }
{ tag: 'image', attrs: {}, content: img },
{ tag: 'preview', attrs: {}, content: img }
]
}