Skip to content

Commit

Permalink
general fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jrCleber committed Jun 5, 2024
1 parent 2edfad1 commit 061bd21
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/provider/sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
* └──────────────────────────────────────────────────────────────────────────────┘
*/

import axios, { Axios } from 'axios';
import axios, { Axios, AxiosError } from 'axios';
import { Auth, ConfigService, ProviderSession } from '../config/env.config';
import { Logger } from '../config/logger.config';
import { execSync } from 'child_process';
import { writeFileSync } from 'fs';
import { join } from 'path';

type ResponseSuccess = { status: number; data?: any };
type ResponseProvider = Promise<[ResponseSuccess?, Error?]>;
Expand Down Expand Up @@ -89,7 +91,7 @@ export class ProviderFiles {
}

this._client = axios.create({
baseURL: `http://${this.config.HOST}:${this.config.PORT}/session/${this.config.PREFIX}`,
baseURL: `${url}/session/${this.config.PREFIX}`,
headers: {
apikey: globalApiToken,
},
Expand Down
1 change: 0 additions & 1 deletion src/whatsapp/controllers/instance.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ export class InstanceController {

switch (state) {
case 'close':
await instance.loadWebhook();
await instance.connectToWhatsapp();
await delay(3000);
return instance.qrCode;
Expand Down
1 change: 0 additions & 1 deletion src/whatsapp/services/monitor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ export class WAMonitoringService {
try {
if (this.providerSession.ENABLED) {
const [instances] = await this.providerFiles.allInstances();
console.log('INSTANCES: ', instances);
instances.data.forEach(async (name: string) => {
await set(name);
});
Expand Down
7 changes: 5 additions & 2 deletions src/whatsapp/services/whatsapp.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ export class WAStartupService {
const data = await this.repository.webhook.findFirst({
where: { instanceId: this.instance.id },
});
if (!data) {
return;
}

this.webhook.url = data?.url;
this.webhook.enabled = data?.enabled;
this.webhook.events = data?.events;
Expand Down Expand Up @@ -542,8 +546,7 @@ export class WAStartupService {
public async connectToWhatsapp(): Promise<WASocket> {
try {
this.instanceQr.count = 0;

this.loadWebhook();
await this.loadWebhook();
this.client = await this.setSocket();
this.eventHandler();

Expand Down

0 comments on commit 061bd21

Please sign in to comment.