diff options
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r-- | server/helpers/custom-validators/accounts.ts | 11 | ||||
-rw-r--r-- | server/helpers/custom-validators/activitypub/video-comments.ts | 3 | ||||
-rw-r--r-- | server/helpers/custom-validators/video-channels.ts | 9 |
3 files changed, 6 insertions, 17 deletions
diff --git a/server/helpers/custom-validators/accounts.ts b/server/helpers/custom-validators/accounts.ts index 146c7708e..31a2de5ca 100644 --- a/server/helpers/custom-validators/accounts.ts +++ b/server/helpers/custom-validators/accounts.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import * as Bluebird from 'bluebird' |
2 | import { Response } from 'express' | 2 | import { Response } from 'express' |
3 | import 'express-validator' | 3 | import 'express-validator' |
4 | import * as validator from 'validator' | ||
5 | import { AccountModel } from '../../models/account/account' | 4 | import { AccountModel } from '../../models/account/account' |
6 | import { isUserDescriptionValid, isUserUsernameValid } from './users' | 5 | import { isUserDescriptionValid, isUserUsernameValid } from './users' |
7 | import { exists } from './misc' | 6 | import { exists } from './misc' |
@@ -18,14 +17,8 @@ function isAccountDescriptionValid (value: string) { | |||
18 | return isUserDescriptionValid(value) | 17 | return isUserDescriptionValid(value) |
19 | } | 18 | } |
20 | 19 | ||
21 | function doesAccountIdExist (id: number | string, res: Response, sendNotFound = true) { | 20 | function doesAccountIdExist (id: number, res: Response, sendNotFound = true) { |
22 | let promise: Bluebird<AccountModel> | 21 | const promise = AccountModel.load(id) |
23 | |||
24 | if (validator.isInt('' + id)) { | ||
25 | promise = AccountModel.load(+id) | ||
26 | } else { // UUID | ||
27 | promise = AccountModel.loadByUUID('' + id) | ||
28 | } | ||
29 | 22 | ||
30 | return doesAccountExist(promise, res, sendNotFound) | 23 | return doesAccountExist(promise, res, sendNotFound) |
31 | } | 24 | } |
diff --git a/server/helpers/custom-validators/activitypub/video-comments.ts b/server/helpers/custom-validators/activitypub/video-comments.ts index 26c8c4cc6..e04c5388f 100644 --- a/server/helpers/custom-validators/activitypub/video-comments.ts +++ b/server/helpers/custom-validators/activitypub/video-comments.ts | |||
@@ -36,7 +36,8 @@ function normalizeComment (comment: any) { | |||
36 | if (!comment) return | 36 | if (!comment) return |
37 | 37 | ||
38 | if (typeof comment.url !== 'string') { | 38 | if (typeof comment.url !== 'string') { |
39 | comment.url = comment.url.href || comment.url.url | 39 | if (typeof comment.url === 'object') comment.url = comment.url.href || comment.url.url |
40 | else comment.url = comment.id | ||
40 | } | 41 | } |
41 | 42 | ||
42 | return | 43 | return |
diff --git a/server/helpers/custom-validators/video-channels.ts b/server/helpers/custom-validators/video-channels.ts index fd56b9a70..f818ce8f1 100644 --- a/server/helpers/custom-validators/video-channels.ts +++ b/server/helpers/custom-validators/video-channels.ts | |||
@@ -26,13 +26,8 @@ async function doesLocalVideoChannelNameExist (name: string, res: express.Respon | |||
26 | return processVideoChannelExist(videoChannel, res) | 26 | return processVideoChannelExist(videoChannel, res) |
27 | } | 27 | } |
28 | 28 | ||
29 | async function doesVideoChannelIdExist (id: number | string, res: express.Response) { | 29 | async function doesVideoChannelIdExist (id: number, res: express.Response) { |
30 | let videoChannel: VideoChannelModel | 30 | const videoChannel = await VideoChannelModel.loadAndPopulateAccount(+id) |
31 | if (validator.isInt('' + id)) { | ||
32 | videoChannel = await VideoChannelModel.loadAndPopulateAccount(+id) | ||
33 | } else { // UUID | ||
34 | videoChannel = await VideoChannelModel.loadByUUIDAndPopulateAccount('' + id) | ||
35 | } | ||
36 | 31 | ||
37 | return processVideoChannelExist(videoChannel, res) | 32 | return processVideoChannelExist(videoChannel, res) |
38 | } | 33 | } |