Remove old body on note and tasks (#13290)
Fixes: https://github.com/twentyhq/twenty/issues/13110 I'm deprecating note.body and task.body to remove confusion between body and bodyV2 What will be left but should be done later to avoid breaking changes: - re-add a body field in the graphql API only that points to the same bodyV2 field in SQL (need to be handled in fields and filter for note and task) - (wait some time) - remove bodyV2 field
This commit is contained in:
@@ -41,6 +41,7 @@ import { TransientTokenService } from 'src/engine/core-modules/auth/token/servic
|
||||
import { WorkspaceAgnosticTokenService } from 'src/engine/core-modules/auth/token/services/workspace-agnostic-token.service';
|
||||
import { JwtTokenTypeEnum } from 'src/engine/core-modules/auth/types/auth-context.type';
|
||||
import { CaptchaGuard } from 'src/engine/core-modules/captcha/captcha.guard';
|
||||
import { CaptchaGraphqlApiExceptionFilter } from 'src/engine/core-modules/captcha/filters/captcha-graphql-api-exception.filter';
|
||||
import { DomainManagerService } from 'src/engine/core-modules/domain-manager/services/domain-manager.service';
|
||||
import { EmailVerificationExceptionFilter } from 'src/engine/core-modules/email-verification/email-verification-exception-filter.util';
|
||||
import { EmailVerificationService } from 'src/engine/core-modules/email-verification/services/email-verification.service';
|
||||
@@ -78,6 +79,7 @@ import { AuthService } from './services/auth.service';
|
||||
@UsePipes(ResolverValidationPipe)
|
||||
@Resolver()
|
||||
@UseFilters(
|
||||
CaptchaGraphqlApiExceptionFilter,
|
||||
AuthGraphqlApiExceptionFilter,
|
||||
PermissionsGraphqlApiExceptionFilter,
|
||||
EmailVerificationExceptionFilter,
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { CustomException } from 'src/utils/custom-exception';
|
||||
|
||||
export class CaptchaException extends CustomException {
|
||||
declare code: CaptchaExceptionCode;
|
||||
constructor(
|
||||
message: string,
|
||||
code: CaptchaExceptionCode,
|
||||
{ userFriendlyMessage }: { userFriendlyMessage?: string } = {},
|
||||
) {
|
||||
super(message, code, userFriendlyMessage);
|
||||
}
|
||||
}
|
||||
|
||||
export enum CaptchaExceptionCode {
|
||||
INVALID_CAPTCHA = 'INVALID_CAPTCHA',
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
import {
|
||||
BadRequestException,
|
||||
CanActivate,
|
||||
ExecutionContext,
|
||||
Injectable,
|
||||
} from '@nestjs/common';
|
||||
import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common';
|
||||
import { GqlExecutionContext } from '@nestjs/graphql';
|
||||
|
||||
import { t } from '@lingui/core/macro';
|
||||
|
||||
import {
|
||||
CaptchaException,
|
||||
CaptchaExceptionCode,
|
||||
} from 'src/engine/core-modules/captcha/captcha.exception';
|
||||
import { CaptchaService } from 'src/engine/core-modules/captcha/captcha.service';
|
||||
import { MetricsService } from 'src/engine/core-modules/metrics/metrics.service';
|
||||
import { MetricsKeys } from 'src/engine/core-modules/metrics/types/metrics-keys.type';
|
||||
@@ -33,8 +34,10 @@ export class CaptchaGuard implements CanActivate {
|
||||
...(result.error ? { attributes: { error: result.error } } : {}),
|
||||
});
|
||||
|
||||
throw new BadRequestException(
|
||||
throw new CaptchaException(
|
||||
'Invalid Captcha, please try another device',
|
||||
CaptchaExceptionCode.INVALID_CAPTCHA,
|
||||
{ userFriendlyMessage: t`Invalid Captcha, please try another device` },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import { Catch, ExceptionFilter } from '@nestjs/common';
|
||||
|
||||
import { CaptchaException } from 'src/engine/core-modules/captcha/captcha.exception';
|
||||
import { captchaGraphqlApiExceptionHandler } from 'src/engine/core-modules/captcha/utils/captcha-graphql-api-exception-handler.util';
|
||||
|
||||
@Catch(CaptchaException)
|
||||
export class CaptchaGraphqlApiExceptionFilter implements ExceptionFilter {
|
||||
catch(exception: CaptchaException) {
|
||||
return captchaGraphqlApiExceptionHandler(exception);
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import {
|
||||
CaptchaException,
|
||||
CaptchaExceptionCode,
|
||||
} from 'src/engine/core-modules/captcha/captcha.exception';
|
||||
import { UserInputError } from 'src/engine/core-modules/graphql/utils/graphql-errors.util';
|
||||
|
||||
export const captchaGraphqlApiExceptionHandler = (
|
||||
exception: CaptchaException,
|
||||
) => {
|
||||
switch (exception.code) {
|
||||
case CaptchaExceptionCode.INVALID_CAPTCHA:
|
||||
throw new UserInputError(exception);
|
||||
|
||||
default: {
|
||||
const _exhaustiveCheck: never = exception.code;
|
||||
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user