mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-17 04:32:53 -06:00
fix error after logout and try to get status or to connect again
This commit is contained in:
parent
573e56cd8c
commit
75b48aa8ac
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
* Adjust dockerfile variables
|
* Adjust dockerfile variables
|
||||||
* tweaks in docker-compose to pass variables
|
* tweaks in docker-compose to pass variables
|
||||||
|
* Adjust the route getProfileBusiness to fetchProfileBusiness
|
||||||
|
* fix error after logout and try to get status or to connect again
|
||||||
|
|
||||||
# 1.0.9 (2023-06-10)
|
# 1.0.9 (2023-06-10)
|
||||||
|
|
||||||
|
@ -75,11 +75,13 @@ export class ChatController {
|
|||||||
return await this.waMonitor.waInstances[instanceName].updatePrivacySettings(data);
|
return await this.waMonitor.waInstances[instanceName].updatePrivacySettings(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getBusinessProfile(
|
public async fetchBusinessProfile(
|
||||||
{ instanceName }: InstanceDto,
|
{ instanceName }: InstanceDto,
|
||||||
data: ProfilePictureDto,
|
data: ProfilePictureDto,
|
||||||
) {
|
) {
|
||||||
return await this.waMonitor.waInstances[instanceName].getBusinessProfile(data.number);
|
return await this.waMonitor.waInstances[instanceName].fetchBusinessProfile(
|
||||||
|
data.number,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async updateProfileName({ instanceName }: InstanceDto, data: ProfileNameDto) {
|
public async updateProfileName({ instanceName }: InstanceDto, data: ProfileNameDto) {
|
||||||
|
@ -100,7 +100,7 @@ export class InstanceController {
|
|||||||
public async connectToWhatsapp({ instanceName }: InstanceDto) {
|
public async connectToWhatsapp({ instanceName }: InstanceDto) {
|
||||||
try {
|
try {
|
||||||
const instance = this.waMonitor.waInstances[instanceName];
|
const instance = this.waMonitor.waInstances[instanceName];
|
||||||
const state = instance.connectionStatus?.state;
|
const state = instance?.connectionStatus?.state ?? null;
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case 'close':
|
case 'close':
|
||||||
@ -118,7 +118,7 @@ export class InstanceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async connectionState({ instanceName }: InstanceDto) {
|
public async connectionState({ instanceName }: InstanceDto) {
|
||||||
return this.waMonitor.waInstances[instanceName].connectionStatus;
|
return this.waMonitor.waInstances[instanceName]?.connectionStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async fetchInstances({ instanceName }: InstanceDto) {
|
public async fetchInstances({ instanceName }: InstanceDto) {
|
||||||
|
@ -163,12 +163,13 @@ export class ChatRouter extends RouterBroker {
|
|||||||
|
|
||||||
return res.status(HttpStatus.CREATED).json(response);
|
return res.status(HttpStatus.CREATED).json(response);
|
||||||
})
|
})
|
||||||
.post(this.routerPath('getBusinessProfile'), ...guards, async (req, res) => {
|
.post(this.routerPath('fetchBusinessProfile'), ...guards, async (req, res) => {
|
||||||
const response = await this.dataValidate<ProfilePictureDto>({
|
const response = await this.dataValidate<ProfilePictureDto>({
|
||||||
request: req,
|
request: req,
|
||||||
schema: profilePictureSchema,
|
schema: profilePictureSchema,
|
||||||
ClassRef: ProfilePictureDto,
|
ClassRef: ProfilePictureDto,
|
||||||
execute: (instance, data) => chatController.getBusinessProfile(instance, data),
|
execute: (instance, data) =>
|
||||||
|
chatController.fetchBusinessProfile(instance, data),
|
||||||
});
|
});
|
||||||
|
|
||||||
return res.status(HttpStatus.OK).json(response);
|
return res.status(HttpStatus.OK).json(response);
|
||||||
|
@ -29,9 +29,6 @@ import makeWASocket, {
|
|||||||
WAMessage,
|
WAMessage,
|
||||||
WAMessageUpdate,
|
WAMessageUpdate,
|
||||||
WASocket,
|
WASocket,
|
||||||
WAReadReceiptsValue,
|
|
||||||
WAPrivacyValue,
|
|
||||||
WAPrivacyOnlineValue,
|
|
||||||
} from '@evolution/base';
|
} from '@evolution/base';
|
||||||
import {
|
import {
|
||||||
Auth,
|
Auth,
|
||||||
@ -1502,6 +1499,9 @@ export class WAStartupService {
|
|||||||
await this.client.updateOnlinePrivacy(settings.privacySettings.online);
|
await this.client.updateOnlinePrivacy(settings.privacySettings.online);
|
||||||
await this.client.updateLastSeenPrivacy(settings.privacySettings.last);
|
await this.client.updateLastSeenPrivacy(settings.privacySettings.last);
|
||||||
await this.client.updateGroupsAddPrivacy(settings.privacySettings.groupadd);
|
await this.client.updateGroupsAddPrivacy(settings.privacySettings.groupadd);
|
||||||
|
|
||||||
|
// reinicia a instancia
|
||||||
|
|
||||||
return { update: 'success', data: await this.client.fetchPrivacySettings() };
|
return { update: 'success', data: await this.client.fetchPrivacySettings() };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new InternalServerErrorException(
|
throw new InternalServerErrorException(
|
||||||
@ -1511,7 +1511,7 @@ export class WAStartupService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getBusinessProfile(number: string) {
|
public async fetchBusinessProfile(number: string) {
|
||||||
try {
|
try {
|
||||||
let jid;
|
let jid;
|
||||||
|
|
||||||
|
24
start.sh
Normal file
24
start.sh
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ "$DOCKER_ENV" = "true" ];
|
||||||
|
then
|
||||||
|
echo "Enabling environment variables for Docker"
|
||||||
|
echo "DOCKER_ENV=$DOCKER_ENV"
|
||||||
|
echo
|
||||||
|
else
|
||||||
|
cp ./src/env.yml ./dist/src
|
||||||
|
fi
|
||||||
|
echo "> removing dist"
|
||||||
|
rm -rf ./dist
|
||||||
|
echo
|
||||||
|
echo "> transpiling..."
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "> Successfully build "
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "> Starting application..."
|
||||||
|
echo
|
||||||
|
|
||||||
|
node ./dist/src/main.js
|
Loading…
Reference in New Issue
Block a user