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)
|
||||
connectionStatus InstanceConnectionStatus @default(open)
|
||||
ownerJid String? @db.VarChar(100)
|
||||
profileName String? @db.VarChar(100)
|
||||
profilePicUrl String? @db.VarChar(500)
|
||||
integration String? @db.VarChar(100)
|
||||
number String? @db.VarChar(100)
|
||||
|
@ -50,6 +50,7 @@ model Instance {
|
||||
name String @unique @db.VarChar(255)
|
||||
connectionStatus InstanceConnectionStatus @default(open)
|
||||
ownerJid String? @db.VarChar(100)
|
||||
profileName String? @db.VarChar(100)
|
||||
profilePicUrl String? @db.VarChar(500)
|
||||
integration 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;
|
||||
|
||||
let name = instanceName;
|
||||
let arrayReturn = false;
|
||||
// let arrayReturn = false;
|
||||
|
||||
if (env.KEY !== key) {
|
||||
const instanceByKey = await this.prismaRepository.instance.findUnique({
|
||||
@ -521,14 +521,14 @@ export class InstanceController {
|
||||
|
||||
if (instanceByKey) {
|
||||
name = instanceByKey.name;
|
||||
arrayReturn = true;
|
||||
// arrayReturn = true;
|
||||
} else {
|
||||
throw new UnauthorizedException();
|
||||
}
|
||||
}
|
||||
|
||||
if (name) {
|
||||
return this.waMonitor.instanceInfo(name, arrayReturn);
|
||||
return this.waMonitor.instanceInfo(name);
|
||||
} else if (instanceId || number) {
|
||||
return this.waMonitor.instanceInfoById(instanceId, number);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import ffmpegPath from '@ffmpeg-installer/ffmpeg';
|
||||
import { Boom } from '@hapi/boom';
|
||||
import { Instance } from '@prisma/client';
|
||||
import makeWASocket, {
|
||||
AnyMessageContent,
|
||||
BufferedEventData,
|
||||
@ -419,6 +420,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
where: { id: this.instanceId },
|
||||
data: {
|
||||
ownerJid: this.instance.wuid,
|
||||
profileName: (await this.getProfileName()) as string,
|
||||
profilePicUrl: this.instance.profilePictureUrl,
|
||||
connectionStatus: 'open',
|
||||
},
|
||||
@ -1650,15 +1652,15 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
website: business?.website?.shift(),
|
||||
};
|
||||
} else {
|
||||
const info = await waMonitor.instanceInfo(instanceName);
|
||||
const info: Instance = await waMonitor.instanceInfo(instanceName);
|
||||
const business = await this.fetchBusinessProfile(jid);
|
||||
|
||||
return {
|
||||
wuid: jid,
|
||||
// name: info?.instance?.profileName,
|
||||
name: info?.profileName,
|
||||
numberExists: true,
|
||||
// picture: info?.instance?.profilePictureUrl,
|
||||
// status: info?.instance?.profileStatus,
|
||||
picture: info?.profilePicUrl,
|
||||
status: info?.connectionStatus,
|
||||
isBusiness: business.isBusiness,
|
||||
email: business?.email,
|
||||
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]) {
|
||||
throw new NotFoundException(`Instance "${instanceName}" not found`);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user