Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79e5c0589d | ||
|
|
f6679b7368 | ||
|
|
a3c0b86b67 | ||
|
|
c8f48dd62b | ||
|
|
aed157697a | ||
|
|
913b8606d9 | ||
|
|
7cadbad36e | ||
|
|
abb5bdffcc | ||
|
|
6a44c15dd3 |
No files matched your search
@@ -10,6 +10,7 @@ import {
|
||||
ServerDebugController,
|
||||
} from '@waha/api/server.controller';
|
||||
import { WebsocketGatewayCore } from '@waha/core/api/websocket.gateway.core';
|
||||
import { WebJSEngineConfigService } from '@waha/core/config/WebJSEngineConfigService';
|
||||
import { MediaLocalStorageModule } from '@waha/core/media/local/media.local.storage.module';
|
||||
import { MediaLocalStorageConfig } from '@waha/core/media/local/MediaLocalStorageConfig';
|
||||
import { BufferJsonReplacerInterceptor } from '@waha/nestjs/BufferJsonReplacerInterceptor';
|
||||
@@ -146,6 +147,7 @@ const PROVIDERS = [
|
||||
},
|
||||
DashboardConfigServiceCore,
|
||||
SwaggerConfigServiceCore,
|
||||
WebJSEngineConfigService,
|
||||
WhatsappConfigService,
|
||||
EngineConfigService,
|
||||
WebsocketGatewayCore,
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
|
||||
import { WebJSConfig } from '../../core/engines/webjs/session.webjs.core';
|
||||
|
||||
@Injectable()
|
||||
export class WebJSEngineConfigService {
|
||||
constructor(protected configService: ConfigService) {}
|
||||
|
||||
getConfig(): WebJSConfig {
|
||||
let webVersion = this.configService.get<string>(
|
||||
'WAHA_WEBJS_WEB_VERSION',
|
||||
undefined,
|
||||
);
|
||||
if (webVersion === '2.2412.54-videofix') {
|
||||
// Deprecated version
|
||||
webVersion = undefined;
|
||||
}
|
||||
return {
|
||||
webVersion: webVersion,
|
||||
cacheType: this.getCacheType(),
|
||||
};
|
||||
}
|
||||
|
||||
getCacheType(): 'local' | 'none' {
|
||||
const cacheType = this.configService
|
||||
.get<string>('WAHA_WEBJS_CACHE_TYPE', 'none')
|
||||
.toLowerCase();
|
||||
if (cacheType != 'local' && cacheType != 'none') {
|
||||
throw new Error(
|
||||
'Invalid cache type, only "local" and "none" are allowed',
|
||||
);
|
||||
}
|
||||
|
||||
return cacheType;
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import makeWASocket, {
|
||||
normalizeMessageContent,
|
||||
PresenceData,
|
||||
proto,
|
||||
SocketConfig,
|
||||
WAMessageContent,
|
||||
WAMessageKey,
|
||||
WAMessageUpdate,
|
||||
@@ -194,6 +195,7 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
|
||||
private autoRestartJob: SinglePeriodicJobRunner;
|
||||
private msgRetryCounterCache: NodeCache;
|
||||
private placeholderResendCache: NodeCache;
|
||||
protected engineLogger: BaileysLogger;
|
||||
|
||||
private authNOWEBStore: any;
|
||||
@@ -213,6 +215,10 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
stdTTL: 60 * 60, // 1 hour
|
||||
useClones: false,
|
||||
});
|
||||
this.placeholderResendCache = new NodeCache({
|
||||
stdTTL: 60 * 60, // 1 hour
|
||||
useClones: false,
|
||||
});
|
||||
|
||||
this.engineLogger = this.loggerBuilder.child({
|
||||
name: 'NOWEBEngine',
|
||||
@@ -252,7 +258,7 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
await this.sock?.logout();
|
||||
}
|
||||
|
||||
getSocketConfig(agent, state): any {
|
||||
getSocketConfig(agent, state): Partial<SocketConfig> {
|
||||
const fullSyncEnabled = this.sessionConfig?.noweb?.store?.fullSync || false;
|
||||
const browser = fullSyncEnabled
|
||||
? Browsers.ubuntu('Desktop')
|
||||
@@ -278,6 +284,7 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
getMessage: (key) => this.getMessage(key),
|
||||
syncFullHistory: fullSyncEnabled,
|
||||
msgRetryCounterCache: this.msgRetryCounterCache,
|
||||
placeholderResendCache: this.placeholderResendCache,
|
||||
markOnlineOnConnect: markOnlineOnConnect,
|
||||
};
|
||||
}
|
||||
@@ -291,7 +298,10 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
}
|
||||
const { state, saveCreds } = this.authNOWEBStore;
|
||||
const agent = this.makeAgent();
|
||||
const socketConfig = this.getSocketConfig(agent, state);
|
||||
const socketConfig: SocketConfig = this.getSocketConfig(
|
||||
agent,
|
||||
state,
|
||||
) as SocketConfig;
|
||||
const sock = makeWASocket(socketConfig);
|
||||
sock.ev.on('creds.update', saveCreds);
|
||||
return sock;
|
||||
|
||||
@@ -99,6 +99,7 @@ const QRCode = require('qrcode');
|
||||
|
||||
export interface WebJSConfig {
|
||||
webVersion?: string;
|
||||
cacheType: 'local' | 'none';
|
||||
}
|
||||
|
||||
export class WhatsappSessionWebJSCore extends WhatsappSession {
|
||||
@@ -143,7 +144,11 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
|
||||
const path = this.getClassDirName();
|
||||
const webVersion =
|
||||
this.engineConfig?.webVersion || '2.3000.1018072227-alpha';
|
||||
this.logger.info(`Using web version: '${webVersion}'`);
|
||||
const cacheType = this.engineConfig?.cacheType || 'none';
|
||||
this.logger.info(`Using cache type: '${cacheType}'`);
|
||||
if (cacheType === 'local') {
|
||||
this.logger.info(`Using web version: '${webVersion}'`);
|
||||
}
|
||||
return {
|
||||
puppeteer: {
|
||||
headless: true,
|
||||
@@ -153,8 +158,7 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
|
||||
},
|
||||
webVersion: webVersion,
|
||||
webVersionCache: {
|
||||
// type: 'none',
|
||||
type: 'local',
|
||||
type: cacheType,
|
||||
path: path,
|
||||
strict: true,
|
||||
},
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
NotFoundException,
|
||||
UnprocessableEntityException,
|
||||
} from '@nestjs/common';
|
||||
import { WebJSEngineConfigService } from '@waha/core/config/WebJSEngineConfigService';
|
||||
import { WebhookConductor } from '@waha/core/integrations/webhooks/WebhookConductor';
|
||||
import { MediaStorageFactory } from '@waha/core/media/MediaStorageFactory';
|
||||
import { DefaultMap } from '@waha/utils/DefaultMap';
|
||||
@@ -11,7 +12,7 @@ import { promiseTimeout, sleep } from '@waha/utils/promiseTimeout';
|
||||
import { complete } from '@waha/utils/reactive/complete';
|
||||
import { SwitchObservable } from '@waha/utils/reactive/SwitchObservable';
|
||||
import { PinoLogger } from 'nestjs-pino';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, retry, share } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { WhatsappConfigService } from '../config.service';
|
||||
@@ -69,6 +70,7 @@ export class SessionManagerCore extends SessionManager {
|
||||
constructor(
|
||||
config: WhatsappConfigService,
|
||||
private engineConfigService: EngineConfigService,
|
||||
private webjsEngineConfigService: WebJSEngineConfigService,
|
||||
log: PinoLogger,
|
||||
private mediaStorageFactory: MediaStorageFactory,
|
||||
) {
|
||||
@@ -77,6 +79,14 @@ export class SessionManagerCore extends SessionManager {
|
||||
this.sessionConfig = null;
|
||||
const engineName = this.engineConfigService.getDefaultEngineName();
|
||||
this.EngineClass = this.getEngine(engineName);
|
||||
|
||||
this.events2 = new DefaultMap<WAHAEvents, SwitchObservable<any>>(
|
||||
(key) =>
|
||||
new SwitchObservable((obs$) => {
|
||||
return obs$.pipe(retry(), share());
|
||||
}),
|
||||
);
|
||||
|
||||
this.store = new LocalStoreCore(engineName.toLowerCase());
|
||||
this.sessionAuthRepository = new LocalSessionAuthRepository(this.store);
|
||||
this.startPredefinedSessions();
|
||||
@@ -167,6 +177,9 @@ export class SessionManagerCore extends SessionManager {
|
||||
proxyConfig: proxyConfig,
|
||||
sessionConfig: this.sessionConfig,
|
||||
};
|
||||
if (this.EngineClass === WhatsappSessionWebJSCore) {
|
||||
sessionConfig.engineConfig = this.webjsEngineConfigService.getConfig();
|
||||
}
|
||||
await this.sessionAuthRepository.init(name);
|
||||
// @ts-ignore
|
||||
const session = new this.EngineClass(sessionConfig);
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ export function getEngineName(): string {
|
||||
}
|
||||
|
||||
export const VERSION: WAHAEnvironment = {
|
||||
version: '2024.11.5',
|
||||
version: '2024.11.9',
|
||||
engine: getEngineName(),
|
||||
tier: getWAHAVersion(),
|
||||
browser: getBrowserExecutablePath(),
|
||||
|
||||
@@ -7,7 +7,7 @@ __metadata:
|
||||
|
||||
"@adiwajshing/baileys@github:devlikeapro/Baileys#fork-master-channels-678":
|
||||
version: 6.7.8
|
||||
resolution: "@adiwajshing/baileys@https://github.com/devlikeapro/Baileys.git#commit=e2d6246da89a4775a8482fbe8de2a42b8421516d"
|
||||
resolution: "@adiwajshing/baileys@https://github.com/devlikeapro/Baileys.git#commit=1cb6831ab696f8fdcdbb95c0d4dc218c39156a8f"
|
||||
dependencies:
|
||||
"@adiwajshing/keyed-db": ^0.2.4
|
||||
"@hapi/boom": ^9.1.3
|
||||
@@ -39,7 +39,7 @@ __metadata:
|
||||
optional: true
|
||||
sharp:
|
||||
optional: true
|
||||
checksum: 43ac116fcc3eca176ff036a296c99d8be39bdcaafb788fb65305ee06d59060f0b8b8d5dee8596d9dca9794843dd76e90769e5acfa6d14ff55ad2a0f2616686e3
|
||||
checksum: 3052043e1085db9a82dd5046ab0899603fb81705e46c62b9b6234348d288bce7eb27b57b5e48eda7716159a102ee81edf30efc688b93ca898e76e74b92340e5b
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
||||
Reference in new issue
Block a user