From 9269606c76d99fe6444a78955edddd4dc86cec1c Mon Sep 17 00:00:00 2001 From: Nawaz Dhandala Date: Fri, 22 Apr 2022 15:33:21 +0100 Subject: [PATCH] fix compile errors --- .../Middleware/ClusterKeyAuthorization.ts | 18 +++++++----------- Mail/Services/MailService.ts | 13 ++++++++++--- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/CommonServer/Middleware/ClusterKeyAuthorization.ts b/CommonServer/Middleware/ClusterKeyAuthorization.ts index d23781812b..dcc608bb78 100644 --- a/CommonServer/Middleware/ClusterKeyAuthorization.ts +++ b/CommonServer/Middleware/ClusterKeyAuthorization.ts @@ -7,6 +7,7 @@ import { import { sendErrorResponse } from '../Utils/Response'; import BadDataException from 'Common/Types/Exception/BadDataException'; +import ObjectID from 'Common/Types/ObjectID'; export default class ClusterKeyAuthorization { public static async isAuthorizedService( @@ -14,22 +15,17 @@ export default class ClusterKeyAuthorization { res: ExpressResponse, next: NextFunction ): Promise { - let clusterKey: string; + let clusterKey: ObjectID; if (req.params && req.params['clusterKey']) { - clusterKey = req.params['clusterKey']; + clusterKey = new ObjectID(req.params['clusterKey']); } else if (req.query && req.query['clusterKey']) { - clusterKey = req.query['clusterKey'] as string; - } else if ( - req.headers && - (req.headers['clusterkey'] || req.headers['clusterkey']) - ) { + clusterKey = new ObjectID(req.query['clusterKey'] as string); + } else if (req.headers && req.headers['clusterkey']) { // Header keys are automatically transformed to lowercase - clusterKey = - (req.headers['clusterkey'] as string) || - (req.headers['clusterkey'] as string); + clusterKey = new ObjectID(req.headers['clusterkey'] as string); } else if (req.body && req.body.clusterKey) { - clusterKey = req.body.clusterKey; + clusterKey = new ObjectID(req.body.clusterKey); } else { return sendErrorResponse( req, diff --git a/Mail/Services/MailService.ts b/Mail/Services/MailService.ts index 09110a8688..abd8e1b241 100755 --- a/Mail/Services/MailService.ts +++ b/Mail/Services/MailService.ts @@ -137,8 +137,11 @@ export default class MailService { // Localcache templates, so we dont read from disk all the time. let templateData: string; - if (LocalCache.hasValue(emailTemplateType)) { - templateData = LocalCache.get(emailTemplateType); + if (LocalCache.hasValue('email-templates', emailTemplateType)) { + templateData = LocalCache.get( + 'email-templates', + emailTemplateType + ) as string; } else { templateData = await fsp.readFile( Path.resolve( @@ -148,7 +151,11 @@ export default class MailService { ), { encoding: 'utf8', flag: 'r' } ); - LocalCache.set(emailTemplateType, templateData); + LocalCache.set( + 'email-templates', + emailTemplateType, + templateData as string + ); } const emailBody: Handlebars.TemplateDelegate =