mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 01:41:24 -06:00
fix: instances
This commit is contained in:
parent
4879bdb527
commit
28e5b2f65e
@ -0,0 +1,2 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Instance" ADD COLUMN "profileName" VARCHAR(100);
|
@ -50,6 +50,7 @@ model Instance {
|
|||||||
name String @unique @db.VarChar(255)
|
name String @unique @db.VarChar(255)
|
||||||
connectionStatus InstanceConnectionStatus @default(open)
|
connectionStatus InstanceConnectionStatus @default(open)
|
||||||
ownerJid String? @db.VarChar(100)
|
ownerJid String? @db.VarChar(100)
|
||||||
|
profileName String? @db.VarChar(100)
|
||||||
profilePicUrl String? @db.VarChar(500)
|
profilePicUrl String? @db.VarChar(500)
|
||||||
integration String? @db.VarChar(100)
|
integration String? @db.VarChar(100)
|
||||||
number String? @db.VarChar(100)
|
number String? @db.VarChar(100)
|
||||||
|
@ -50,6 +50,7 @@ model Instance {
|
|||||||
name String @unique @db.VarChar(255)
|
name String @unique @db.VarChar(255)
|
||||||
connectionStatus InstanceConnectionStatus @default(open)
|
connectionStatus InstanceConnectionStatus @default(open)
|
||||||
ownerJid String? @db.VarChar(100)
|
ownerJid String? @db.VarChar(100)
|
||||||
|
profileName String? @db.VarChar(100)
|
||||||
profilePicUrl String? @db.VarChar(500)
|
profilePicUrl String? @db.VarChar(500)
|
||||||
integration String? @db.VarChar(100)
|
integration String? @db.VarChar(100)
|
||||||
number String? @db.VarChar(100)
|
number String? @db.VarChar(100)
|
||||||
|
@ -510,7 +510,7 @@ export class InstanceController {
|
|||||||
const env = this.configService.get<Auth>('AUTHENTICATION').API_KEY;
|
const env = this.configService.get<Auth>('AUTHENTICATION').API_KEY;
|
||||||
|
|
||||||
let name = instanceName;
|
let name = instanceName;
|
||||||
let arrayReturn = false;
|
// let arrayReturn = false;
|
||||||
|
|
||||||
if (env.KEY !== key) {
|
if (env.KEY !== key) {
|
||||||
const instanceByKey = await this.prismaRepository.instance.findUnique({
|
const instanceByKey = await this.prismaRepository.instance.findUnique({
|
||||||
@ -521,14 +521,14 @@ export class InstanceController {
|
|||||||
|
|
||||||
if (instanceByKey) {
|
if (instanceByKey) {
|
||||||
name = instanceByKey.name;
|
name = instanceByKey.name;
|
||||||
arrayReturn = true;
|
// arrayReturn = true;
|
||||||
} else {
|
} else {
|
||||||
throw new UnauthorizedException();
|
throw new UnauthorizedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name) {
|
if (name) {
|
||||||
return this.waMonitor.instanceInfo(name, arrayReturn);
|
return this.waMonitor.instanceInfo(name);
|
||||||
} else if (instanceId || number) {
|
} else if (instanceId || number) {
|
||||||
return this.waMonitor.instanceInfoById(instanceId, number);
|
return this.waMonitor.instanceInfoById(instanceId, number);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import ffmpegPath from '@ffmpeg-installer/ffmpeg';
|
import ffmpegPath from '@ffmpeg-installer/ffmpeg';
|
||||||
import { Boom } from '@hapi/boom';
|
import { Boom } from '@hapi/boom';
|
||||||
|
import { Instance } from '@prisma/client';
|
||||||
import makeWASocket, {
|
import makeWASocket, {
|
||||||
AnyMessageContent,
|
AnyMessageContent,
|
||||||
BufferedEventData,
|
BufferedEventData,
|
||||||
@ -419,6 +420,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
where: { id: this.instanceId },
|
where: { id: this.instanceId },
|
||||||
data: {
|
data: {
|
||||||
ownerJid: this.instance.wuid,
|
ownerJid: this.instance.wuid,
|
||||||
|
profileName: (await this.getProfileName()) as string,
|
||||||
profilePicUrl: this.instance.profilePictureUrl,
|
profilePicUrl: this.instance.profilePictureUrl,
|
||||||
connectionStatus: 'open',
|
connectionStatus: 'open',
|
||||||
},
|
},
|
||||||
@ -1650,15 +1652,15 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
website: business?.website?.shift(),
|
website: business?.website?.shift(),
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
const info = await waMonitor.instanceInfo(instanceName);
|
const info: Instance = await waMonitor.instanceInfo(instanceName);
|
||||||
const business = await this.fetchBusinessProfile(jid);
|
const business = await this.fetchBusinessProfile(jid);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
wuid: jid,
|
wuid: jid,
|
||||||
// name: info?.instance?.profileName,
|
name: info?.profileName,
|
||||||
numberExists: true,
|
numberExists: true,
|
||||||
// picture: info?.instance?.profilePictureUrl,
|
picture: info?.profilePicUrl,
|
||||||
// status: info?.instance?.profileStatus,
|
status: info?.connectionStatus,
|
||||||
isBusiness: business.isBusiness,
|
isBusiness: business.isBusiness,
|
||||||
email: business?.email,
|
email: business?.email,
|
||||||
description: business?.description,
|
description: business?.description,
|
||||||
|
@ -63,7 +63,7 @@ export class WAMonitoringService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async instanceInfo(instanceName?: string, arrayReturn = false) {
|
public async instanceInfo(instanceName?: string): Promise<any> {
|
||||||
if (instanceName && !this.waInstances[instanceName]) {
|
if (instanceName && !this.waInstances[instanceName]) {
|
||||||
throw new NotFoundException(`Instance "${instanceName}" not found`);
|
throw new NotFoundException(`Instance "${instanceName}" not found`);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user