diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-12 17:53:50 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-13 16:50:33 +0100 |
commit | 3fd3ab2d34d512b160a5e6084d7609be7b4f4452 (patch) | |
tree | e5ca358287fca6ecacce83defcf23af1e8e9f419 /server/middlewares/validators | |
parent | c893d4514e6ecbf282c7985fe5f82b8acd8a1137 (diff) | |
download | PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.tar.gz PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.tar.zst PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.zip |
Move models to typescript-sequelize
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/account.ts | 4 | ||||
-rw-r--r-- | server/middlewares/validators/activitypub/activity.ts | 3 | ||||
-rw-r--r-- | server/middlewares/validators/activitypub/signature.ts | 4 | ||||
-rw-r--r-- | server/middlewares/validators/follows.ts | 11 | ||||
-rw-r--r-- | server/middlewares/validators/oembed.ts | 5 | ||||
-rw-r--r-- | server/middlewares/validators/sort.ts | 1 | ||||
-rw-r--r-- | server/middlewares/validators/users.ts | 15 | ||||
-rw-r--r-- | server/middlewares/validators/utils.ts | 1 | ||||
-rw-r--r-- | server/middlewares/validators/video-blacklist.ts | 13 | ||||
-rw-r--r-- | server/middlewares/validators/video-channels.ts | 19 | ||||
-rw-r--r-- | server/middlewares/validators/videos.ts | 17 | ||||
-rw-r--r-- | server/middlewares/validators/webfinger.ts | 6 |
12 files changed, 50 insertions, 49 deletions
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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { param } from 'express-validator/check' | 2 | import { param } from 'express-validator/check' |
3 | import { logger, isLocalAccountNameExist } from '../../helpers' | 3 | import { logger } from '../../helpers' |
4 | import { isAccountNameValid } from '../../helpers/custom-validators/accounts' | 4 | import { isAccountNameValid, isLocalAccountNameExist } from '../../helpers/custom-validators/accounts' |
5 | import { areValidationErrors } from './utils' | 5 | import { areValidationErrors } from './utils' |
6 | 6 | ||
7 | const localAccountValidator = [ | 7 | const 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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body } from 'express-validator/check' | 2 | import { body } from 'express-validator/check' |
3 | import { isRootActivityValid, logger } from '../../../helpers' | 3 | import { logger } from '../../../helpers' |
4 | import { isRootActivityValid } from '../../../helpers/custom-validators/activitypub' | ||
4 | import { areValidationErrors } from '../utils' | 5 | import { areValidationErrors } from '../utils' |
5 | 6 | ||
6 | const activityPubValidator = [ | 7 | const 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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body } from 'express-validator/check' | 2 | import { body } from 'express-validator/check' |
3 | import { isDateValid, isSignatureCreatorValid, isSignatureTypeValid, isSignatureValueValid, logger } from '../../../helpers' | 3 | import { logger } from '../../../helpers' |
4 | import { isSignatureCreatorValid, isSignatureTypeValid, isSignatureValueValid } from '../../../helpers/custom-validators/activitypub' | ||
5 | import { isDateValid } from '../../../helpers/custom-validators/misc' | ||
4 | import { areValidationErrors } from '../utils' | 6 | import { areValidationErrors } from '../utils' |
5 | 7 | ||
6 | const signatureValidator = [ | 8 | const 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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body, param } from 'express-validator/check' | 2 | import { body, param } from 'express-validator/check' |
3 | import { isTestInstance } from '../../helpers/core-utils' | 3 | import { getServerAccount, isTestInstance, logger } from '../../helpers' |
4 | import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' | ||
4 | import { isEachUniqueHostValid } from '../../helpers/custom-validators/servers' | 5 | import { isEachUniqueHostValid } from '../../helpers/custom-validators/servers' |
5 | import { logger } from '../../helpers/logger' | 6 | import { CONFIG } from '../../initializers' |
6 | import { CONFIG, database as db } from '../../initializers' | 7 | import { AccountFollowModel } from '../../models/account/account-follow' |
7 | import { areValidationErrors } from './utils' | 8 | import { areValidationErrors } from './utils' |
8 | import { getServerAccount } from '../../helpers/utils' | ||
9 | import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' | ||
10 | 9 | ||
11 | const followValidator = [ | 10 | const 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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { query } from 'express-validator/check' | 2 | import { query } from 'express-validator/check' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { isIdOrUUIDValid, isTestInstance, logger } from '../../helpers' | 4 | import { isTestInstance, logger } from '../../helpers' |
5 | import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' | ||
6 | import { isVideoExist } from '../../helpers/custom-validators/videos' | ||
5 | import { CONFIG } from '../../initializers' | 7 | import { CONFIG } from '../../initializers' |
6 | import { areValidationErrors } from './utils' | 8 | import { areValidationErrors } from './utils' |
7 | import { isVideoExist } from '../../helpers/custom-validators/videos' | ||
8 | 9 | ||
9 | const urlShouldStartWith = CONFIG.WEBSERVER.SCHEME + '://' + join(CONFIG.WEBSERVER.HOST, 'videos', 'watch') + '/' | 10 | const urlShouldStartWith = CONFIG.WEBSERVER.SCHEME + '://' + join(CONFIG.WEBSERVER.HOST, 'videos', 'watch') + '/' |
10 | const videoWatchRegex = new RegExp('([^/]+)$') | 11 | const 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 @@ | |||
1 | import { query } from 'express-validator/check' | 1 | import { query } from 'express-validator/check' |
2 | import * as express from 'express' | 2 | import * as express from 'express' |
3 | |||
4 | import { logger } from '../../helpers' | 3 | import { logger } from '../../helpers' |
5 | import { SORTABLE_COLUMNS } from '../../initializers' | 4 | import { SORTABLE_COLUMNS } from '../../initializers' |
6 | import { areValidationErrors } from './utils' | 5 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import 'express-validator' | 2 | import 'express-validator' |
3 | import { body, param } from 'express-validator/check' | 3 | import { body, param } from 'express-validator/check' |
4 | import { isSignupAllowed, logger } from '../../helpers' | ||
5 | import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' | ||
4 | import { | 6 | import { |
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' | ||
14 | import { isVideoExist } from '../../helpers/custom-validators/videos' | 13 | import { isVideoExist } from '../../helpers/custom-validators/videos' |
15 | import { database as db } from '../../initializers/database' | 14 | import { UserModel } from '../../models/account/user' |
16 | import { areValidationErrors } from './utils' | 15 | import { areValidationErrors } from './utils' |
17 | 16 | ||
18 | const usersAddValidator = [ | 17 | const usersAddValidator = [ |
@@ -153,7 +152,7 @@ export { | |||
153 | // --------------------------------------------------------------------------- | 152 | // --------------------------------------------------------------------------- |
154 | 153 | ||
155 | async function checkUserIdExist (id: number, res: express.Response) { | 154 | async 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 | ||
170 | async function checkUserNameOrEmailDoesNotAlreadyExist (username: string, email: string, res: express.Response) { | 169 | async 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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { validationResult } from 'express-validator/check' | 2 | import { validationResult } from 'express-validator/check' |
3 | |||
4 | import { logger } from '../../helpers' | 3 | import { logger } from '../../helpers' |
5 | 4 | ||
6 | function areValidationErrors (req: express.Request, res: express.Response) { | 5 | function 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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { param } from 'express-validator/check' | 2 | import { param } from 'express-validator/check' |
3 | import { isIdOrUUIDValid, logger } from '../../helpers' | 3 | import { logger } from '../../helpers' |
4 | import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' | ||
4 | import { isVideoExist } from '../../helpers/custom-validators/videos' | 5 | import { isVideoExist } from '../../helpers/custom-validators/videos' |
5 | import { database as db } from '../../initializers/database' | 6 | import { VideoModel } from '../../models/video/video' |
6 | import { VideoInstance } from '../../models/video/video-interface' | 7 | import { VideoBlacklistModel } from '../../models/video/video-blacklist' |
7 | import { areValidationErrors } from './utils' | 8 | import { areValidationErrors } from './utils' |
8 | 9 | ||
9 | const videosBlacklistRemoveValidator = [ | 10 | const videosBlacklistRemoveValidator = [ |
@@ -42,7 +43,7 @@ export { | |||
42 | } | 43 | } |
43 | // --------------------------------------------------------------------------- | 44 | // --------------------------------------------------------------------------- |
44 | 45 | ||
45 | function checkVideoIsBlacklistable (video: VideoInstance, res: express.Response) { | 46 | function 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 | ||
57 | async function checkVideoIsBlacklisted (video: VideoInstance, res: express.Response) { | 58 | async 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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body, param } from 'express-validator/check' | 2 | import { body, param } from 'express-validator/check' |
3 | import { UserRight } from '../../../shared' | 3 | import { UserRight } from '../../../shared' |
4 | import { isIdValid } from '../../helpers/custom-validators/misc' | 4 | import { logger } from '../../helpers' |
5 | import { isAccountIdExist } from '../../helpers/custom-validators/accounts' | ||
6 | import { isIdOrUUIDValid, isIdValid } from '../../helpers/custom-validators/misc' | ||
5 | import { | 7 | import { |
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' |
10 | import { isIdOrUUIDValid } from '../../helpers/index' | 12 | import { UserModel } from '../../models/account/user' |
11 | import { logger } from '../../helpers/logger' | 13 | import { VideoChannelModel } from '../../models/video/video-channel' |
12 | import { database as db } from '../../initializers' | 14 | import { VideoChannelShareModel } from '../../models/video/video-channel-share' |
13 | import { UserInstance } from '../../models' | ||
14 | import { areValidationErrors } from './utils' | 15 | import { areValidationErrors } from './utils' |
15 | import { isAccountIdExist } from '../../helpers/custom-validators/accounts' | ||
16 | import { VideoChannelInstance } from '../../models/video/video-channel-interface' | ||
17 | 16 | ||
18 | const listVideoAccountChannelsValidator = [ | 17 | const 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 | ||
137 | function checkUserCanDeleteVideoChannel (user: UserInstance, videoChannel: VideoChannelInstance, res: express.Response) { | 136 | function 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 | ||
161 | async function checkVideoChannelIsNotTheLastOne (res: express.Response) { | 160 | async 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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import 'express-validator' | ||
2 | import { body, param, query } from 'express-validator/check' | 3 | import { body, param, query } from 'express-validator/check' |
3 | import { UserRight, VideoPrivacy } from '../../../shared' | 4 | import { UserRight, VideoPrivacy } from '../../../shared' |
5 | import { getDurationFromVideoFile, logger } from '../../helpers' | ||
4 | import { isIdOrUUIDValid, isIdValid } from '../../helpers/custom-validators/misc' | 6 | import { isIdOrUUIDValid, isIdValid } from '../../helpers/custom-validators/misc' |
5 | import { | 7 | import { |
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' |
19 | import { getDurationFromVideoFile } from '../../helpers/ffmpeg-utils' | ||
20 | import { logger } from '../../helpers/logger' | ||
21 | import { CONSTRAINTS_FIELDS } from '../../initializers' | 21 | import { CONSTRAINTS_FIELDS } from '../../initializers' |
22 | import { database as db } from '../../initializers/database' | 22 | import { UserModel } from '../../models/account/user' |
23 | import { UserInstance } from '../../models/account/user-interface' | 23 | import { VideoModel } from '../../models/video/video' |
24 | import { VideoInstance } from '../../models/video/video-interface' | 24 | import { VideoChannelModel } from '../../models/video/video-channel' |
25 | import { VideoShareModel } from '../../models/video/video-share' | ||
25 | import { authenticate } from '../oauth' | 26 | import { authenticate } from '../oauth' |
26 | import { areValidationErrors } from './utils' | 27 | import { 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 | ||
252 | function checkUserCanDeleteVideo (user: UserInstance, video: VideoInstance, res: express.Response) { | 253 | function 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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { query } from 'express-validator/check' | 2 | import { query } from 'express-validator/check' |
3 | import { logger } from '../../helpers' | ||
3 | import { isWebfingerResourceValid } from '../../helpers/custom-validators/webfinger' | 4 | import { isWebfingerResourceValid } from '../../helpers/custom-validators/webfinger' |
4 | import { logger } from '../../helpers/logger' | 5 | import { AccountModel } from '../../models/account/account' |
5 | import { database as db } from '../../initializers' | ||
6 | import { areValidationErrors } from './utils' | 6 | import { areValidationErrors } from './utils' |
7 | 7 | ||
8 | const webfingerValidator = [ | 8 | const 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' }) |