File size: 965 Bytes
4327358
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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;
  }
}