mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 01:41:24 -06:00
Merge branch 'release/1.1.4-1'
This commit is contained in:
commit
ea6a7c1c87
@ -17,6 +17,7 @@ STORE_MESSAGES=true
|
||||
STORE_MESSAGE_UP=true
|
||||
STORE_CONTACTS=true
|
||||
STORE_CHATS=true
|
||||
|
||||
CLEAN_STORE_CLEANING_INTERVAL=7200 # seconds === 2h
|
||||
CLEAN_STORE_MESSAGES=true
|
||||
CLEAN_STORE_MESSAGE_UP=true
|
||||
@ -29,15 +30,15 @@ DATABASE_CONNECTION_URI=mongodb://root:root@mongodb:27017/?authSource=admin&read
|
||||
DATABASE_CONNECTION_DB_PREFIX_NAME=evolution
|
||||
|
||||
# Choose the data you want to save in the application's database or store
|
||||
DATABASE_SAVE_DATA_INSTANCE=true
|
||||
DATABASE_SAVE_DATA_INSTANCE=false
|
||||
DATABASE_SAVE_DATA_OLD_MESSAGE=false
|
||||
DATABASE_SAVE_DATA_NEW_MESSAGE=true
|
||||
DATABASE_SAVE_MESSAGE_UPDATE=true
|
||||
DATABASE_SAVE_DATA_CONTACTS=true
|
||||
DATABASE_SAVE_DATA_CHATS=true
|
||||
DATABASE_SAVE_DATA_NEW_MESSAGE=false
|
||||
DATABASE_SAVE_MESSAGE_UPDATE=false
|
||||
DATABASE_SAVE_DATA_CONTACTS=false
|
||||
DATABASE_SAVE_DATA_CHATS=false
|
||||
|
||||
REDIS_ENABLED=false
|
||||
REDIS_URI=redis://redis:6379/1
|
||||
REDIS_URI=redis://redis:6379
|
||||
REDIS_PREFIX_KEY=evolution
|
||||
|
||||
# Webhook Settings
|
||||
@ -65,10 +66,10 @@ WEBHOOK_EVENTS_GROUPS_UPDATE=true
|
||||
WEBHOOK_EVENTS_GROUP_PARTICIPANTS_UPDATE=true
|
||||
WEBHOOK_EVENTS_CONNECTION_UPDATE=true
|
||||
# This event fires every time a new token is requested via the refresh route
|
||||
WEBHOOK_EVENTS_NEW_JWT_TOKEN=true
|
||||
WEBHOOK_EVENTS_NEW_JWT_TOKEN=false
|
||||
|
||||
# Name that will be displayed on smartphone connection
|
||||
CONFIG_SESSION_PHONE_CLIENT=Evolution API
|
||||
CONFIG_SESSION_PHONE_CLIENT='Evolution API'
|
||||
CONFIG_SESSION_PHONE_NAME=chrome # chrome | firefox | edge | opera | safari
|
||||
|
||||
# Set qrcode display limit
|
||||
@ -88,4 +89,4 @@ AUTHENTICATION_JWT_SECRET='L0YWtjb2w554WFqPG'
|
||||
AUTHENTICATION_INSTANCE_MODE=server # container or server
|
||||
# if you are using container mode, set the container name and the webhook url to default instance
|
||||
AUTHENTICATION_INSTANCE_NAME=evolution
|
||||
AUTHENTICATION_INSTANCE_WEBHOOK_URL=<url>
|
||||
AUTHENTICATION_INSTANCE_WEBHOOK_URL='<url>'
|
@ -21,7 +21,7 @@ ENV CORS_METHODS="POST,GET,PUT,DELETE"
|
||||
ENV CORS_CREDENTIALS=true
|
||||
|
||||
ENV LOG_LEVEL=$LOG_LEVEL
|
||||
ENV LOG_COLOR=true
|
||||
ENV LOG_COLOR=$LOG_COLOR
|
||||
|
||||
ENV DEL_INSTANCE=$DEL_INSTANCE
|
||||
|
||||
|
@ -2,9 +2,10 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[](https://evolution-api.com/whatsapp)
|
||||
[](https://evolution-api.com/docs/evolution-documentation/getting-started/postman-collection/)
|
||||
[](https://evolution-api.com)
|
||||
[](https://evolution-api.com/whatsapp)
|
||||
[](https://evolution-api.com/discord)
|
||||
[](https://evolution-api.com/postman)
|
||||
[](https://doc.evolution-api.com)
|
||||
[](./LICENSE)
|
||||
[](https://app.picpay.com/user/davidsongomes1998)
|
||||
|
||||
|
@ -8,13 +8,6 @@ then
|
||||
docker network create -d bridge ${NET}
|
||||
fi
|
||||
|
||||
# sudo mkdir -p ./docker-data/instances
|
||||
# sudo mkdir -p ./docker-data/mongodb
|
||||
# sudo mkdir -p ./docker-data/mongodb/data
|
||||
# sudo mkdir -p ./docker-data/mongodb/configdb
|
||||
# sudo mkdir -p ./docker-data/redis
|
||||
# sudo mkdir -p ./docker-data/redis/data
|
||||
|
||||
docker build -t ${IMAGE} .
|
||||
|
||||
docker compose up -d
|
@ -61,7 +61,7 @@ CLEAN_STORE:
|
||||
|
||||
# Permanent data storage
|
||||
DATABASE:
|
||||
ENABLED: true
|
||||
ENABLED: false
|
||||
CONNECTION:
|
||||
URI: 'mongodb://root:root@localhost:27017/?authSource=admin&readPreference=primary&ssl=false&directConnection=true'
|
||||
DB_PREFIX_NAME: evolution
|
||||
@ -69,14 +69,14 @@ DATABASE:
|
||||
SAVE_DATA:
|
||||
INSTANCE: false
|
||||
OLD_MESSAGE: false
|
||||
NEW_MESSAGE: true
|
||||
MESSAGE_UPDATE: true
|
||||
CONTACTS: true
|
||||
CHATS: true
|
||||
NEW_MESSAGE: false
|
||||
MESSAGE_UPDATE: false
|
||||
CONTACTS: false
|
||||
CHATS: false
|
||||
|
||||
REDIS:
|
||||
ENABLED: true
|
||||
URI: 'redis://localhost:6379/1'
|
||||
ENABLED: false
|
||||
URI: 'redis://localhost:6379'
|
||||
PREFIX_KEY: 'evolution'
|
||||
|
||||
# Webhook Settings
|
||||
@ -84,13 +84,13 @@ WEBHOOK:
|
||||
# Define a global webhook that will listen for enabled events from all instances
|
||||
GLOBAL:
|
||||
URL: <url>
|
||||
ENABLED: true
|
||||
ENABLED: false
|
||||
# With this option activated, you work with a url per webhook event, respecting the global url and the name of each event
|
||||
WEBHOOK_BY_EVENTS: false
|
||||
# Automatically maps webhook paths
|
||||
# Set the events you want to hear
|
||||
EVENTS:
|
||||
APPLICATION_STARTUP: true
|
||||
APPLICATION_STARTUP: false
|
||||
QRCODE_UPDATED: true
|
||||
MESSAGES_SET: true
|
||||
MESSAGES_UPSERT: true
|
||||
@ -108,7 +108,7 @@ WEBHOOK:
|
||||
GROUP_PARTICIPANTS_UPDATE: true
|
||||
CONNECTION_UPDATE: true
|
||||
# This event fires every time a new token is requested via the refresh route
|
||||
NEW_JWT_TOKEN: true
|
||||
NEW_JWT_TOKEN: false
|
||||
|
||||
CONFIG_SESSION_PHONE:
|
||||
# Name that will be displayed on smartphone connection
|
||||
|
@ -63,6 +63,9 @@ export class RepositoryBroker {
|
||||
|
||||
this.logger.verbose('creating webhook path: ' + join(storePath, 'webhook'));
|
||||
execSync(`mkdir -p ${join(storePath, 'webhook')}`);
|
||||
|
||||
this.logger.verbose('creating temp path: ' + join(storePath, 'temp'));
|
||||
execSync(`mkdir -p ${join(storePath, 'temp')}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -984,12 +984,20 @@ export class WAStartupService {
|
||||
if (
|
||||
key.remoteJid !== 'status@broadcast' &&
|
||||
!key?.remoteJid?.match(/(:\d+)/) &&
|
||||
!key.fromMe
|
||||
key.fromMe
|
||||
) {
|
||||
this.logger.verbose('Message update is valid');
|
||||
|
||||
let pollUpdates: any;
|
||||
if (update.pollUpdates) {
|
||||
this.logger.verbose('Poll update found');
|
||||
|
||||
this.logger.verbose('Getting poll message');
|
||||
const pollCreation = await this.getMessage(key);
|
||||
this.logger.verbose(pollCreation);
|
||||
|
||||
if (pollCreation) {
|
||||
this.logger.verbose('Getting aggregate votes in poll message');
|
||||
pollUpdates = getAggregateVotesInPollMessage({
|
||||
message: pollCreation as proto.IMessage,
|
||||
pollUpdates: update.pollUpdates,
|
||||
@ -1005,6 +1013,8 @@ export class WAStartupService {
|
||||
pollUpdates,
|
||||
};
|
||||
|
||||
this.logger.verbose(message);
|
||||
|
||||
this.logger.verbose('Sending data to webhook in event MESSAGES_UPDATE');
|
||||
await this.sendDataWebhook(Events.MESSAGES_UPDATE, message);
|
||||
|
||||
@ -1367,21 +1377,27 @@ export class WAStartupService {
|
||||
);
|
||||
})();
|
||||
|
||||
const messageRaw: proto.IWebMessageInfo = {
|
||||
const messageRaw: MessageRaw = {
|
||||
key: messageSent.key,
|
||||
messageTimestamp: Long.isLong(messageSent.messageTimestamp)
|
||||
? messageSent.messageTimestamp?.toNumber()
|
||||
: messageSent.messageTimestamp,
|
||||
pushName: messageSent.pushName,
|
||||
broadcast: messageSent.broadcast,
|
||||
status: 2,
|
||||
message: { ...messageSent.message },
|
||||
messageType: getContentType(messageSent.message),
|
||||
messageTimestamp: messageSent.messageTimestamp as number,
|
||||
owner: this.instance.name,
|
||||
source: getDevice(messageSent.key.id),
|
||||
};
|
||||
|
||||
this.client.ev.emit('messages.upsert', {
|
||||
messages: [messageRaw],
|
||||
type: 'notify',
|
||||
});
|
||||
this.logger.log(messageRaw);
|
||||
|
||||
this.logger.verbose('Sending data to webhook in event SEND_MESSAGE');
|
||||
await this.sendDataWebhook(Events.SEND_MESSAGE, messageRaw);
|
||||
|
||||
this.logger.verbose('Inserting message in database');
|
||||
await this.repository.message.insert(
|
||||
[messageRaw],
|
||||
this.instance.name,
|
||||
this.configService.get<Database>('DATABASE').SAVE_DATA.NEW_MESSAGE,
|
||||
);
|
||||
|
||||
return messageSent;
|
||||
} catch (error) {
|
||||
@ -1628,7 +1644,7 @@ export class WAStartupService {
|
||||
const hash = `${number}-${new Date().getTime()}`;
|
||||
this.logger.verbose('Hash to image name: ' + hash);
|
||||
|
||||
const outputPath = `${join(process.cwd(), 'temp', `${hash}.webp`)}`;
|
||||
const outputPath = `${join(this.storePath, 'temp', `${hash}.webp`)}`;
|
||||
this.logger.verbose('Output path: ' + outputPath);
|
||||
|
||||
if (isBase64(image)) {
|
||||
@ -1636,7 +1652,7 @@ export class WAStartupService {
|
||||
|
||||
const base64Data = image.replace(/^data:image\/(jpeg|png|gif);base64,/, '');
|
||||
const imageBuffer = Buffer.from(base64Data, 'base64');
|
||||
imagePath = `${join(process.cwd(), 'temp', `temp-${hash}.png`)}`;
|
||||
imagePath = `${join(this.storePath, 'temp', `temp-${hash}.png`)}`;
|
||||
this.logger.verbose('Image path: ' + imagePath);
|
||||
|
||||
await sharp(imageBuffer).toFile(imagePath);
|
||||
@ -1652,7 +1668,7 @@ export class WAStartupService {
|
||||
this.logger.verbose('Getting image from url');
|
||||
|
||||
const imageBuffer = Buffer.from(response.data, 'binary');
|
||||
imagePath = `${join(process.cwd(), 'temp', `temp-${hash}.png`)}`;
|
||||
imagePath = `${join(this.storePath, 'temp', `temp-${hash}.png`)}`;
|
||||
this.logger.verbose('Image path: ' + imagePath);
|
||||
|
||||
await sharp(imageBuffer).toFile(imagePath);
|
||||
@ -1710,8 +1726,8 @@ export class WAStartupService {
|
||||
if (isURL(audio)) {
|
||||
this.logger.verbose('Audio is url');
|
||||
|
||||
outputAudio = `${join(process.cwd(), 'temp', `${hash}.mp4`)}`;
|
||||
tempAudioPath = `${join(process.cwd(), 'temp', `temp-${hash}.mp3`)}`;
|
||||
outputAudio = `${join(this.storePath, 'temp', `${hash}.mp4`)}`;
|
||||
tempAudioPath = `${join(this.storePath, 'temp', `temp-${hash}.mp3`)}`;
|
||||
|
||||
this.logger.verbose('Output audio path: ' + outputAudio);
|
||||
this.logger.verbose('Temp audio path: ' + tempAudioPath);
|
||||
@ -1725,12 +1741,11 @@ export class WAStartupService {
|
||||
this.logger.verbose('Getting audio from url');
|
||||
|
||||
fs.writeFileSync(tempAudioPath, response.data);
|
||||
this.logger.verbose('Temp audio created');
|
||||
} else {
|
||||
this.logger.verbose('Audio is base64');
|
||||
|
||||
outputAudio = `${join(process.cwd(), 'temp', `${hash}.mp4`)}`;
|
||||
tempAudioPath = `${join(process.cwd(), 'temp', `temp-${hash}.mp3`)}`;
|
||||
outputAudio = `${join(this.storePath, 'temp', `${hash}.mp4`)}`;
|
||||
tempAudioPath = `${join(this.storePath, 'temp', `temp-${hash}.mp3`)}`;
|
||||
|
||||
this.logger.verbose('Output audio path: ' + outputAudio);
|
||||
this.logger.verbose('Temp audio path: ' + tempAudioPath);
|
||||
|
@ -6,6 +6,7 @@ export enum Events {
|
||||
QRCODE_UPDATED = 'qrcode.updated',
|
||||
CONNECTION_UPDATE = 'connection.update',
|
||||
STATUS_INSTANCE = 'status.instance',
|
||||
SEND_MESSAGE = 'send.message',
|
||||
MESSAGES_SET = 'messages.set',
|
||||
MESSAGES_UPSERT = 'messages.upsert',
|
||||
MESSAGES_UPDATE = 'messages.update',
|
||||
|
Loading…
Reference in New Issue
Block a user