chore: Tidy up unused variables, etc (#14289)

This commit is contained in:
Erik authored and GitHub committed 2024-04-02 22:06:42 +00:00
1 parent 2aada9a7da
commit cdf059361e
18 files changed
+30 -40

No files matched your search

@@ -4,9 +4,11 @@ import { google } from "googleapis";
import { z } from "zod";
@Injectable()
export class GcalService {
export class GCalService {
private logger = new Logger("GcalService");
private gcalResponseSchema = z.object({ client_id: z.string(), client_secret: z.string() });
constructor(private readonly appsRepository: AppsRepository) {}
async getOAuthClient(redirectUri: string) {
@@ -17,9 +19,7 @@ export class GcalService {
throw new NotFoundException();
}
const { client_id, client_secret } = z
.object({ client_id: z.string(), client_secret: z.string() })
.parse(app.keys);
const { client_id, client_secret } = this.gcalResponseSchema.parse(app.keys);
const oAuth2Client = new google.auth.OAuth2(client_id, client_secret, redirectUri);
return oAuth2Client;
@@ -38,7 +38,7 @@ export class OrganizationRolesGuard implements CanActivate {
async isPlatform(organizationId: number) {
const isPlatform = await this.organizationsService.isPlatform(organizationId);
if (!isPlatform) {
throw new ForbiddenException("Organization is not a platform.");
throw new ForbiddenException("Organization is not a platform (SHP).");
}
}
@@ -27,6 +27,7 @@ export class OAuthClientUsersService {
const username = generateShortHash(body.email, oAuthClientId);
user = await this.userRepository.create(body, username, oAuthClientId, isPlatformManaged);
} else {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [_, emailDomain] = body.email.split("@");
user = (
await createNewUsersConnectToOrgIfExists({
@@ -1,20 +1,18 @@
import { TokenExpiredException } from "@/modules/auth/guards/access-token/token-expired.exception";
import { OAuthClientRepository } from "@/modules/oauth-clients/oauth-client.repository";
import { TokensRepository } from "@/modules/tokens/tokens.repository";
import { BadRequestException, Injectable, Logger, UnauthorizedException } from "@nestjs/common";
import { BadRequestException, Injectable, UnauthorizedException } from "@nestjs/common";
import { INVALID_ACCESS_TOKEN } from "@calcom/platform-constants";
@Injectable()
export class OAuthFlowService {
private logger = new Logger("OAuthFlowService");
constructor(
private readonly tokensRepository: TokensRepository,
private readonly oAuthClientRepository: OAuthClientRepository
) //private readonly redisService: RedisIOService
{}
private readonly oAuthClientRepository: OAuthClientRepository //private readonly redisService: RedisIOService
) {}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async propagateAccessToken(accessToken: string) {
// this.logger.log("Propagating access token to redis", accessToken);
// TODO propagate
@@ -48,6 +46,7 @@ export class OAuthFlowService {
return true;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
private async readFromCache(secret: string) {
return { status: "CACHE_MISS" };
}
@@ -7,7 +7,7 @@ import { PrismaClient } from "@prisma/client";
export class PrismaReadService implements OnModuleInit {
public prisma: PrismaClient;
constructor(private readonly configService: ConfigService) {
constructor(readonly configService: ConfigService) {
const dbUrl = configService.get("db.readUrl", { infer: true });
this.prisma = new PrismaClient({
@@ -7,7 +7,7 @@ import { PrismaClient } from "@prisma/client";
export class PrismaWriteService implements OnModuleInit {
public prisma: PrismaClient;
constructor(private readonly configService: ConfigService) {
constructor(readonly configService: ConfigService) {
const dbUrl = configService.get("db.writeUrl", { infer: true });
this.prisma = new PrismaClient({
@@ -1,10 +1,9 @@
import { PrismaReadService } from "@/modules/prisma/prisma-read.service";
import { PrismaWriteService } from "@/modules/prisma/prisma-write.service";
import { Injectable } from "@nestjs/common";
@Injectable()
export class SelectedCalendarsRepository {
constructor(private readonly dbRead: PrismaReadService, private readonly dbWrite: PrismaWriteService) {}
constructor(private readonly dbWrite: PrismaWriteService) {}
createSelectedCalendar(externalId: string, credentialId: number, userId: number, integration: string) {
return this.dbWrite.prisma.selectedCalendar.create({