mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
update profile pic in legacy version (#1611)
Co-authored-by: Henrique <qplok02@gmail.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { BaileysEventMap, Chat, ChatModification, Contact, LastMessageList, LegacySocketConfig, PresenceData, WABusinessProfile, WAFlag, WAMessageKey, WAMessageUpdate, WAMetric, WAPresence } from '../Types'
|
import { BaileysEventMap, Chat, ChatModification, Contact, LastMessageList, LegacySocketConfig, PresenceData, WABusinessProfile, WAFlag, WAMessageKey, WAMessageUpdate, WAMetric, WAPresence } from '../Types'
|
||||||
import { debouncedTimeout, unixTimestampSeconds } from '../Utils/generics'
|
import { debouncedTimeout, unixTimestampSeconds } from '../Utils/generics'
|
||||||
import { BinaryNode, jidNormalizedUser } from '../WABinary'
|
import { BinaryNode, jidNormalizedUser } from '../WABinary'
|
||||||
|
import { generateProfilePicture } from '../Utils'
|
||||||
import makeAuthSocket from './auth'
|
import makeAuthSocket from './auth'
|
||||||
|
|
||||||
const makeChatsSocket = (config: LegacySocketConfig) => {
|
const makeChatsSocket = (config: LegacySocketConfig) => {
|
||||||
@@ -474,16 +475,17 @@ const makeChatsSocket = (config: LegacySocketConfig) => {
|
|||||||
* @param jid
|
* @param jid
|
||||||
* @param img
|
* @param img
|
||||||
*/
|
*/
|
||||||
async updateProfilePicture(jid: string, img: Buffer) {
|
async updateProfilePicture(jid: string, imgBuffer: Buffer) {
|
||||||
jid = jidNormalizedUser (jid)
|
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 tag = this.generateMessageTag ()
|
||||||
const query: BinaryNode = {
|
const query: BinaryNode = {
|
||||||
tag: 'picture',
|
tag: 'picture',
|
||||||
attrs: { jid: jid, id: tag, type: 'set' },
|
attrs: { jid: jid, id: tag, type: 'set' },
|
||||||
content: [
|
content: [
|
||||||
{ tag: 'image', attrs: {}, content: data.img },
|
{ tag: 'image', attrs: {}, content: img },
|
||||||
{ tag: 'preview', attrs: {}, content: data.preview }
|
{ tag: 'preview', attrs: {}, content: img }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user