diff options
author | Chocobozzz <me@florianbigard.com> | 2021-05-28 10:21:39 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-05-28 10:22:50 +0200 |
commit | 012580d98f489e599d44a9a2a0bdc892b9455a90 (patch) | |
tree | cd6d4abdbf43f4cd1c051ac49682b97c7b6dca92 /server/helpers | |
parent | d6d96bed80700830063c6055969d2d2ff46c63c6 (diff) | |
download | PeerTube-012580d98f489e599d44a9a2a0bdc892b9455a90.tar.gz PeerTube-012580d98f489e599d44a9a2a0bdc892b9455a90.tar.zst PeerTube-012580d98f489e599d44a9a2a0bdc892b9455a90.zip |
Cleanup
We must not expose private actor objects to clients
Just make 2 GET requests on channel/accounts instead
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/custom-validators/actor.ts | 10 | ||||
-rw-r--r-- | server/helpers/middlewares/video-channels.ts | 20 |
2 files changed, 9 insertions, 21 deletions
diff --git a/server/helpers/custom-validators/actor.ts b/server/helpers/custom-validators/actor.ts deleted file mode 100644 index ad129e080..000000000 --- a/server/helpers/custom-validators/actor.ts +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | import { isAccountNameValid } from './accounts' | ||
2 | import { isVideoChannelNameValid } from './video-channels' | ||
3 | |||
4 | function isActorNameValid (value: string) { | ||
5 | return isAccountNameValid(value) || isVideoChannelNameValid(value) | ||
6 | } | ||
7 | |||
8 | export { | ||
9 | isActorNameValid | ||
10 | } | ||
diff --git a/server/helpers/middlewares/video-channels.ts b/server/helpers/middlewares/video-channels.ts index e30ea90b3..602555921 100644 --- a/server/helpers/middlewares/video-channels.ts +++ b/server/helpers/middlewares/video-channels.ts | |||
@@ -3,22 +3,22 @@ import { MChannelBannerAccountDefault } from '@server/types/models' | |||
3 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' |
4 | import { VideoChannelModel } from '../../models/video/video-channel' | 4 | import { VideoChannelModel } from '../../models/video/video-channel' |
5 | 5 | ||
6 | async function doesLocalVideoChannelNameExist (name: string, res: express.Response, sendNotFound = true) { | 6 | async function doesLocalVideoChannelNameExist (name: string, res: express.Response) { |
7 | const videoChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(name) | 7 | const videoChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(name) |
8 | 8 | ||
9 | return processVideoChannelExist(videoChannel, res, sendNotFound) | 9 | return processVideoChannelExist(videoChannel, res) |
10 | } | 10 | } |
11 | 11 | ||
12 | async function doesVideoChannelIdExist (id: number, res: express.Response, sendNotFound = true) { | 12 | async function doesVideoChannelIdExist (id: number, res: express.Response) { |
13 | const videoChannel = await VideoChannelModel.loadAndPopulateAccount(+id) | 13 | const videoChannel = await VideoChannelModel.loadAndPopulateAccount(+id) |
14 | 14 | ||
15 | return processVideoChannelExist(videoChannel, res, sendNotFound) | 15 | return processVideoChannelExist(videoChannel, res) |
16 | } | 16 | } |
17 | 17 | ||
18 | async function doesVideoChannelNameWithHostExist (nameWithDomain: string, res: express.Response, sendNotFound = true) { | 18 | async function doesVideoChannelNameWithHostExist (nameWithDomain: string, res: express.Response) { |
19 | const videoChannel = await VideoChannelModel.loadByNameWithHostAndPopulateAccount(nameWithDomain) | 19 | const videoChannel = await VideoChannelModel.loadByNameWithHostAndPopulateAccount(nameWithDomain) |
20 | 20 | ||
21 | return processVideoChannelExist(videoChannel, res, sendNotFound) | 21 | return processVideoChannelExist(videoChannel, res) |
22 | } | 22 | } |
23 | 23 | ||
24 | // --------------------------------------------------------------------------- | 24 | // --------------------------------------------------------------------------- |
@@ -29,12 +29,10 @@ export { | |||
29 | doesVideoChannelNameWithHostExist | 29 | doesVideoChannelNameWithHostExist |
30 | } | 30 | } |
31 | 31 | ||
32 | function processVideoChannelExist (videoChannel: MChannelBannerAccountDefault, res: express.Response, sendNotFound = true) { | 32 | function processVideoChannelExist (videoChannel: MChannelBannerAccountDefault, res: express.Response) { |
33 | if (!videoChannel) { | 33 | if (!videoChannel) { |
34 | if (sendNotFound) { | 34 | res.status(HttpStatusCode.NOT_FOUND_404) |
35 | res.status(HttpStatusCode.NOT_FOUND_404) | 35 | .json({ error: 'Video channel not found' }) |
36 | .json({ error: 'Video channel not found' }) | ||
37 | } | ||
38 | 36 | ||
39 | return false | 37 | return false |
40 | } | 38 | } |