From 7d29c79d4d53934e21ea352a274fdecb163f52cd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Minelli?= <michael@minelli.me>
Date: Wed, 5 Jul 2023 17:46:17 +0200
Subject: [PATCH] DojoValidator => Remove unused vars and validators

---
 ExpressAPI/src/helpers/DojoValidators.ts | 36 ++----------------------
 1 file changed, 3 insertions(+), 33 deletions(-)

diff --git a/ExpressAPI/src/helpers/DojoValidators.ts b/ExpressAPI/src/helpers/DojoValidators.ts
index 09b7c82..ca7124c 100644
--- a/ExpressAPI/src/helpers/DojoValidators.ts
+++ b/ExpressAPI/src/helpers/DojoValidators.ts
@@ -1,4 +1,4 @@
-import ApiRequest                                                   from '../models/ApiRequest';
+import ApiRequest                                                   from '../types/ApiRequest';
 import Config                                                       from '../config/Config';
 import { StatusCodes }                                              from 'http-status-codes';
 import { CustomValidator, ErrorMessage, FieldMessageFactory, Meta } from 'express-validator/src/base';
@@ -36,11 +36,7 @@ class DojoValidators {
     }
 
     readonly nullSanitizer = this.toValidatorSchemaOptions({
-                                                               options: (value, {
-                                                                   req,
-                                                                   location,
-                                                                   path
-                                                               }) => {
+                                                               options: (value) => {
                                                                    try {
                                                                        return value == 'null' || value == 'undefined' || value == '' ? null : value;
                                                                    } catch ( e ) {
@@ -50,11 +46,7 @@ class DojoValidators {
                                                            });
 
     readonly jsonSanitizer = this.toValidatorSchemaOptions({
-                                                               options: (value, {
-                                                                   req,
-                                                                   location,
-                                                                   path
-                                                               }) => {
+                                                               options: (value) => {
                                                                    try {
                                                                        return JSON.parse(value);
                                                                    } catch ( e ) {
@@ -68,7 +60,6 @@ class DojoValidators {
                                                                       errorMessage: 'Template doesn\'t exist or you don\'t have access to it',
                                                                       options     : (value, {
                                                                           req,
-                                                                          location,
                                                                           path
                                                                       }) => {
                                                                           return new Promise((resolve, reject) => {
@@ -86,7 +77,6 @@ class DojoValidators {
     readonly templateUrlSanitizer = this.toValidatorSchemaOptions({
                                                                       options: (value, {
                                                                           req,
-                                                                          location,
                                                                           path
                                                                       }) => {
                                                                           try {
@@ -101,26 +91,6 @@ class DojoValidators {
                                                                           return value;
                                                                       }
                                                                   });
-
-    readonly enonceValidator = this.toValidatorSchemaOptions({
-                                                                 bail        : true,
-                                                                 errorMessage: 'Template doesn\'t exist or you don\'t have access to it',
-                                                                 options     : (value, {
-                                                                     req,
-                                                                     location,
-                                                                     path
-                                                                 }) => {
-                                                                     return new Promise((resolve, reject) => {
-                                                                         const template = this.getParamValue(req, path);
-                                                                         if ( template ) {
-                                                                             GitlabManager.checkTemplateAccess(template, req).then((templateAccess) => {
-                                                                                 templateAccess !== StatusCodes.OK ? reject() : resolve(true);
-                                                                             });
-                                                                         }
-                                                                         resolve(true);
-                                                                     });
-                                                                 }
-                                                             });
 }
 
 
-- 
GitLab