Skip to content

Commit 540636d

Browse files
committed
[core] Fix MongoDB
1 parent 3cc7843 commit 540636d

4 files changed

Lines changed: 8 additions & 7 deletions

File tree

src/apps/app_sdk/services/AppsDisabledService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Injectable, UnprocessableEntityException } from '@nestjs/common';
22
import { IAppsService } from '@waha/apps/app_sdk/services/IAppsService';
3+
import { DataStore } from '@waha/core/abc/DataStore';
34
import { SessionManager } from '@waha/core/abc/manager.abc';
45
import { WhatsappSession } from '@waha/core/abc/session.abc';
56
import { Knex } from 'knex';
@@ -36,7 +37,7 @@ export class AppsDisabledService implements IAppsService {
3637
return;
3738
}
3839

39-
async beforeSessionStart(session: WhatsappSession, knex) {
40+
async beforeSessionStart(session: WhatsappSession, store: DataStore) {
4041
return;
4142
}
4243
}

src/apps/app_sdk/services/AppsEnabledService.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { migrate } from '@waha/apps/app_sdk/migrations';
33
import { IAppService } from '@waha/apps/app_sdk/services/IAppService';
44
import { IAppsService } from '@waha/apps/app_sdk/services/IAppsService';
55
import { ChatWootAppService } from '@waha/apps/chatwoot/services/ChatWootAppService';
6+
import { DataStore } from '@waha/core/abc/DataStore';
67
import { SessionManager } from '@waha/core/abc/manager.abc';
78
import { WhatsappSession } from '@waha/core/abc/session.abc';
89
import { generatePrefixedId } from '@waha/utils/ids';
@@ -106,7 +107,8 @@ export class AppsEnabledService implements IAppsService {
106107
return;
107108
}
108109

109-
async beforeSessionStart(session: WhatsappSession, knex) {
110+
async beforeSessionStart(session: WhatsappSession, store: DataStore) {
111+
const knex = store.getWAHADatabase();
110112
const repo = new AppRepository(knex);
111113
const apps = await repo.getAllBySession(session.name);
112114
for (const app of apps) {

src/apps/app_sdk/services/IAppsService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { App } from '@waha/apps/app_sdk/dto/app.dto';
2+
import { DataStore } from '@waha/core/abc/DataStore';
23
import { SessionManager } from '@waha/core/abc/manager.abc';
34
import { WhatsappSession } from '@waha/core/abc/session.abc';
45
import { Knex } from 'knex';
@@ -12,7 +13,7 @@ export interface IAppsService {
1213

1314
delete(manager: SessionManager, appId: string): Promise<void>;
1415

15-
beforeSessionStart(session: WhatsappSession, knex: Knex): Promise<void>;
16+
beforeSessionStart(session: WhatsappSession, store: DataStore): Promise<void>;
1617

1718
migrate(knex: Knex): Promise<void>;
1819
}

src/core/abc/manager.abc.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,7 @@ export abstract class SessionManager
103103
}
104104

105105
async configureApps(session: WhatsappSession) {
106-
await this.appsService.beforeSessionStart(
107-
session,
108-
this.store.getWAHADatabase(),
109-
);
106+
await this.appsService.beforeSessionStart(session, this.store);
110107
}
111108

112109
//

0 commit comments

Comments
 (0)