X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=inline;f=server%2Fhelpers%2Fexpress-utils.ts;h=e0a1d56a587759adad40cdec568594b2ee41900a;hb=74dc3bca2b14f5fd3fe80c394dfc34177a46db77;hp=8a9cee8c57a72756f857f44d14bb6cd3edc7c0c7;hpb=d1a63fc7ac58a1db00d8ca4f43aadba02eb9b084;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/express-utils.ts b/server/helpers/express-utils.ts index 8a9cee8c5..e0a1d56a5 100644 --- a/server/helpers/express-utils.ts +++ b/server/helpers/express-utils.ts @@ -1,20 +1,19 @@ import * as express from 'express' import * as multer from 'multer' -import { CONFIG, REMOTE_SCHEME } from '../initializers' +import { REMOTE_SCHEME } from '../initializers/constants' import { logger } from './logger' -import { User } from '../../shared/models/users' import { deleteFileAsync, generateRandomString } from './utils' import { extname } from 'path' import { isArray } from './custom-validators/misc' -import { UserModel } from '../models/account/user' +import { CONFIG } from '../initializers/config' -function buildNSFWFilter (res: express.Response, paramNSFW?: string) { +function buildNSFWFilter (res?: express.Response, paramNSFW?: string) { if (paramNSFW === 'true') return true if (paramNSFW === 'false') return false if (paramNSFW === 'both') return undefined - if (res.locals.oauth) { - const user: UserModel = res.locals.oauth.token.User + if (res && res.locals.oauth) { + const user = res.locals.oauth.token.User // User does not want NSFW videos if (user.nsfwPolicy === 'do_not_list') return false @@ -60,7 +59,7 @@ function getHostWithPort (host: string) { return host } -function badRequest (req: express.Request, res: express.Response, next: express.NextFunction) { +function badRequest (req: express.Request, res: express.Response) { return res.type('json').status(400).end() } @@ -101,7 +100,7 @@ function createReqFiles ( } function isUserAbleToSearchRemoteURI (res: express.Response) { - const user: User = res.locals.oauth ? res.locals.oauth.token.User : undefined + const user = res.locals.oauth ? res.locals.oauth.token.User : undefined return CONFIG.SEARCH.REMOTE_URI.ANONYMOUS === true || (CONFIG.SEARCH.REMOTE_URI.USERS === true && user !== undefined)