Skip to content

Commit 80ae86b

Browse files
committed
fix: chatwoot screen
1 parent c20a3b6 commit 80ae86b

File tree

7 files changed

+36
-16
lines changed

7 files changed

+36
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* Fixed use chatwoot with evolution channel
1414
* Fix chatwoot reply quote with Cloud API
1515
* Use exchange name from .env on RabbitMQ
16+
* Fixed chatwoot screen
1617

1718
# 2.1.0 (2024-08-26 15:33)
1819

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manager/dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<link rel="icon" type="image/png" href="/assets/images/evolution-logo.png" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Evolution Manager</title>
8-
<script type="module" crossorigin src="/assets/index-B-Bdu2zN.js"></script>
8+
<script type="module" crossorigin src="/assets/index-DOHK1pp9.js"></script>
99
<link rel="stylesheet" crossorigin href="/assets/index-DNOCacL_.css">
1010
</head>
1111
<body>

src/api/controllers/instance.controller.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ export class InstanceController {
4646
providerFiles: this.providerFiles,
4747
});
4848

49+
if (!instance) {
50+
throw new BadRequestException('Invalid integration');
51+
}
52+
4953
const instanceId = v4();
5054

5155
instanceData.instanceId = instanceId;
@@ -62,6 +66,7 @@ export class InstanceController {
6266
hash,
6367
number: instanceData.number,
6468
businessId: instanceData.businessId,
69+
status: instanceData.status,
6570
});
6671

6772
instance.setInstance({
@@ -146,7 +151,7 @@ export class InstanceController {
146151
integration: instanceData.integration,
147152
webhookWaBusiness,
148153
accessTokenWaBusiness,
149-
status: 'created',
154+
status: instance.connectionStatus.state,
150155
},
151156
hash,
152157
webhook: {
@@ -233,7 +238,7 @@ export class InstanceController {
233238
integration: instanceData.integration,
234239
webhookWaBusiness,
235240
accessTokenWaBusiness,
236-
status: 'created',
241+
status: instance.connectionStatus.state,
237242
},
238243
hash,
239244
webhook: {

src/api/dto/instance.dto.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export class InstanceDto extends IntegrationDto {
99
number?: string;
1010
integration?: string;
1111
token?: string;
12+
status?: string;
1213
// settings
1314
rejectCall?: boolean;
1415
msgCall?: string;

src/api/integrations/channel/channel.controller.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,18 @@ export class ChannelController {
8080
);
8181
}
8282

83-
return new BaileysStartupService(
84-
data.configService,
85-
data.eventEmitter,
86-
data.prismaRepository,
87-
data.cache,
88-
data.chatwootCache,
89-
data.baileysCache,
90-
data.providerFiles,
91-
);
83+
if (instanceData.integration === Integration.WHATSAPP_BAILEYS) {
84+
return new BaileysStartupService(
85+
data.configService,
86+
data.eventEmitter,
87+
data.prismaRepository,
88+
data.cache,
89+
data.chatwootCache,
90+
data.baileysCache,
91+
data.providerFiles,
92+
);
93+
}
94+
95+
return null;
9296
}
9397
}

src/api/services/monitor.service.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,17 @@ export class WAMonitoringService {
118118
public async cleaningUp(instanceName: string) {
119119
let instanceDbId: string;
120120
if (this.db.SAVE_DATA.INSTANCE) {
121+
const findInstance = await this.prismaRepository.instance.findFirst({
122+
where: { name: instanceName },
123+
});
124+
125+
if (!findInstance) this.logger.error('Instance not found');
126+
121127
const instance = await this.prismaRepository.instance.update({
122128
where: { name: instanceName },
123129
data: { connectionStatus: 'close' },
124130
});
125131

126-
if (!instance) this.logger.error('Instance not found');
127-
128132
rmSync(join(INSTANCE_DIR, instance.id), { recursive: true, force: true });
129133

130134
instanceDbId = instance.id;
@@ -150,6 +154,8 @@ export class WAMonitoringService {
150154
where: { name: instanceName },
151155
});
152156

157+
if (!instance) return;
158+
153159
rmSync(join(INSTANCE_DIR, instance.id), { recursive: true, force: true });
154160

155161
await this.prismaRepository.session.deleteMany({ where: { sessionId: instance.id } });
@@ -194,7 +200,8 @@ export class WAMonitoringService {
194200
data: {
195201
id: data.instanceId,
196202
name: data.instanceName,
197-
connectionStatus: data.integration && data.integration === Integration.WHATSAPP_BAILEYS ? 'close' : 'open',
203+
connectionStatus:
204+
data.integration && data.integration === Integration.WHATSAPP_BAILEYS ? 'close' : data.status ?? 'open',
198205
number: data.number,
199206
integration: data.integration || Integration.WHATSAPP_BAILEYS,
200207
token: data.hash,
@@ -226,6 +233,8 @@ export class WAMonitoringService {
226233
providerFiles: this.providerFiles,
227234
});
228235

236+
if (!instance) return;
237+
229238
instance.setInstance({
230239
instanceId: instanceData.instanceId,
231240
instanceName: instanceData.instanceName,

0 commit comments

Comments
 (0)