From 0e8ed90a659f3e4dbf7f31ec04363efd040fe4d0 Mon Sep 17 00:00:00 2001 From: wanlingt Date: Mon, 20 Feb 2023 10:11:21 +0800 Subject: [PATCH 1/5] feat: revert previous check for public form --- .../modules/react-migration/react-migration.controller.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/app/modules/react-migration/react-migration.controller.ts b/src/app/modules/react-migration/react-migration.controller.ts index a8169b3257..93f59ed94c 100644 --- a/src/app/modules/react-migration/react-migration.controller.ts +++ b/src/app/modules/react-migration/react-migration.controller.ts @@ -6,7 +6,7 @@ import path from 'path' import { FormResponseMode, - FormStatus, + // FormStatus, UiCookieValues, } from '../../../../shared/types' import config from '../../config/config' @@ -216,9 +216,8 @@ export const servePublicForm: ControllerHandler< }) if (showReact) { - return serveFormReact( - !formResult.isErr() && formResult.value.status === FormStatus.Public, - )(req, res, next) + return serveFormReact(/* isPublic= */ true)(req, res, next) + // return serveFormReact(!formResult.isErr() && formResult.value.status === FormStatus.Public,)(req, res, next) } else { return serveFormAngular(req, res, next) } From d944dfc01ed3344c3c95ee1040796b74145986a9 Mon Sep 17 00:00:00 2001 From: wanlingt Date: Mon, 20 Feb 2023 10:44:52 +0800 Subject: [PATCH 2/5] feat: add check for public form --- .../modules/react-migration/react-migration.controller.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/modules/react-migration/react-migration.controller.ts b/src/app/modules/react-migration/react-migration.controller.ts index 93f59ed94c..0ff9f474fc 100644 --- a/src/app/modules/react-migration/react-migration.controller.ts +++ b/src/app/modules/react-migration/react-migration.controller.ts @@ -6,7 +6,7 @@ import path from 'path' import { FormResponseMode, - // FormStatus, + FormStatus, UiCookieValues, } from '../../../../shared/types' import config from '../../config/config' @@ -216,7 +216,11 @@ export const servePublicForm: ControllerHandler< }) if (showReact) { - return serveFormReact(/* isPublic= */ true)(req, res, next) + const isPublicForm = Boolean( + !formResult.isErr() && formResult.value.status === FormStatus.Public, + ) + return serveFormReact(/* isPublic= */ isPublicForm)(req, res, next) + // return serveFormReact(/* isPublic= */ true)(req, res, next) // return serveFormReact(!formResult.isErr() && formResult.value.status === FormStatus.Public,)(req, res, next) } else { return serveFormAngular(req, res, next) From 46a177522e781581e663845c11f012a03e30108e Mon Sep 17 00:00:00 2001 From: wanlingt Date: Mon, 20 Feb 2023 13:25:05 +0800 Subject: [PATCH 3/5] test: add logging --- .../react-migration/react-migration.controller.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/app/modules/react-migration/react-migration.controller.ts b/src/app/modules/react-migration/react-migration.controller.ts index 0ff9f474fc..12b1917eaf 100644 --- a/src/app/modules/react-migration/react-migration.controller.ts +++ b/src/app/modules/react-migration/react-migration.controller.ts @@ -147,6 +147,7 @@ export const servePublicForm: ControllerHandler< > = async (req, res, next) => { const formResult = await FormService.retrieveFormKeysById(req.params.formId, [ 'responseMode', + 'status', ]) let showReact: boolean | undefined = undefined let isEmail = false @@ -219,6 +220,20 @@ export const servePublicForm: ControllerHandler< const isPublicForm = Boolean( !formResult.isErr() && formResult.value.status === FormStatus.Public, ) + const formStatus = !formResult.isErr() + ? `${formResult.value.status}` + : 'formresulterr' + logger.info({ + message: 'metatags test', + meta: { + action: 'metatags test', + formResult: formResult, + isFormResultErr: formResult.isErr(), + formStatus: formStatus, + formStatusRaw: formResult.isErr() ? null : formResult.value.status, + isPublicForm: isPublicForm, + }, + }) return serveFormReact(/* isPublic= */ isPublicForm)(req, res, next) // return serveFormReact(/* isPublic= */ true)(req, res, next) // return serveFormReact(!formResult.isErr() && formResult.value.status === FormStatus.Public,)(req, res, next) From 7d6f80c89a73628d85e8b8f3bd2b0db8ef183022 Mon Sep 17 00:00:00 2001 From: wanlingt Date: Tue, 21 Feb 2023 11:25:34 +0800 Subject: [PATCH 4/5] fix: remove logging --- .../react-migration.controller.ts | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/app/modules/react-migration/react-migration.controller.ts b/src/app/modules/react-migration/react-migration.controller.ts index 12b1917eaf..c129bc482f 100644 --- a/src/app/modules/react-migration/react-migration.controller.ts +++ b/src/app/modules/react-migration/react-migration.controller.ts @@ -220,23 +220,7 @@ export const servePublicForm: ControllerHandler< const isPublicForm = Boolean( !formResult.isErr() && formResult.value.status === FormStatus.Public, ) - const formStatus = !formResult.isErr() - ? `${formResult.value.status}` - : 'formresulterr' - logger.info({ - message: 'metatags test', - meta: { - action: 'metatags test', - formResult: formResult, - isFormResultErr: formResult.isErr(), - formStatus: formStatus, - formStatusRaw: formResult.isErr() ? null : formResult.value.status, - isPublicForm: isPublicForm, - }, - }) return serveFormReact(/* isPublic= */ isPublicForm)(req, res, next) - // return serveFormReact(/* isPublic= */ true)(req, res, next) - // return serveFormReact(!formResult.isErr() && formResult.value.status === FormStatus.Public,)(req, res, next) } else { return serveFormAngular(req, res, next) } From 00b75a7cc63e73d54ee8d1b501676332a0572be1 Mon Sep 17 00:00:00 2001 From: wanlingt Date: Tue, 21 Feb 2023 17:19:45 +0800 Subject: [PATCH 5/5] fix: clean up code --- .../modules/react-migration/react-migration.controller.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/modules/react-migration/react-migration.controller.ts b/src/app/modules/react-migration/react-migration.controller.ts index c129bc482f..cc5df6c72b 100644 --- a/src/app/modules/react-migration/react-migration.controller.ts +++ b/src/app/modules/react-migration/react-migration.controller.ts @@ -217,10 +217,10 @@ export const servePublicForm: ControllerHandler< }) if (showReact) { - const isPublicForm = Boolean( - !formResult.isErr() && formResult.value.status === FormStatus.Public, - ) - return serveFormReact(/* isPublic= */ isPublicForm)(req, res, next) + const isPublicForm = + !formResult.isErr() && formResult.value.status === FormStatus.Public + + return serveFormReact(isPublicForm)(req, res, next) } else { return serveFormAngular(req, res, next) }