This commit is contained in:
pedro-php 2025-04-25 14:47:15 -03:00
parent d35159edf1
commit 37c4b2d9ec

View File

@ -382,7 +382,7 @@ export class BaileysStartupService extends ChannelStartupService {
qrcodeTerminal.generate(qr, { small: true }, (qrcode) => qrcodeTerminal.generate(qr, { small: true }, (qrcode) =>
this.logger.log( this.logger.log(
`\n{ instance: ${this.instance.name} pairingCode: ${this.instance.qrcode.pairingCode}, qrcodeCount: ${this.instance.qrcode.count} }\n` + `\n{ instance: ${this.instance.name} pairingCode: ${this.instance.qrcode.pairingCode}, qrcodeCount: ${this.instance.qrcode.count} }\n` +
qrcode, qrcode,
), ),
); );
@ -1023,18 +1023,18 @@ export class BaileysStartupService extends ChannelStartupService {
const messagesRepository: Set<string> = new Set( const messagesRepository: Set<string> = new Set(
chatwootImport.getRepositoryMessagesCache(instance) ?? chatwootImport.getRepositoryMessagesCache(instance) ??
( (
await this.prismaRepository.message.findMany({ await this.prismaRepository.message.findMany({
select: { key: true }, select: { key: true },
where: { instanceId: this.instanceId }, where: { instanceId: this.instanceId },
}) })
).map((message) => { ).map((message) => {
const key = message.key as { const key = message.key as {
id: string; id: string;
}; };
return key.id; return key.id;
}), }),
); );
if (chatwootImport.getRepositoryMessagesCache(instance) === null) { if (chatwootImport.getRepositoryMessagesCache(instance) === null) {
@ -1115,6 +1115,7 @@ export class BaileysStartupService extends ChannelStartupService {
) => { ) => {
try { try {
for (const received of messages) { for (const received of messages) {
console.dir({ received }, { depth: null });
if (received.message?.conversation || received.message?.extendedTextMessage?.text) { if (received.message?.conversation || received.message?.extendedTextMessage?.text) {
const text = received.message?.conversation || received.message?.extendedTextMessage?.text; const text = received.message?.conversation || received.message?.extendedTextMessage?.text;
@ -1366,6 +1367,7 @@ export class BaileysStartupService extends ChannelStartupService {
if (this.localWebhook.enabled) { if (this.localWebhook.enabled) {
if (isMedia && this.localWebhook.webhookBase64) { if (isMedia && this.localWebhook.webhookBase64) {
try { try {
console.dir({ key: received.key, message: received.message }, { depth: null });
const buffer = await downloadMediaMessage( const buffer = await downloadMediaMessage(
{ key: received.key, message: received?.message }, { key: received.key, message: received?.message },
'buffer', 'buffer',
@ -1375,8 +1377,9 @@ export class BaileysStartupService extends ChannelStartupService {
reuploadRequest: this.client.updateMediaMessage, reuploadRequest: this.client.updateMediaMessage,
}, },
); );
console.dir({ buffer });
messageRaw.message.base64 = buffer ? buffer.toString('base64') : undefined; messageRaw.message.base64 = buffer ? buffer.toString('base64') : undefined;
console.dir({ base64: messageRaw.message.base64 });
} catch (error) { } catch (error) {
this.logger.error(['Error converting media to base64', error?.message]); this.logger.error(['Error converting media to base64', error?.message]);
} }
@ -1870,7 +1873,7 @@ export class BaileysStartupService extends ChannelStartupService {
try { try {
const profilePictureUrl = await this.client.profilePictureUrl(jid, 'image'); const profilePictureUrl = await this.client.profilePictureUrl(jid, 'image');
console.dir({profilePictureUrl}); console.dir({ profilePictureUrl });
return { return {
wuid: jid, wuid: jid,