mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 01:41:24 -06:00
fix: correction of chatwoot functioning with admin flows
This commit is contained in:
parent
f069a41390
commit
64c1440c46
@ -56,7 +56,7 @@
|
|||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"dayjs": "^1.11.7",
|
"dayjs": "^1.11.7",
|
||||||
"eventemitter2": "^6.4.9",
|
"eventemitter2": "^6.4.9",
|
||||||
"evolution-manager": "latest",
|
"evolution-manager": "^0.4.4",
|
||||||
"exiftool-vendored": "^22.0.0",
|
"exiftool-vendored": "^22.0.0",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"express-async-errors": "^3.1.1",
|
"express-async-errors": "^3.1.1",
|
||||||
|
@ -47,7 +47,7 @@ export class ChatwootController {
|
|||||||
|
|
||||||
data.name_inbox = instance.instanceName;
|
data.name_inbox = instance.instanceName;
|
||||||
|
|
||||||
const result = this.chatwootService.create(instance, data);
|
const result = await this.chatwootService.create(instance, data);
|
||||||
|
|
||||||
const urlServer = this.configService.get<HttpServer>('SERVER').URL;
|
const urlServer = this.configService.get<HttpServer>('SERVER').URL;
|
||||||
|
|
||||||
|
@ -52,25 +52,26 @@ export class ChatwootService {
|
|||||||
|
|
||||||
private async getProvider(instance: InstanceDto) {
|
private async getProvider(instance: InstanceDto) {
|
||||||
this.logger.verbose('get provider to instance: ' + instance.instanceName);
|
this.logger.verbose('get provider to instance: ' + instance.instanceName);
|
||||||
try {
|
const provider = await this.waMonitor.waInstances[instance.instanceName]?.findChatwoot();
|
||||||
const provider = await this.waMonitor.waInstances[instance.instanceName].findChatwoot();
|
|
||||||
|
|
||||||
if (!provider) {
|
if (!provider) {
|
||||||
this.logger.warn('provider not found');
|
this.logger.warn('provider not found');
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.logger.verbose('provider found');
|
|
||||||
|
|
||||||
return provider;
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error('provider not found');
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.verbose('provider found');
|
||||||
|
|
||||||
|
return provider;
|
||||||
|
// try {
|
||||||
|
// } catch (error) {
|
||||||
|
// this.logger.error('provider not found');
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private async clientCw(instance: InstanceDto) {
|
private async clientCw(instance: InstanceDto) {
|
||||||
this.logger.verbose('get client to instance: ' + instance.instanceName);
|
this.logger.verbose('get client to instance: ' + instance.instanceName);
|
||||||
|
|
||||||
const provider = await this.getProvider(instance);
|
const provider = await this.getProvider(instance);
|
||||||
|
|
||||||
if (!provider) {
|
if (!provider) {
|
||||||
@ -97,17 +98,17 @@ export class ChatwootService {
|
|||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
public create(instance: InstanceDto, data: ChatwootDto) {
|
public async create(instance: InstanceDto, data: ChatwootDto) {
|
||||||
this.logger.verbose('create chatwoot: ' + instance.instanceName);
|
this.logger.verbose('create chatwoot: ' + instance.instanceName);
|
||||||
|
|
||||||
this.waMonitor.waInstances[instance.instanceName].setChatwoot(data);
|
await this.waMonitor.waInstances[instance.instanceName].setChatwoot(data);
|
||||||
|
|
||||||
this.logger.verbose('chatwoot created');
|
this.logger.verbose('chatwoot created');
|
||||||
|
|
||||||
if (data.auto_create) {
|
if (data.auto_create) {
|
||||||
const urlServer = this.configService.get<HttpServer>('SERVER').URL;
|
const urlServer = this.configService.get<HttpServer>('SERVER').URL;
|
||||||
|
|
||||||
this.initInstanceChatwoot(
|
await this.initInstanceChatwoot(
|
||||||
instance,
|
instance,
|
||||||
instance.instanceName.split('-cwId-')[0],
|
instance.instanceName.split('-cwId-')[0],
|
||||||
`${urlServer}/chatwoot/webhook/${encodeURIComponent(instance.instanceName)}`,
|
`${urlServer}/chatwoot/webhook/${encodeURIComponent(instance.instanceName)}`,
|
||||||
@ -1002,7 +1003,7 @@ export class ChatwootService {
|
|||||||
if (state !== 'open') {
|
if (state !== 'open') {
|
||||||
if (state === 'close') {
|
if (state === 'close') {
|
||||||
this.logger.verbose('request cleaning up instance: ' + instance.instanceName);
|
this.logger.verbose('request cleaning up instance: ' + instance.instanceName);
|
||||||
await this.waMonitor.cleaningUp(instance.instanceName);
|
// await this.waMonitor.cleaningUp(instance.instanceName);
|
||||||
}
|
}
|
||||||
this.logger.verbose('connect to whatsapp');
|
this.logger.verbose('connect to whatsapp');
|
||||||
const number = command.split(':')[1];
|
const number = command.split(':')[1];
|
||||||
|
@ -211,6 +211,7 @@ export class WAStartupService {
|
|||||||
|
|
||||||
public async getProfileName() {
|
public async getProfileName() {
|
||||||
this.logger.verbose('Getting profile name');
|
this.logger.verbose('Getting profile name');
|
||||||
|
|
||||||
let profileName = this.client.user?.name ?? this.client.user?.verifiedName;
|
let profileName = this.client.user?.name ?? this.client.user?.verifiedName;
|
||||||
if (!profileName) {
|
if (!profileName) {
|
||||||
this.logger.verbose('Profile name not found, trying to get from database');
|
this.logger.verbose('Profile name not found, trying to get from database');
|
||||||
@ -3311,7 +3312,16 @@ export class WAStartupService {
|
|||||||
|
|
||||||
public async fetchPrivacySettings() {
|
public async fetchPrivacySettings() {
|
||||||
this.logger.verbose('Fetching privacy settings');
|
this.logger.verbose('Fetching privacy settings');
|
||||||
return await this.client.fetchPrivacySettings();
|
const privacy = await this.client.fetchPrivacySettings();
|
||||||
|
|
||||||
|
return {
|
||||||
|
readreceipts: privacy.readreceipts,
|
||||||
|
profile: privacy.profile,
|
||||||
|
status: privacy.status,
|
||||||
|
online: privacy.online,
|
||||||
|
last: privacy.last,
|
||||||
|
groupadd: privacy.groupadd,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public async updatePrivacySettings(settings: PrivacySettingDto) {
|
public async updatePrivacySettings(settings: PrivacySettingDto) {
|
||||||
@ -3427,7 +3437,7 @@ export class WAStartupService {
|
|||||||
await this.client.updateProfilePicture(this.instance.wuid, pic);
|
await this.client.updateProfilePicture(this.instance.wuid, pic);
|
||||||
this.logger.verbose('Profile picture updated');
|
this.logger.verbose('Profile picture updated');
|
||||||
|
|
||||||
await this.reloadConnection();
|
this.reloadConnection();
|
||||||
|
|
||||||
return { update: 'success' };
|
return { update: 'success' };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user