From 9452d4fd3321148fb80b64a67bd9983fee6c208e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 6 Jul 2022 15:44:14 +0200 Subject: /!\ Use a dedicated config file for development It means you have to replace NODE_ENV=test to NODE_ENV=dev if you use it npm run dev:* commands are already updated --- server/middlewares/validators/follows.ts | 6 +++--- server/middlewares/validators/oembed.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'server/middlewares') diff --git a/server/middlewares/validators/follows.ts b/server/middlewares/validators/follows.ts index df4cefe28..86d2d6228 100644 --- a/server/middlewares/validators/follows.ts +++ b/server/middlewares/validators/follows.ts @@ -1,12 +1,13 @@ import express from 'express' import { body, param, query } from 'express-validator' +import { isProdInstance } from '@server/helpers/core-utils' import { isEachUniqueHandleValid, isFollowStateValid, isRemoteHandleValid } from '@server/helpers/custom-validators/follows' import { loadActorUrlOrGetFromWebfinger } from '@server/lib/activitypub/actors' import { getRemoteNameAndHost } from '@server/lib/activitypub/follow' import { getServerActor } from '@server/models/application/application' import { MActorFollowActorsDefault } from '@server/types/models' +import { ServerFollowCreate } from '@shared/models' import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' -import { isTestInstance } from '../../helpers/core-utils' import { isActorTypeValid, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers' import { logger } from '../../helpers/logger' @@ -14,7 +15,6 @@ import { WEBSERVER } from '../../initializers/constants' import { ActorModel } from '../../models/actor/actor' import { ActorFollowModel } from '../../models/actor/actor-follow' import { areValidationErrors } from './shared' -import { ServerFollowCreate } from '@shared/models' const listFollowsValidator = [ query('state') @@ -42,7 +42,7 @@ const followValidator = [ (req: express.Request, res: express.Response, next: express.NextFunction) => { // Force https if the administrator wants to follow remote actors - if (isTestInstance() === false && WEBSERVER.SCHEME === 'http') { + if (isProdInstance() && WEBSERVER.SCHEME === 'http') { return res .status(HttpStatusCode.INTERNAL_SERVER_ERROR_500) .json({ diff --git a/server/middlewares/validators/oembed.ts b/server/middlewares/validators/oembed.ts index fc1a294e0..8e7b44a86 100644 --- a/server/middlewares/validators/oembed.ts +++ b/server/middlewares/validators/oembed.ts @@ -5,7 +5,7 @@ import { loadVideo } from '@server/lib/model-loaders' import { VideoPlaylistModel } from '@server/models/video/video-playlist' import { VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' -import { isTestInstance } from '../../helpers/core-utils' +import { isTestOrDevInstance } from '../../helpers/core-utils' import { isIdOrUUIDValid, isUUIDValid, toCompleteUUID } from '../../helpers/custom-validators/misc' import { logger } from '../../helpers/logger' import { WEBSERVER } from '../../initializers/constants' @@ -34,7 +34,7 @@ const isURLOptions = { } // We validate 'localhost', so we don't have the top level domain -if (isTestInstance()) { +if (isTestOrDevInstance()) { isURLOptions.require_tld = false } -- cgit v1.2.3