From 09a2269fb1496a8b61a24e44d70bf0c2a92f62bb Mon Sep 17 00:00:00 2001 From: Moiz Adnan <67912355+MoizAdnan@users.noreply.github.com> Date: Fri, 16 Aug 2024 15:09:43 +0500 Subject: [PATCH] IR-2915: Re-evaluate feathers validator usage for recording services (#10545) * Fixed validators * chore: add createdAt to recordingQueryProperties --- packages/common/src/schemas/recording/recording.schema.ts | 4 ++-- .../recording-resource/recording-resource.hooks.ts | 6 +++--- .../server-core/src/recording/recording/recording.hooks.ts | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/common/src/schemas/recording/recording.schema.ts b/packages/common/src/schemas/recording/recording.schema.ts index a4a28c3f24..e73ce7344c 100644 --- a/packages/common/src/schemas/recording/recording.schema.ts +++ b/packages/common/src/schemas/recording/recording.schema.ts @@ -69,7 +69,7 @@ export interface RecordingDatabaseType extends Omit { } // Schema for creating new entries -export const recordingDataSchema = Type.Partial(recordingSchema, { +export const recordingDataSchema = Type.Pick(recordingSchema, ['schema'], { $id: 'RecordingData' }) export interface RecordingData extends Static {} @@ -81,7 +81,7 @@ export const recordingPatchSchema = Type.Partial(recordingSchema, { export interface RecordingPatch extends Static {} // Schema for allowed query properties -export const recordingQueryProperties = Type.Pick(recordingSchema, ['id', 'userId']) +export const recordingQueryProperties = Type.Pick(recordingSchema, ['id', 'userId', 'createdAt']) export const recordingQuerySchema = Type.Intersect( [ querySyntax(recordingQueryProperties), diff --git a/packages/server-core/src/recording/recording-resource/recording-resource.hooks.ts b/packages/server-core/src/recording/recording-resource/recording-resource.hooks.ts index 71ebd5bb77..80189d0970 100755 --- a/packages/server-core/src/recording/recording-resource/recording-resource.hooks.ts +++ b/packages/server-core/src/recording/recording-resource/recording-resource.hooks.ts @@ -50,20 +50,20 @@ export default { before: { all: [ - () => schemaHooks.validateQuery(recordingResourceQueryValidator), + schemaHooks.validateQuery(recordingResourceQueryValidator), schemaHooks.resolveQuery(recordingResourceQueryResolver) ], find: [iff(isProvider('external'), verifyScope('recording', 'read'))], get: [iff(isProvider('external'), verifyScope('recording', 'read'))], create: [ iff(isProvider('external'), verifyScope('recording', 'write'), verifyScope('settings', 'write')), - () => schemaHooks.validateData(recordingResourceDataValidator), + schemaHooks.validateData(recordingResourceDataValidator), schemaHooks.resolveData(recordingResourceDataResolver) ], update: [disallow()], patch: [ iff(isProvider('external'), verifyScope('recording', 'write')), - () => schemaHooks.validateData(recordingResourcePatchValidator), + schemaHooks.validateData(recordingResourcePatchValidator), schemaHooks.resolveData(recordingResourcePatchResolver) ], remove: [iff(isProvider('external'), verifyScope('recording', 'write'))] diff --git a/packages/server-core/src/recording/recording/recording.hooks.ts b/packages/server-core/src/recording/recording/recording.hooks.ts index 2a5f8536af..2c0b94797d 100755 --- a/packages/server-core/src/recording/recording/recording.hooks.ts +++ b/packages/server-core/src/recording/recording/recording.hooks.ts @@ -87,7 +87,7 @@ export default { }, before: { - all: [() => schemaHooks.validateQuery(recordingQueryValidator), schemaHooks.resolveQuery(recordingQueryResolver)], + all: [schemaHooks.validateQuery(recordingQueryValidator), schemaHooks.resolveQuery(recordingQueryResolver)], find: [ iff( isProvider('external'), @@ -100,13 +100,13 @@ export default { create: [ iff(isProvider('external'), verifyScope('recording', 'write')), setLoggedinUserInBody('userId'), - () => schemaHooks.validateData(recordingDataValidator), + schemaHooks.validateData(recordingDataValidator), schemaHooks.resolveData(recordingDataResolver) ], update: [disallow()], patch: [ iff(isProvider('external'), verifyScope('recording', 'write')), - () => schemaHooks.validateData(recordingPatchValidator), + schemaHooks.validateData(recordingPatchValidator), schemaHooks.resolveData(recordingPatchResolver) ], remove: [iff(isProvider('external'), verifyScope('recording', 'write')), ensureRecording]