From bcaed7ec694cf23cc7619200c955c769005cb2b0 Mon Sep 17 00:00:00 2001 From: mirarifhasan Date: Thu, 23 May 2024 15:10:46 +0600 Subject: [PATCH] feat: added query to see is smtp enabled or not --- .../hoppscotch-backend/src/admin/infra.resolver.ts | 8 ++++++++ .../src/infra-config/infra-config.service.ts | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/packages/hoppscotch-backend/src/admin/infra.resolver.ts b/packages/hoppscotch-backend/src/admin/infra.resolver.ts index 1c08e9a2f..83bdd6a9c 100644 --- a/packages/hoppscotch-backend/src/admin/infra.resolver.ts +++ b/packages/hoppscotch-backend/src/admin/infra.resolver.ts @@ -292,6 +292,14 @@ export class InfraResolver { return this.infraConfigService.getAllowedAuthProviders(); } + @Query(() => Boolean, { + description: 'Check if the SMTP is enabled or not', + }) + @UseGuards(GqlAuthGuard) + isSMTPEnabled() { + return this.infraConfigService.isSMTPEnabled(); + } + /* Mutations */ @Mutation(() => [InfraConfig], { diff --git a/packages/hoppscotch-backend/src/infra-config/infra-config.service.ts b/packages/hoppscotch-backend/src/infra-config/infra-config.service.ts index 7ed744d47..845c33130 100644 --- a/packages/hoppscotch-backend/src/infra-config/infra-config.service.ts +++ b/packages/hoppscotch-backend/src/infra-config/infra-config.service.ts @@ -316,6 +316,16 @@ export class InfraConfigService implements OnModuleInit { .split(','); } + /** + * Check if SMTP is enabled or not + * @returns boolean + */ + isSMTPEnabled() { + return ( + this.configService.get('INFRA.MAILER_SMTP_ENABLE') === 'true' + ); + } + /** * Reset all the InfraConfigs to their default values (from .env) */