mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 01:41:24 -06:00
fix: include instance Id field in the instance configuration
This commit is contained in:
parent
c07e23bf8d
commit
cf89601269
@ -6,6 +6,10 @@
|
|||||||
* Fixed sending variables to typebot
|
* Fixed sending variables to typebot
|
||||||
* Fixed sending variables from typebot
|
* Fixed sending variables from typebot
|
||||||
* Correction sending s3/minio media to chatwoot and typebot
|
* Correction sending s3/minio media to chatwoot and typebot
|
||||||
|
* Fixed the problem with typebot closing at the end of the flow, now this is optional with the TYPEBOT_KEEP_OPEN variable
|
||||||
|
* Fixed chatwoot Bold, Italic and Underline formatting using Regex
|
||||||
|
* Added the sign_delimiter property to the Chatwoot configuration, allowing you to set a different delimiter for the signature. Default when not defined \n
|
||||||
|
* Include instance Id field in the instance configuration
|
||||||
|
|
||||||
# 1.6.0 (2023-12-12 17:24)
|
# 1.6.0 (2023-12-12 17:24)
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { delay } from '@whiskeysockets/baileys';
|
import { delay } from '@whiskeysockets/baileys';
|
||||||
import { isURL } from 'class-validator';
|
import { isURL } from 'class-validator';
|
||||||
import EventEmitter2 from 'eventemitter2';
|
import EventEmitter2 from 'eventemitter2';
|
||||||
|
import { v4 } from 'uuid';
|
||||||
|
|
||||||
import { ConfigService, HttpServer } from '../../config/env.config';
|
import { ConfigService, HttpServer } from '../../config/env.config';
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
@ -87,8 +88,11 @@ export class InstanceController {
|
|||||||
const instance = new WAStartupService(this.configService, this.eventEmitter, this.repository, this.cache);
|
const instance = new WAStartupService(this.configService, this.eventEmitter, this.repository, this.cache);
|
||||||
instance.instanceName = instanceName;
|
instance.instanceName = instanceName;
|
||||||
|
|
||||||
|
const instanceId = v4();
|
||||||
|
|
||||||
instance.sendDataWebhook(Events.INSTANCE_CREATE, {
|
instance.sendDataWebhook(Events.INSTANCE_CREATE, {
|
||||||
instanceName,
|
instanceName,
|
||||||
|
instanceId: instanceId,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.logger.verbose('instance: ' + instance.instanceName + ' created');
|
this.logger.verbose('instance: ' + instance.instanceName + ' created');
|
||||||
@ -100,6 +104,7 @@ export class InstanceController {
|
|||||||
const hash = await this.authService.generateHash(
|
const hash = await this.authService.generateHash(
|
||||||
{
|
{
|
||||||
instanceName: instance.instanceName,
|
instanceName: instance.instanceName,
|
||||||
|
instanceId: instanceId,
|
||||||
},
|
},
|
||||||
token,
|
token,
|
||||||
);
|
);
|
||||||
@ -367,6 +372,7 @@ export class InstanceController {
|
|||||||
const result = {
|
const result = {
|
||||||
instance: {
|
instance: {
|
||||||
instanceName: instance.instanceName,
|
instanceName: instance.instanceName,
|
||||||
|
instanceId: instanceId,
|
||||||
status: 'created',
|
status: 'created',
|
||||||
},
|
},
|
||||||
hash,
|
hash,
|
||||||
@ -459,6 +465,7 @@ export class InstanceController {
|
|||||||
return {
|
return {
|
||||||
instance: {
|
instance: {
|
||||||
instanceName: instance.instanceName,
|
instanceName: instance.instanceName,
|
||||||
|
instanceId: instanceId,
|
||||||
status: 'created',
|
status: 'created',
|
||||||
},
|
},
|
||||||
hash,
|
hash,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
export class InstanceDto {
|
export class InstanceDto {
|
||||||
instanceName: string;
|
instanceName: string;
|
||||||
|
instanceId?: string;
|
||||||
qrcode?: boolean;
|
qrcode?: boolean;
|
||||||
number?: string;
|
number?: string;
|
||||||
token?: string;
|
token?: string;
|
||||||
|
@ -6,12 +6,14 @@ export class AuthRaw {
|
|||||||
_id?: string;
|
_id?: string;
|
||||||
jwt?: string;
|
jwt?: string;
|
||||||
apikey?: string;
|
apikey?: string;
|
||||||
|
instanceId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const authSchema = new Schema<AuthRaw>({
|
const authSchema = new Schema<AuthRaw>({
|
||||||
_id: { type: String, _id: true },
|
_id: { type: String, _id: true },
|
||||||
jwt: { type: String, minlength: 1 },
|
jwt: { type: String, minlength: 1 },
|
||||||
apikey: { type: String, minlength: 1 },
|
apikey: { type: String, minlength: 1 },
|
||||||
|
instanceId: { type: String, minlength: 1 },
|
||||||
});
|
});
|
||||||
|
|
||||||
export const AuthModel = dbserver?.model(AuthRaw.name, authSchema, 'authentication');
|
export const AuthModel = dbserver?.model(AuthRaw.name, authSchema, 'authentication');
|
||||||
|
@ -19,6 +19,7 @@ export class AuthRepository extends Repository {
|
|||||||
public async create(data: AuthRaw, instance: string): Promise<IInsert> {
|
public async create(data: AuthRaw, instance: string): Promise<IInsert> {
|
||||||
try {
|
try {
|
||||||
this.logger.verbose('creating auth');
|
this.logger.verbose('creating auth');
|
||||||
|
|
||||||
if (this.dbSettings.ENABLED) {
|
if (this.dbSettings.ENABLED) {
|
||||||
this.logger.verbose('saving auth to db');
|
this.logger.verbose('saving auth to db');
|
||||||
const insert = await this.authModel.replaceOne({ _id: instance }, { ...data }, { upsert: true });
|
const insert = await this.authModel.replaceOne({ _id: instance }, { ...data }, { upsert: true });
|
||||||
|
@ -46,7 +46,10 @@ export class AuthService {
|
|||||||
|
|
||||||
this.logger.verbose('JWT token created: ' + token);
|
this.logger.verbose('JWT token created: ' + token);
|
||||||
|
|
||||||
const auth = await this.repository.auth.create({ jwt: token }, instance.instanceName);
|
const auth = await this.repository.auth.create(
|
||||||
|
{ jwt: token, instanceId: instance.instanceId },
|
||||||
|
instance.instanceName,
|
||||||
|
);
|
||||||
|
|
||||||
this.logger.verbose('JWT token saved in database');
|
this.logger.verbose('JWT token saved in database');
|
||||||
|
|
||||||
@ -66,7 +69,7 @@ export class AuthService {
|
|||||||
|
|
||||||
this.logger.verbose(token ? 'APIKEY defined: ' + apikey : 'APIKEY created: ' + apikey);
|
this.logger.verbose(token ? 'APIKEY defined: ' + apikey : 'APIKEY created: ' + apikey);
|
||||||
|
|
||||||
const auth = await this.repository.auth.create({ apikey }, instance.instanceName);
|
const auth = await this.repository.auth.create({ apikey, instanceId: instance.instanceId }, instance.instanceName);
|
||||||
|
|
||||||
this.logger.verbose('APIKEY saved in database');
|
this.logger.verbose('APIKEY saved in database');
|
||||||
|
|
||||||
|
@ -112,6 +112,7 @@ export class WAMonitoringService {
|
|||||||
const instanceData = {
|
const instanceData = {
|
||||||
instance: {
|
instance: {
|
||||||
instanceName: key,
|
instanceName: key,
|
||||||
|
instanceId: (await this.repository.auth.find(key))?.instanceId,
|
||||||
owner: value.wuid,
|
owner: value.wuid,
|
||||||
profileName: (await value.getProfileName()) || 'not loaded',
|
profileName: (await value.getProfileName()) || 'not loaded',
|
||||||
profilePictureUrl: value.profilePictureUrl,
|
profilePictureUrl: value.profilePictureUrl,
|
||||||
@ -135,6 +136,7 @@ export class WAMonitoringService {
|
|||||||
const instanceData = {
|
const instanceData = {
|
||||||
instance: {
|
instance: {
|
||||||
instanceName: key,
|
instanceName: key,
|
||||||
|
instanceId: (await this.repository.auth.find(key))?.instanceId,
|
||||||
status: value.connectionStatus.state,
|
status: value.connectionStatus.state,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user