From 8a19bee1a1ee39f973bb37429e4f73c3f2873cdb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 17 Aug 2018 15:45:42 +0200 Subject: Add ability to set a name to a channel --- server/controllers/activitypub/client.ts | 16 ++++++++-------- server/controllers/api/accounts.ts | 2 +- server/controllers/api/video-channel.ts | 19 +++++++++---------- 3 files changed, 18 insertions(+), 19 deletions(-) (limited to 'server/controllers') diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index c90c3f931..54cf44419 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/controllers/activitypub/client.ts @@ -6,8 +6,8 @@ import { CONFIG, ROUTE_CACHE_LIFETIME } from '../../initializers' import { buildVideoAnnounce } from '../../lib/activitypub/send' import { audiencify, getAudience } from '../../lib/activitypub/audience' import { createActivityData } from '../../lib/activitypub/send/send-create' -import { asyncMiddleware, executeIfActivityPub, localAccountValidator } from '../../middlewares' -import { videoChannelsGetValidator, videosGetValidator, videosShareValidator } from '../../middlewares/validators' +import { asyncMiddleware, executeIfActivityPub, localAccountValidator, localVideoChannelValidator } from '../../middlewares' +import { videosGetValidator, videosShareValidator } from '../../middlewares/validators' import { videoCommentGetValidator } from '../../middlewares/validators/video-comments' import { AccountModel } from '../../models/account/account' import { ActorModel } from '../../models/activitypub/actor' @@ -80,16 +80,16 @@ activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId/activity executeIfActivityPub(asyncMiddleware(videoCommentController)) ) -activityPubClientRouter.get('/video-channels/:id', - executeIfActivityPub(asyncMiddleware(videoChannelsGetValidator)), +activityPubClientRouter.get('/video-channels/:name', + executeIfActivityPub(asyncMiddleware(localVideoChannelValidator)), executeIfActivityPub(asyncMiddleware(videoChannelController)) ) -activityPubClientRouter.get('/video-channels/:id/followers', - executeIfActivityPub(asyncMiddleware(videoChannelsGetValidator)), +activityPubClientRouter.get('/video-channels/:name/followers', + executeIfActivityPub(asyncMiddleware(localVideoChannelValidator)), executeIfActivityPub(asyncMiddleware(videoChannelFollowersController)) ) -activityPubClientRouter.get('/video-channels/:id/following', - executeIfActivityPub(asyncMiddleware(videoChannelsGetValidator)), +activityPubClientRouter.get('/video-channels/:name/following', + executeIfActivityPub(asyncMiddleware(localVideoChannelValidator)), executeIfActivityPub(asyncMiddleware(videoChannelFollowingController)) ) diff --git a/server/controllers/api/accounts.ts b/server/controllers/api/accounts.ts index 308970abc..7b7e5e740 100644 --- a/server/controllers/api/accounts.ts +++ b/server/controllers/api/accounts.ts @@ -78,7 +78,7 @@ async function listAccountVideos (req: express.Request, res: express.Response, n start: req.query.start, count: req.query.count, sort: req.query.sort, - includeLocalVideos: false, + includeLocalVideos: true, categoryOneOf: req.query.categoryOneOf, licenceOneOf: req.query.licenceOneOf, languageOneOf: req.query.languageOneOf, diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts index 6ffc09f87..3f51f03f4 100644 --- a/server/controllers/api/video-channel.ts +++ b/server/controllers/api/video-channel.ts @@ -10,13 +10,12 @@ import { setDefaultPagination, setDefaultSort, videoChannelsAddValidator, - videoChannelsGetValidator, videoChannelsRemoveValidator, videoChannelsSortValidator, videoChannelsUpdateValidator } from '../../middlewares' import { VideoChannelModel } from '../../models/video/video-channel' -import { videosSortValidator } from '../../middlewares/validators' +import { videoChannelsNameWithHostValidator, videosSortValidator } from '../../middlewares/validators' import { sendUpdateActor } from '../../lib/activitypub/send' import { VideoChannelCreate, VideoChannelUpdate } from '../../../shared' import { createVideoChannel } from '../../lib/video-channel' @@ -50,7 +49,7 @@ videoChannelRouter.post('/', asyncRetryTransactionMiddleware(addVideoChannel) ) -videoChannelRouter.post('/:id/avatar/pick', +videoChannelRouter.post('/:nameWithHost/avatar/pick', authenticate, reqAvatarFile, // Check the rights @@ -59,25 +58,25 @@ videoChannelRouter.post('/:id/avatar/pick', asyncMiddleware(updateVideoChannelAvatar) ) -videoChannelRouter.put('/:id', +videoChannelRouter.put('/:nameWithHost', authenticate, asyncMiddleware(videoChannelsUpdateValidator), asyncRetryTransactionMiddleware(updateVideoChannel) ) -videoChannelRouter.delete('/:id', +videoChannelRouter.delete('/:nameWithHost', authenticate, asyncMiddleware(videoChannelsRemoveValidator), asyncRetryTransactionMiddleware(removeVideoChannel) ) -videoChannelRouter.get('/:id', - asyncMiddleware(videoChannelsGetValidator), +videoChannelRouter.get('/:nameWithHost', + asyncMiddleware(videoChannelsNameWithHostValidator), asyncMiddleware(getVideoChannel) ) -videoChannelRouter.get('/:id/videos', - asyncMiddleware(videoChannelsGetValidator), +videoChannelRouter.get('/:nameWithHost/videos', + asyncMiddleware(videoChannelsNameWithHostValidator), paginationValidator, videosSortValidator, setDefaultSort, @@ -215,7 +214,7 @@ async function listVideoChannelVideos (req: express.Request, res: express.Respon start: req.query.start, count: req.query.count, sort: req.query.sort, - includeLocalVideos: false, + includeLocalVideos: true, categoryOneOf: req.query.categoryOneOf, licenceOneOf: req.query.licenceOneOf, languageOneOf: req.query.languageOneOf, -- cgit v1.2.3