mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 09:51:24 -06:00
Merge branch 'develop' of github.com:EvolutionAPI/evolution-api into develop
This commit is contained in:
commit
547943a05c
@ -97,6 +97,7 @@ WEBHOOK:
|
||||
WEBHOOK_BY_EVENTS: false
|
||||
# Automatically maps webhook paths
|
||||
# Set the events you want to hear
|
||||
WEBHOOK_BASE64: false
|
||||
EVENTS:
|
||||
APPLICATION_STARTUP: false
|
||||
QRCODE_UPDATED: true
|
||||
|
@ -41,6 +41,7 @@ export class InstanceController {
|
||||
instanceName,
|
||||
webhook,
|
||||
webhook_by_events,
|
||||
webhook_base64,
|
||||
events,
|
||||
qrcode,
|
||||
number,
|
||||
@ -139,6 +140,7 @@ export class InstanceController {
|
||||
url: webhook,
|
||||
events: newEvents,
|
||||
webhook_by_events,
|
||||
webhook_base64,
|
||||
});
|
||||
|
||||
webhookEvents = (await this.webhookService.find(instance)).events;
|
||||
@ -297,6 +299,7 @@ export class InstanceController {
|
||||
webhook: {
|
||||
webhook,
|
||||
webhook_by_events,
|
||||
webhook_base64,
|
||||
events: webhookEvents,
|
||||
},
|
||||
websocket: {
|
||||
@ -390,6 +393,7 @@ export class InstanceController {
|
||||
webhook: {
|
||||
webhook,
|
||||
webhook_by_events,
|
||||
webhook_base64,
|
||||
events: webhookEvents,
|
||||
},
|
||||
websocket: {
|
||||
|
@ -5,6 +5,7 @@ export class InstanceDto {
|
||||
token?: string;
|
||||
webhook?: string;
|
||||
webhook_by_events?: boolean;
|
||||
webhook_base64?: boolean;
|
||||
events?: string[];
|
||||
reject_call?: boolean;
|
||||
msg_call?: string;
|
||||
|
@ -8,6 +8,7 @@ export class WebhookRaw {
|
||||
enabled?: boolean;
|
||||
events?: string[];
|
||||
webhook_by_events?: boolean;
|
||||
webhook_base64?: boolean;
|
||||
}
|
||||
|
||||
const webhookSchema = new Schema<WebhookRaw>({
|
||||
@ -16,6 +17,7 @@ const webhookSchema = new Schema<WebhookRaw>({
|
||||
enabled: { type: Boolean, required: true },
|
||||
events: { type: [String], required: true },
|
||||
webhook_by_events: { type: Boolean, required: true },
|
||||
webhook_base64: { type: Boolean, required: true },
|
||||
});
|
||||
|
||||
export const WebhookModel = dbserver?.model(WebhookRaw.name, webhookSchema, 'webhook');
|
||||
|
@ -26,7 +26,7 @@ export class WebhookService {
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
return { enabled: false, url: '', events: [], webhook_by_events: false };
|
||||
return { enabled: false, url: '', events: [], webhook_by_events: false, webhook_base64 : false };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -276,6 +276,10 @@ export class WAStartupService {
|
||||
this.localWebhook.webhook_by_events = data?.webhook_by_events;
|
||||
this.logger.verbose(`Webhook by events: ${this.localWebhook.webhook_by_events}`);
|
||||
|
||||
this.localWebhook.webhook_base64 = data?.webhook_base64;
|
||||
this.logger.verbose(`Webhook by webhook_base64: ${this.localWebhook.webhook_base64}`);
|
||||
|
||||
|
||||
this.logger.verbose('Webhook loaded');
|
||||
}
|
||||
|
||||
@ -1528,7 +1532,33 @@ export class WAStartupService {
|
||||
return;
|
||||
}
|
||||
|
||||
const messageRaw: MessageRaw = {
|
||||
let messageRaw: MessageRaw;
|
||||
const globalWebhook = this.configService.get<Webhook>('WEBHOOK').GLOBAL;
|
||||
if (this.localWebhook.webhook_base64 === true && received?.message.documentMessage || received?.message.imageMessage ) {
|
||||
const buffer = await downloadMediaMessage(
|
||||
{ key: received.key, message: received?.message },
|
||||
'buffer',
|
||||
{},
|
||||
{
|
||||
logger: P({ level: 'error' }),
|
||||
reuploadRequest: this.client.updateMediaMessage,
|
||||
},
|
||||
);
|
||||
console.log(buffer);
|
||||
messageRaw = {
|
||||
key: received.key,
|
||||
pushName: received.pushName,
|
||||
message: {
|
||||
...received.message,
|
||||
base64: buffer ? buffer.toString('base64') : undefined,
|
||||
},
|
||||
messageType: getContentType(received.message),
|
||||
messageTimestamp: received.messageTimestamp as number,
|
||||
owner: this.instance.name,
|
||||
source: getDevice(received.key.id),
|
||||
};
|
||||
} else {
|
||||
messageRaw = {
|
||||
key: received.key,
|
||||
pushName: received.pushName,
|
||||
message: { ...received.message },
|
||||
@ -1537,6 +1567,7 @@ export class WAStartupService {
|
||||
owner: this.instance.name,
|
||||
source: getDevice(received.key.id),
|
||||
};
|
||||
}
|
||||
|
||||
if (this.localSettings.read_messages && received.key.id !== 'status@broadcast') {
|
||||
await this.client.readMessages([received.key]);
|
||||
|
@ -50,6 +50,7 @@ export declare namespace wa {
|
||||
url?: string;
|
||||
events?: string[];
|
||||
webhook_by_events?: boolean;
|
||||
webhook_base64?: boolean;
|
||||
};
|
||||
|
||||
export type LocalChatwoot = {
|
||||
|
Loading…
Reference in New Issue
Block a user