-
-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Add WebJSEngineConfigService.ts
- Loading branch information
1 parent
abb5bdf
commit 7cadbad
Showing
4 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', 'local') | ||
.toLowerCase(); | ||
if (cacheType != 'local' && cacheType != 'none') { | ||
throw new Error( | ||
'Invalid cache type, only "local" and "none" are allowed', | ||
); | ||
} | ||
|
||
return cacheType; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters