feat: Added restart instance endpoint

This commit is contained in:
Davidson Gomes 2023-07-16 21:55:12 -03:00
parent 7a2fcc3469
commit 69353892d9
3 changed files with 3 additions and 21 deletions

View File

@ -3,6 +3,7 @@
### Features
* Added messages.delete event
* Added restart instance endpoint
### Fixed

View File

@ -357,24 +357,8 @@ export class InstanceController {
try {
this.logger.verbose('requested restartInstance from ' + instanceName + ' instance');
this.logger.verbose('deleting instance: ' + instanceName);
delete this.waMonitor.waInstances[instanceName];
this.logger.verbose('creating instance: ' + instanceName);
const instance = new WAStartupService(
this.configService,
this.eventEmitter,
this.repository,
this.cache,
);
instance.instanceName = instanceName;
this.logger.verbose('instance: ' + instance.instanceName + ' created');
this.logger.verbose('connecting instance: ' + instanceName);
await instance.connectToWhatsapp();
this.waMonitor.waInstances[instance.instanceName] = instance;
this.logger.verbose('logging out instance: ' + instanceName);
this.waMonitor.waInstances[instanceName]?.client?.ws?.close();
return { error: false, message: 'Instance restarted' };
} catch (error) {

View File

@ -1111,7 +1111,6 @@ export class WAStartupService {
},
'messages.update': async (args: WAMessageUpdate[], database: Database) => {
console.log(args);
this.logger.verbose('Event received: messages.update');
const status: Record<number, wa.StatusMessage> = {
0: 'ERROR',
@ -1337,7 +1336,6 @@ export class WAStartupService {
const numberReplace = number.replace(/[^0-9]/g, '');
console.log('number', numberReplace);
if (numberReplace.includes('@g.us') || numberReplace.includes('@s.whatsapp.net')) {
this.logger.verbose('Number already contains @g.us or @s.whatsapp.net');
return numberReplace;
@ -1507,7 +1505,6 @@ export class WAStartupService {
}
if (message['conversation']) {
console.log(message['conversation']);
this.logger.verbose('Sending message');
return await this.client.sendMessage(
sender,