aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/activitypub.ts8
-rw-r--r--server/middlewares/sort.ts6
-rw-r--r--server/middlewares/user-right.ts7
-rw-r--r--server/middlewares/validators/account.ts4
-rw-r--r--server/middlewares/validators/activitypub/activity.ts3
-rw-r--r--server/middlewares/validators/activitypub/signature.ts4
-rw-r--r--server/middlewares/validators/follows.ts11
-rw-r--r--server/middlewares/validators/oembed.ts5
-rw-r--r--server/middlewares/validators/sort.ts1
-rw-r--r--server/middlewares/validators/users.ts15
-rw-r--r--server/middlewares/validators/utils.ts1
-rw-r--r--server/middlewares/validators/video-blacklist.ts13
-rw-r--r--server/middlewares/validators/video-channels.ts19
-rw-r--r--server/middlewares/validators/videos.ts17
-rw-r--r--server/middlewares/validators/webfinger.ts6
15 files changed, 59 insertions, 61 deletions
diff --git a/server/middlewares/activitypub.ts b/server/middlewares/activitypub.ts
index c2ad18195..489396447 100644
--- a/server/middlewares/activitypub.ts
+++ b/server/middlewares/activitypub.ts
@@ -2,16 +2,16 @@ import { eachSeries } from 'async'
2import { NextFunction, Request, RequestHandler, Response } from 'express' 2import { NextFunction, Request, RequestHandler, Response } from 'express'
3import { ActivityPubSignature } from '../../shared' 3import { ActivityPubSignature } from '../../shared'
4import { isSignatureVerified, logger } from '../helpers' 4import { isSignatureVerified, logger } from '../helpers'
5import { database as db } from '../initializers' 5import { ACCEPT_HEADERS, ACTIVITY_PUB } from '../initializers'
6import { ACCEPT_HEADERS, ACTIVITY_PUB } from '../initializers/constants' 6import { fetchRemoteAccount, saveAccountAndServerIfNotExist } from '../lib/activitypub'
7import { fetchRemoteAccount, saveAccountAndServerIfNotExist } from '../lib/activitypub/account' 7import { AccountModel } from '../models/account/account'
8 8
9async function checkSignature (req: Request, res: Response, next: NextFunction) { 9async function checkSignature (req: Request, res: Response, next: NextFunction) {
10 const signatureObject: ActivityPubSignature = req.body.signature 10 const signatureObject: ActivityPubSignature = req.body.signature
11 11
12 logger.debug('Checking signature of account %s...', signatureObject.creator) 12 logger.debug('Checking signature of account %s...', signatureObject.creator)
13 13
14 let account = await db.Account.loadByUrl(signatureObject.creator) 14 let account = await AccountModel.loadByUrl(signatureObject.creator)
15 15
16 // We don't have this account in our database, fetch it on remote 16 // We don't have this account in our database, fetch it on remote
17 if (!account) { 17 if (!account) {
diff --git a/server/middlewares/sort.ts b/server/middlewares/sort.ts
index 7b60920de..5d2a43acc 100644
--- a/server/middlewares/sort.ts
+++ b/server/middlewares/sort.ts
@@ -1,8 +1,6 @@
1import 'express-validator'
2import * as express from 'express' 1import * as express from 'express'
3 2import 'express-validator'
4import { SortType } from '../helpers' 3import { SortType } from '../helpers'
5import { database } from '../initializers'
6 4
7function setUsersSort (req: express.Request, res: express.Response, next: express.NextFunction) { 5function setUsersSort (req: express.Request, res: express.Response, next: express.NextFunction) {
8 if (!req.query.sort) req.query.sort = '-createdAt' 6 if (!req.query.sort) req.query.sort = '-createdAt'
@@ -57,7 +55,7 @@ function setBlacklistSort (req: express.Request, res: express.Response, next: ex
57 // If we want to sort onto the BlacklistedVideos relation, we won't specify it in the query parameter ... 55 // If we want to sort onto the BlacklistedVideos relation, we won't specify it in the query parameter ...
58 newSort.sortModel = undefined 56 newSort.sortModel = undefined
59 } else { 57 } else {
60 newSort.sortModel = database.Video 58 newSort.sortModel = 'Video'
61 } 59 }
62 60
63 newSort.sortValue = req.query.sort 61 newSort.sortValue = req.query.sort
diff --git a/server/middlewares/user-right.ts b/server/middlewares/user-right.ts
index bcebe9d7f..5d63ebaf4 100644
--- a/server/middlewares/user-right.ts
+++ b/server/middlewares/user-right.ts
@@ -1,13 +1,12 @@
1import 'express-validator'
2import * as express from 'express' 1import * as express from 'express'
3 2import 'express-validator'
4import { UserInstance } from '../models'
5import { UserRight } from '../../shared' 3import { UserRight } from '../../shared'
6import { logger } from '../helpers' 4import { logger } from '../helpers'
5import { UserModel } from '../models/account/user'
7 6
8function ensureUserHasRight (userRight: UserRight) { 7function ensureUserHasRight (userRight: UserRight) {
9 return function (req: express.Request, res: express.Response, next: express.NextFunction) { 8 return function (req: express.Request, res: express.Response, next: express.NextFunction) {
10 const user: UserInstance = res.locals.oauth.token.user 9 const user = res.locals.oauth.token.user as UserModel
11 if (user.hasRight(userRight) === false) { 10 if (user.hasRight(userRight) === false) {
12 logger.info('User %s does not have right %s to access to %s.', user.username, UserRight[userRight], req.path) 11 logger.info('User %s does not have right %s to access to %s.', user.username, UserRight[userRight], req.path)
13 return res.sendStatus(403) 12 return res.sendStatus(403)
diff --git a/server/middlewares/validators/account.ts b/server/middlewares/validators/account.ts
index 70f4e4d3b..6951dfc80 100644
--- a/server/middlewares/validators/account.ts
+++ b/server/middlewares/validators/account.ts
@@ -1,7 +1,7 @@
1import * as express from 'express' 1import * as express from 'express'
2import { param } from 'express-validator/check' 2import { param } from 'express-validator/check'
3import { logger, isLocalAccountNameExist } from '../../helpers' 3import { logger } from '../../helpers'
4import { isAccountNameValid } from '../../helpers/custom-validators/accounts' 4import { isAccountNameValid, isLocalAccountNameExist } from '../../helpers/custom-validators/accounts'
5import { areValidationErrors } from './utils' 5import { areValidationErrors } from './utils'
6 6
7const localAccountValidator = [ 7const localAccountValidator = [
diff --git a/server/middlewares/validators/activitypub/activity.ts b/server/middlewares/validators/activitypub/activity.ts
index c63be5979..e0225f30c 100644
--- a/server/middlewares/validators/activitypub/activity.ts
+++ b/server/middlewares/validators/activitypub/activity.ts
@@ -1,6 +1,7 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body } from 'express-validator/check' 2import { body } from 'express-validator/check'
3import { isRootActivityValid, logger } from '../../../helpers' 3import { logger } from '../../../helpers'
4import { isRootActivityValid } from '../../../helpers/custom-validators/activitypub'
4import { areValidationErrors } from '../utils' 5import { areValidationErrors } from '../utils'
5 6
6const activityPubValidator = [ 7const activityPubValidator = [
diff --git a/server/middlewares/validators/activitypub/signature.ts b/server/middlewares/validators/activitypub/signature.ts
index 360685512..d41bb6a8d 100644
--- a/server/middlewares/validators/activitypub/signature.ts
+++ b/server/middlewares/validators/activitypub/signature.ts
@@ -1,6 +1,8 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body } from 'express-validator/check' 2import { body } from 'express-validator/check'
3import { isDateValid, isSignatureCreatorValid, isSignatureTypeValid, isSignatureValueValid, logger } from '../../../helpers' 3import { logger } from '../../../helpers'
4import { isSignatureCreatorValid, isSignatureTypeValid, isSignatureValueValid } from '../../../helpers/custom-validators/activitypub'
5import { isDateValid } from '../../../helpers/custom-validators/misc'
4import { areValidationErrors } from '../utils' 6import { areValidationErrors } from '../utils'
5 7
6const signatureValidator = [ 8const signatureValidator = [
diff --git a/server/middlewares/validators/follows.ts b/server/middlewares/validators/follows.ts
index 605872ecf..10482e5d0 100644
--- a/server/middlewares/validators/follows.ts
+++ b/server/middlewares/validators/follows.ts
@@ -1,12 +1,11 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body, param } from 'express-validator/check' 2import { body, param } from 'express-validator/check'
3import { isTestInstance } from '../../helpers/core-utils' 3import { getServerAccount, isTestInstance, logger } from '../../helpers'
4import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
4import { isEachUniqueHostValid } from '../../helpers/custom-validators/servers' 5import { isEachUniqueHostValid } from '../../helpers/custom-validators/servers'
5import { logger } from '../../helpers/logger' 6import { CONFIG } from '../../initializers'
6import { CONFIG, database as db } from '../../initializers' 7import { AccountFollowModel } from '../../models/account/account-follow'
7import { areValidationErrors } from './utils' 8import { areValidationErrors } from './utils'
8import { getServerAccount } from '../../helpers/utils'
9import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
10 9
11const followValidator = [ 10const followValidator = [
12 body('hosts').custom(isEachUniqueHostValid).withMessage('Should have an array of unique hosts'), 11 body('hosts').custom(isEachUniqueHostValid).withMessage('Should have an array of unique hosts'),
@@ -38,7 +37,7 @@ const removeFollowingValidator = [
38 if (areValidationErrors(req, res)) return 37 if (areValidationErrors(req, res)) return
39 38
40 const serverAccount = await getServerAccount() 39 const serverAccount = await getServerAccount()
41 const follow = await db.AccountFollow.loadByAccountAndTarget(serverAccount.id, req.params.accountId) 40 const follow = await AccountFollowModel.loadByAccountAndTarget(serverAccount.id, req.params.accountId)
42 41
43 if (!follow) { 42 if (!follow) {
44 return res.status(404) 43 return res.status(404)
diff --git a/server/middlewares/validators/oembed.ts b/server/middlewares/validators/oembed.ts
index 31f06dc65..fb7b726e5 100644
--- a/server/middlewares/validators/oembed.ts
+++ b/server/middlewares/validators/oembed.ts
@@ -1,10 +1,11 @@
1import * as express from 'express' 1import * as express from 'express'
2import { query } from 'express-validator/check' 2import { query } from 'express-validator/check'
3import { join } from 'path' 3import { join } from 'path'
4import { isIdOrUUIDValid, isTestInstance, logger } from '../../helpers' 4import { isTestInstance, logger } from '../../helpers'
5import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
6import { isVideoExist } from '../../helpers/custom-validators/videos'
5import { CONFIG } from '../../initializers' 7import { CONFIG } from '../../initializers'
6import { areValidationErrors } from './utils' 8import { areValidationErrors } from './utils'
7import { isVideoExist } from '../../helpers/custom-validators/videos'
8 9
9const urlShouldStartWith = CONFIG.WEBSERVER.SCHEME + '://' + join(CONFIG.WEBSERVER.HOST, 'videos', 'watch') + '/' 10const urlShouldStartWith = CONFIG.WEBSERVER.SCHEME + '://' + join(CONFIG.WEBSERVER.HOST, 'videos', 'watch') + '/'
10const videoWatchRegex = new RegExp('([^/]+)$') 11const videoWatchRegex = new RegExp('([^/]+)$')
diff --git a/server/middlewares/validators/sort.ts b/server/middlewares/validators/sort.ts
index d5822ac81..38184fefa 100644
--- a/server/middlewares/validators/sort.ts
+++ b/server/middlewares/validators/sort.ts
@@ -1,6 +1,5 @@
1import { query } from 'express-validator/check' 1import { query } from 'express-validator/check'
2import * as express from 'express' 2import * as express from 'express'
3
4import { logger } from '../../helpers' 3import { logger } from '../../helpers'
5import { SORTABLE_COLUMNS } from '../../initializers' 4import { SORTABLE_COLUMNS } from '../../initializers'
6import { areValidationErrors } from './utils' 5import { areValidationErrors } from './utils'
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts
index ac7435b7d..920176d07 100644
--- a/server/middlewares/validators/users.ts
+++ b/server/middlewares/validators/users.ts
@@ -1,18 +1,17 @@
1import * as express from 'express' 1import * as express from 'express'
2import 'express-validator' 2import 'express-validator'
3import { body, param } from 'express-validator/check' 3import { body, param } from 'express-validator/check'
4import { isSignupAllowed, logger } from '../../helpers'
5import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
4import { 6import {
5 isIdOrUUIDValid,
6 isSignupAllowed,
7 isUserDisplayNSFWValid, 7 isUserDisplayNSFWValid,
8 isUserPasswordValid, 8 isUserPasswordValid,
9 isUserRoleValid, 9 isUserRoleValid,
10 isUserUsernameValid, 10 isUserUsernameValid,
11 isUserVideoQuotaValid, 11 isUserVideoQuotaValid
12 logger 12} from '../../helpers/custom-validators/users'
13} from '../../helpers'
14import { isVideoExist } from '../../helpers/custom-validators/videos' 13import { isVideoExist } from '../../helpers/custom-validators/videos'
15import { database as db } from '../../initializers/database' 14import { UserModel } from '../../models/account/user'
16import { areValidationErrors } from './utils' 15import { areValidationErrors } from './utils'
17 16
18const usersAddValidator = [ 17const usersAddValidator = [
@@ -153,7 +152,7 @@ export {
153// --------------------------------------------------------------------------- 152// ---------------------------------------------------------------------------
154 153
155async function checkUserIdExist (id: number, res: express.Response) { 154async function checkUserIdExist (id: number, res: express.Response) {
156 const user = await db.User.loadById(id) 155 const user = await UserModel.loadById(id)
157 156
158 if (!user) { 157 if (!user) {
159 res.status(404) 158 res.status(404)
@@ -168,7 +167,7 @@ async function checkUserIdExist (id: number, res: express.Response) {
168} 167}
169 168
170async function checkUserNameOrEmailDoesNotAlreadyExist (username: string, email: string, res: express.Response) { 169async function checkUserNameOrEmailDoesNotAlreadyExist (username: string, email: string, res: express.Response) {
171 const user = await db.User.loadByUsernameOrEmail(username, email) 170 const user = await UserModel.loadByUsernameOrEmail(username, email)
172 171
173 if (user) { 172 if (user) {
174 res.status(409) 173 res.status(409)
diff --git a/server/middlewares/validators/utils.ts b/server/middlewares/validators/utils.ts
index ca80acf29..61f76b457 100644
--- a/server/middlewares/validators/utils.ts
+++ b/server/middlewares/validators/utils.ts
@@ -1,6 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import { validationResult } from 'express-validator/check' 2import { validationResult } from 'express-validator/check'
3
4import { logger } from '../../helpers' 3import { logger } from '../../helpers'
5 4
6function areValidationErrors (req: express.Request, res: express.Response) { 5function areValidationErrors (req: express.Request, res: express.Response) {
diff --git a/server/middlewares/validators/video-blacklist.ts b/server/middlewares/validators/video-blacklist.ts
index f1cc04950..98099fe3f 100644
--- a/server/middlewares/validators/video-blacklist.ts
+++ b/server/middlewares/validators/video-blacklist.ts
@@ -1,9 +1,10 @@
1import * as express from 'express' 1import * as express from 'express'
2import { param } from 'express-validator/check' 2import { param } from 'express-validator/check'
3import { isIdOrUUIDValid, logger } from '../../helpers' 3import { logger } from '../../helpers'
4import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
4import { isVideoExist } from '../../helpers/custom-validators/videos' 5import { isVideoExist } from '../../helpers/custom-validators/videos'
5import { database as db } from '../../initializers/database' 6import { VideoModel } from '../../models/video/video'
6import { VideoInstance } from '../../models/video/video-interface' 7import { VideoBlacklistModel } from '../../models/video/video-blacklist'
7import { areValidationErrors } from './utils' 8import { areValidationErrors } from './utils'
8 9
9const videosBlacklistRemoveValidator = [ 10const videosBlacklistRemoveValidator = [
@@ -42,7 +43,7 @@ export {
42} 43}
43// --------------------------------------------------------------------------- 44// ---------------------------------------------------------------------------
44 45
45function checkVideoIsBlacklistable (video: VideoInstance, res: express.Response) { 46function checkVideoIsBlacklistable (video: VideoModel, res: express.Response) {
46 if (video.isOwned() === true) { 47 if (video.isOwned() === true) {
47 res.status(403) 48 res.status(403)
48 .json({ error: 'Cannot blacklist a local video' }) 49 .json({ error: 'Cannot blacklist a local video' })
@@ -54,8 +55,8 @@ function checkVideoIsBlacklistable (video: VideoInstance, res: express.Response)
54 return true 55 return true
55} 56}
56 57
57async function checkVideoIsBlacklisted (video: VideoInstance, res: express.Response) { 58async function checkVideoIsBlacklisted (video: VideoModel, res: express.Response) {
58 const blacklistedVideo = await db.BlacklistedVideo.loadByVideoId(video.id) 59 const blacklistedVideo = await VideoBlacklistModel.loadByVideoId(video.id)
59 if (!blacklistedVideo) { 60 if (!blacklistedVideo) {
60 res.status(404) 61 res.status(404)
61 .send('Blacklisted video not found') 62 .send('Blacklisted video not found')
diff --git a/server/middlewares/validators/video-channels.ts b/server/middlewares/validators/video-channels.ts
index 3d31a7e52..660390080 100644
--- a/server/middlewares/validators/video-channels.ts
+++ b/server/middlewares/validators/video-channels.ts
@@ -1,19 +1,18 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body, param } from 'express-validator/check' 2import { body, param } from 'express-validator/check'
3import { UserRight } from '../../../shared' 3import { UserRight } from '../../../shared'
4import { isIdValid } from '../../helpers/custom-validators/misc' 4import { logger } from '../../helpers'
5import { isAccountIdExist } from '../../helpers/custom-validators/accounts'
6import { isIdOrUUIDValid, isIdValid } from '../../helpers/custom-validators/misc'
5import { 7import {
6 isVideoChannelDescriptionValid, 8 isVideoChannelDescriptionValid,
7 isVideoChannelExist, 9 isVideoChannelExist,
8 isVideoChannelNameValid 10 isVideoChannelNameValid
9} from '../../helpers/custom-validators/video-channels' 11} from '../../helpers/custom-validators/video-channels'
10import { isIdOrUUIDValid } from '../../helpers/index' 12import { UserModel } from '../../models/account/user'
11import { logger } from '../../helpers/logger' 13import { VideoChannelModel } from '../../models/video/video-channel'
12import { database as db } from '../../initializers' 14import { VideoChannelShareModel } from '../../models/video/video-channel-share'
13import { UserInstance } from '../../models'
14import { areValidationErrors } from './utils' 15import { areValidationErrors } from './utils'
15import { isAccountIdExist } from '../../helpers/custom-validators/accounts'
16import { VideoChannelInstance } from '../../models/video/video-channel-interface'
17 16
18const listVideoAccountChannelsValidator = [ 17const listVideoAccountChannelsValidator = [
19 param('accountId').custom(isIdOrUUIDValid).withMessage('Should have a valid account id'), 18 param('accountId').custom(isIdOrUUIDValid).withMessage('Should have a valid account id'),
@@ -109,7 +108,7 @@ const videoChannelsShareValidator = [
109 if (areValidationErrors(req, res)) return 108 if (areValidationErrors(req, res)) return
110 if (!await isVideoChannelExist(req.params.id, res)) return 109 if (!await isVideoChannelExist(req.params.id, res)) return
111 110
112 const share = await db.VideoChannelShare.load(res.locals.video.id, req.params.accountId, undefined) 111 const share = await VideoChannelShareModel.load(res.locals.video.id, req.params.accountId, undefined)
113 if (!share) { 112 if (!share) {
114 return res.status(404) 113 return res.status(404)
115 .end() 114 .end()
@@ -134,7 +133,7 @@ export {
134 133
135// --------------------------------------------------------------------------- 134// ---------------------------------------------------------------------------
136 135
137function checkUserCanDeleteVideoChannel (user: UserInstance, videoChannel: VideoChannelInstance, res: express.Response) { 136function checkUserCanDeleteVideoChannel (user: UserModel, videoChannel: VideoChannelModel, res: express.Response) {
138 // Retrieve the user who did the request 137 // Retrieve the user who did the request
139 if (videoChannel.isOwned() === false) { 138 if (videoChannel.isOwned() === false) {
140 res.status(403) 139 res.status(403)
@@ -159,7 +158,7 @@ function checkUserCanDeleteVideoChannel (user: UserInstance, videoChannel: Video
159} 158}
160 159
161async function checkVideoChannelIsNotTheLastOne (res: express.Response) { 160async function checkVideoChannelIsNotTheLastOne (res: express.Response) {
162 const count = await db.VideoChannel.countByAccount(res.locals.oauth.token.User.Account.id) 161 const count = await VideoChannelModel.countByAccount(res.locals.oauth.token.User.Account.id)
163 162
164 if (count <= 1) { 163 if (count <= 1) {
165 res.status(409) 164 res.status(409)
diff --git a/server/middlewares/validators/videos.ts b/server/middlewares/validators/videos.ts
index 10625e41d..b52d5f285 100644
--- a/server/middlewares/validators/videos.ts
+++ b/server/middlewares/validators/videos.ts
@@ -1,6 +1,8 @@
1import * as express from 'express' 1import * as express from 'express'
2import 'express-validator'
2import { body, param, query } from 'express-validator/check' 3import { body, param, query } from 'express-validator/check'
3import { UserRight, VideoPrivacy } from '../../../shared' 4import { UserRight, VideoPrivacy } from '../../../shared'
5import { getDurationFromVideoFile, logger } from '../../helpers'
4import { isIdOrUUIDValid, isIdValid } from '../../helpers/custom-validators/misc' 6import { isIdOrUUIDValid, isIdValid } from '../../helpers/custom-validators/misc'
5import { 7import {
6 isVideoAbuseReasonValid, 8 isVideoAbuseReasonValid,
@@ -16,12 +18,11 @@ import {
16 isVideoRatingTypeValid, 18 isVideoRatingTypeValid,
17 isVideoTagsValid 19 isVideoTagsValid
18} from '../../helpers/custom-validators/videos' 20} from '../../helpers/custom-validators/videos'
19import { getDurationFromVideoFile } from '../../helpers/ffmpeg-utils'
20import { logger } from '../../helpers/logger'
21import { CONSTRAINTS_FIELDS } from '../../initializers' 21import { CONSTRAINTS_FIELDS } from '../../initializers'
22import { database as db } from '../../initializers/database' 22import { UserModel } from '../../models/account/user'
23import { UserInstance } from '../../models/account/user-interface' 23import { VideoModel } from '../../models/video/video'
24import { VideoInstance } from '../../models/video/video-interface' 24import { VideoChannelModel } from '../../models/video/video-channel'
25import { VideoShareModel } from '../../models/video/video-share'
25import { authenticate } from '../oauth' 26import { authenticate } from '../oauth'
26import { areValidationErrors } from './utils' 27import { areValidationErrors } from './utils'
27 28
@@ -48,7 +49,7 @@ const videosAddValidator = [
48 const videoFile: Express.Multer.File = req.files['videofile'][0] 49 const videoFile: Express.Multer.File = req.files['videofile'][0]
49 const user = res.locals.oauth.token.User 50 const user = res.locals.oauth.token.User
50 51
51 const videoChannel = await db.VideoChannel.loadByIdAndAccount(req.body.channelId, user.Account.id) 52 const videoChannel = await VideoChannelModel.loadByIdAndAccount(req.body.channelId, user.Account.id)
52 if (!videoChannel) { 53 if (!videoChannel) {
53 res.status(400) 54 res.status(400)
54 .json({ error: 'Unknown video video channel for this account.' }) 55 .json({ error: 'Unknown video video channel for this account.' })
@@ -221,7 +222,7 @@ const videosShareValidator = [
221 if (areValidationErrors(req, res)) return 222 if (areValidationErrors(req, res)) return
222 if (!await isVideoExist(req.params.id, res)) return 223 if (!await isVideoExist(req.params.id, res)) return
223 224
224 const share = await db.VideoShare.load(req.params.accountId, res.locals.video.id, undefined) 225 const share = await VideoShareModel.load(req.params.accountId, res.locals.video.id, undefined)
225 if (!share) { 226 if (!share) {
226 return res.status(404) 227 return res.status(404)
227 .end() 228 .end()
@@ -249,7 +250,7 @@ export {
249 250
250// --------------------------------------------------------------------------- 251// ---------------------------------------------------------------------------
251 252
252function checkUserCanDeleteVideo (user: UserInstance, video: VideoInstance, res: express.Response) { 253function checkUserCanDeleteVideo (user: UserModel, video: VideoModel, res: express.Response) {
253 // Retrieve the user who did the request 254 // Retrieve the user who did the request
254 if (video.isOwned() === false) { 255 if (video.isOwned() === false) {
255 res.status(403) 256 res.status(403)
diff --git a/server/middlewares/validators/webfinger.ts b/server/middlewares/validators/webfinger.ts
index 34e62c66d..7903c7400 100644
--- a/server/middlewares/validators/webfinger.ts
+++ b/server/middlewares/validators/webfinger.ts
@@ -1,8 +1,8 @@
1import * as express from 'express' 1import * as express from 'express'
2import { query } from 'express-validator/check' 2import { query } from 'express-validator/check'
3import { logger } from '../../helpers'
3import { isWebfingerResourceValid } from '../../helpers/custom-validators/webfinger' 4import { isWebfingerResourceValid } from '../../helpers/custom-validators/webfinger'
4import { logger } from '../../helpers/logger' 5import { AccountModel } from '../../models/account/account'
5import { database as db } from '../../initializers'
6import { areValidationErrors } from './utils' 6import { areValidationErrors } from './utils'
7 7
8const webfingerValidator = [ 8const webfingerValidator = [
@@ -17,7 +17,7 @@ const webfingerValidator = [
17 const nameWithHost = req.query.resource.substr(5) 17 const nameWithHost = req.query.resource.substr(5)
18 const [ name ] = nameWithHost.split('@') 18 const [ name ] = nameWithHost.split('@')
19 19
20 const account = await db.Account.loadLocalByName(name) 20 const account = await AccountModel.loadLocalByName(name)
21 if (!account) { 21 if (!account) {
22 return res.status(404) 22 return res.status(404)
23 .send({ error: 'Account not found' }) 23 .send({ error: 'Account not found' })