Skip to content

Commit

Permalink
[core] WEBJS videofix
Browse files Browse the repository at this point in the history
  • Loading branch information
devlikepro committed May 22, 2024
1 parent a3c2c1b commit 7bcd2a6
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 320 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ exclude: |
(?x)^(
^src/dashboard/.*|
^src/core/engines/webjs/.*html
^src/plus/engines/webjs/.*html
)$
repos:
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ services:
# Default - waha / waha
- WAHA_DASHBOARD_USERNAME=waha
- WAHA_DASHBOARD_PASSWORD=waha
# Engine specific environment variables
# - WAHA_WEBJS_WEB_VERSION=2.2412.54-videofix
restart: always

whatsapp-http-api-plus--mongodb:
Expand Down
2 changes: 1 addition & 1 deletion nest-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"sourceRoot": "src",
"compilerOptions": {
"plugins": ["@nestjs/swagger"],
"assets": ["dashboard/**", "core/engines/webjs/*"],
"assets": ["dashboard/**", "core/engines/webjs/*", "plus/engines/webjs/*"],
"watchAssets": true
}
}
4 changes: 4 additions & 0 deletions src/core/abc/session.abc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export interface SessionParams {
sessionStore: DataStore;
proxyConfig?: ProxyConfig;
sessionConfig?: SessionConfig;
engineConfig?: any;
}

export abstract class WhatsappSession {
Expand All @@ -93,6 +94,7 @@ export abstract class WhatsappSession {
protected sessionStore: DataStore;
protected proxyConfig?: ProxyConfig;
public sessionConfig?: SessionConfig;
protected engineConfig?: any;

private _status: WAHASessionStatus;

Expand All @@ -103,6 +105,7 @@ export abstract class WhatsappSession {
proxyConfig,
mediaManager,
sessionConfig,
engineConfig,
}: SessionParams) {
this.events = new EventEmitter();
this.name = name;
Expand All @@ -111,6 +114,7 @@ export abstract class WhatsappSession {
this.sessionStore = sessionStore;
this.mediaManager = mediaManager;
this.sessionConfig = sessionConfig;
this.engineConfig = engineConfig;
}

protected set status(value: WAHASessionStatus) {
Expand Down
316 changes: 0 additions & 316 deletions src/core/engines/webjs/2.2412.54-videofix.html

This file was deleted.

19 changes: 16 additions & 3 deletions src/core/engines/webjs/session.webjs.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ const QRCode = require('qrcode');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const qrcode = require('qrcode-terminal');

export interface WebJSConfig {
webVersion?: string;
}

export class WhatsappSessionWebJSCore extends WhatsappSession {
engine = WAHAEngine.WEBJS;
protected engineConfig?: WebJSConfig;

whatsapp: Client;
protected qr: QR;
Expand All @@ -73,16 +78,24 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
this.qr = new QR();
}

/**
* Folder with the current class
*/
protected getClassDirName() {
return __dirname;
}

protected getClientOptions(): ClientOptions {
// Folder with current file
const path = __dirname;
const path = this.getClassDirName();
const webVersion = this.engineConfig?.webVersion || '2.2412.54';
this.log.debug(`Using web version: '${webVersion}'`);
return {
puppeteer: {
headless: true,
executablePath: this.getBrowserExecutablePath(),
args: this.getBrowserArgsForPuppeteer(),
},
webVersion: '2.2412.54',
webVersion: webVersion,
webVersionCache: {
type: 'local',
path: path,
Expand Down

0 comments on commit 7bcd2a6

Please sign in to comment.