X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fapi%2Fvideo-channel.ts;h=3d6a6af7f53b1a9cb8e59bc58c6b38aebd674681;hb=8b9a525a180cc9f3a98c334cc052dcfc8f36dcd4;hp=ff6bbe44c0b068ba533fbac53cc283a6b01ae7d7;hpb=0491173a61aed66205c017e0d7e0503ea316c144;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts index ff6bbe44c..3d6a6af7f 100644 --- a/server/controllers/api/video-channel.ts +++ b/server/controllers/api/video-channel.ts @@ -22,7 +22,7 @@ import { createVideoChannel } from '../../lib/video-channel' import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' import { setAsyncActorKeys } from '../../lib/activitypub' import { AccountModel } from '../../models/account/account' -import { CONFIG, IMAGE_MIMETYPE_EXT, sequelizeTypescript } from '../../initializers' +import { CONFIG, MIMETYPES, sequelizeTypescript } from '../../initializers' import { logger } from '../../helpers/logger' import { VideoModel } from '../../models/video/video' import { updateAvatarValidator } from '../../middlewares/validators/avatar' @@ -32,7 +32,7 @@ import { resetSequelizeInstance } from '../../helpers/database-utils' import { UserModel } from '../../models/account/user' const auditLogger = auditLoggerFactory('channels') -const reqAvatarFile = createReqFiles([ 'avatarfile' ], IMAGE_MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.AVATARS_DIR }) +const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) const videoChannelRouter = express.Router() @@ -46,7 +46,7 @@ videoChannelRouter.get('/', videoChannelRouter.post('/', authenticate, - videoChannelsAddValidator, + asyncMiddleware(videoChannelsAddValidator), asyncRetryTransactionMiddleware(addVideoChannel) ) @@ -56,7 +56,7 @@ videoChannelRouter.post('/:nameWithHost/avatar/pick', // Check the rights asyncMiddleware(videoChannelsUpdateValidator), updateAvatarValidator, - asyncRetryTransactionMiddleware(updateVideoChannelAvatar) + asyncMiddleware(updateVideoChannelAvatar) ) videoChannelRouter.put('/:nameWithHost', @@ -202,10 +202,10 @@ async function getVideoChannel (req: express.Request, res: express.Response, nex async function listVideoChannelVideos (req: express.Request, res: express.Response, next: express.NextFunction) { const videoChannelInstance: VideoChannelModel = res.locals.videoChannel - const actorId = isUserAbleToSearchRemoteURI(res) ? null : undefined + const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined const resultList = await VideoModel.listForApi({ - actorId, + followerActorId, start: req.query.start, count: req.query.count, sort: req.query.sort, @@ -215,9 +215,11 @@ async function listVideoChannelVideos (req: express.Request, res: express.Respon languageOneOf: req.query.languageOneOf, tagsOneOf: req.query.tagsOneOf, tagsAllOf: req.query.tagsAllOf, + filter: req.query.filter, nsfw: buildNSFWFilter(res, req.query.nsfw), withFiles: false, - videoChannelId: videoChannelInstance.id + videoChannelId: videoChannelInstance.id, + user: res.locals.oauth ? res.locals.oauth.token.User : undefined }) return res.json(getFormattedObjects(resultList.data, resultList.total))