Wrap up Front chat (#1085)

* Wrap up Front chat

* Wrap up Front chat
This commit is contained in:
Charles Bochet
2023-08-04 19:22:54 -07:00
committed by GitHub
parent 57c465176a
commit 6008789a17
19 changed files with 91 additions and 75 deletions

View File

@ -4,6 +4,7 @@ import { ConfigService } from '@nestjs/config';
import { AwsRegion } from './interfaces/aws-region.interface';
import { StorageType } from './interfaces/storage.interface';
import { SupportDriver } from './interfaces/support.interface';
@Injectable()
export class EnvironmentService {
@ -103,14 +104,14 @@ export class EnvironmentService {
}
getSupportDriver(): string {
return this.configService.get<string>('SUPPORT_DRIVER') ?? 'front';
return this.configService.get<string>('SUPPORT_DRIVER') ?? SupportDriver.None;
}
getSupportFrontendKey(): string | null {
return this.configService.get<string>('SUPPORT_FRONTEND_KEY') ?? null;
getSupportFrontChatId(): string | undefined {
return this.configService.get<string>('SUPPORT_FRONT_CHAT_ID');
}
getSupportHMACKey(): string | null {
return this.configService.get<string>('SUPPORT_HMAC_KEY') ?? null;
getSupportFrontHMACKey(): string | undefined {
return this.configService.get<string>('SUPPORT_FRONT_HMAC_KEY');
}
}

View File

@ -16,6 +16,7 @@ import { StorageType } from './interfaces/storage.interface';
import { AwsRegion } from './interfaces/aws-region.interface';
import { IsAWSRegion } from './decorators/is-aws-region.decorator';
import { CastToBoolean } from './decorators/cast-to-boolean.decorator';
import { SupportDriver } from './interfaces/support.interface';
export class EnvironmentVariables {
// Misc
@ -104,6 +105,19 @@ export class EnvironmentVariables {
@IsString()
@ValidateIf((env) => env.STORAGE_TYPE === StorageType.Local)
STORAGE_LOCAL_PATH?: string;
// Support
@IsEnum(SupportDriver)
@IsOptional()
SUPPORT_DRIVER?: SupportDriver;
@ValidateIf((env) => env.SUPPORT_DRIVER === SupportDriver.Front)
@IsString()
SUPPORT_FRONT_CHAT_ID?: AwsRegion;
@ValidateIf((env) => env.SUPPORT_DRIVER === SupportDriver.Front)
@IsString()
SUPPORT_FRONT_HMAC_KEY?: string;
}
export function validate(config: Record<string, unknown>) {

View File

@ -0,0 +1,4 @@
export enum SupportDriver {
None = 'none',
Front = 'front',
}