mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-16 12:12:55 -06:00
Merge pull request #957 from fmedeiros95/v2.0.0
Escutar a configuração do webhook para midias recebidas
This commit is contained in:
commit
7cb5d10fc9
@ -598,6 +598,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
try {
|
try {
|
||||||
this.loadChatwoot();
|
this.loadChatwoot();
|
||||||
this.loadSettings();
|
this.loadSettings();
|
||||||
|
this.loadWebhook();
|
||||||
this.loadProxy();
|
this.loadProxy();
|
||||||
|
|
||||||
return await this.createClient(number);
|
return await this.createClient(number);
|
||||||
@ -1152,18 +1153,20 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMedia && !this.configService.get<S3>('S3').ENABLE) {
|
if (this.localWebhook.enabled) {
|
||||||
const buffer = await downloadMediaMessage(
|
if (isMedia && this.localWebhook.webhookBase64) {
|
||||||
{ key: received.key, message: received?.message },
|
const buffer = await downloadMediaMessage(
|
||||||
'buffer',
|
{ key: received.key, message: received?.message },
|
||||||
{},
|
'buffer',
|
||||||
{
|
{},
|
||||||
logger: P({ level: 'error' }) as any,
|
{
|
||||||
reuploadRequest: this.client.updateMediaMessage,
|
logger: P({ level: 'error' }) as any,
|
||||||
},
|
reuploadRequest: this.client.updateMediaMessage,
|
||||||
);
|
},
|
||||||
|
);
|
||||||
|
|
||||||
messageRaw.message.base64 = buffer ? buffer.toString('base64') : undefined;
|
messageRaw.message.base64 = buffer ? buffer.toString('base64') : undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.log(messageRaw);
|
this.logger.log(messageRaw);
|
||||||
@ -2070,18 +2073,20 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMedia && !this.configService.get<S3>('S3').ENABLE) {
|
if (this.localWebhook.enabled) {
|
||||||
const buffer = await downloadMediaMessage(
|
if (isMedia && this.localWebhook.webhookBase64) {
|
||||||
{ key: messageRaw.key, message: messageRaw?.message },
|
const buffer = await downloadMediaMessage(
|
||||||
'buffer',
|
{ key: messageRaw.key, message: messageRaw?.message },
|
||||||
{},
|
'buffer',
|
||||||
{
|
{},
|
||||||
logger: P({ level: 'error' }) as any,
|
{
|
||||||
reuploadRequest: this.client.updateMediaMessage,
|
logger: P({ level: 'error' }) as any,
|
||||||
},
|
reuploadRequest: this.client.updateMediaMessage,
|
||||||
);
|
},
|
||||||
|
);
|
||||||
|
|
||||||
messageRaw.message.base64 = buffer ? buffer.toString('base64') : undefined;
|
messageRaw.message.base64 = buffer ? buffer.toString('base64') : undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.log(messageRaw);
|
this.logger.log(messageRaw);
|
||||||
|
@ -34,6 +34,7 @@ export class ChannelStartupService {
|
|||||||
public readonly localChatwoot: wa.LocalChatwoot = {};
|
public readonly localChatwoot: wa.LocalChatwoot = {};
|
||||||
public readonly localProxy: wa.LocalProxy = {};
|
public readonly localProxy: wa.LocalProxy = {};
|
||||||
public readonly localSettings: wa.LocalSettings = {};
|
public readonly localSettings: wa.LocalSettings = {};
|
||||||
|
public readonly localWebhook: wa.LocalWebHook = {};
|
||||||
|
|
||||||
public chatwootService = new ChatwootService(
|
public chatwootService = new ChatwootService(
|
||||||
waMonitor,
|
waMonitor,
|
||||||
@ -124,6 +125,17 @@ export class ChannelStartupService {
|
|||||||
return this.instance.wuid;
|
return this.instance.wuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async loadWebhook() {
|
||||||
|
const data = await this.prismaRepository.webhook.findUnique({
|
||||||
|
where: {
|
||||||
|
instanceId: this.instanceId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
this.localWebhook.enabled = data?.enabled;
|
||||||
|
this.localWebhook.webhookBase64 = data?.webhookBase64;
|
||||||
|
}
|
||||||
|
|
||||||
public async loadSettings() {
|
public async loadSettings() {
|
||||||
const data = await this.prismaRepository.setting.findUnique({
|
const data = await this.prismaRepository.setting.findUnique({
|
||||||
where: {
|
where: {
|
||||||
|
Loading…
Reference in New Issue
Block a user