import { Hooks } from '@server/lib/plugins/hooks'
import { getServerActor } from '@server/models/application/application'
import { MChannelBannerAccountDefault } from '@server/types/models'
-import { ActorImageType, VideoChannelCreate, VideoChannelUpdate } from '../../../shared'
+import { ActorImageType, VideoChannelCreate, VideoChannelUpdate, VideosCommonQuery } from '../../../shared'
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger'
import { resetSequelizeInstance } from '../../helpers/database-utils'
import { MIMETYPES } from '../../initializers/constants'
import { sequelizeTypescript } from '../../initializers/database'
import { sendUpdateActor } from '../../lib/activitypub/send'
-import { deleteLocalActorImageFile, updateLocalActorImageFile } from '../../lib/actor-image'
import { JobQueue } from '../../lib/job-queue'
+import { deleteLocalActorImageFile, updateLocalActorImageFile } from '../../lib/local-actor'
import { createLocalVideoChannel, federateAllVideosOfChannel } from '../../lib/video-channel'
import {
asyncMiddleware,
videoChannelsUpdateValidator,
videoPlaylistsSortValidator
} from '../../middlewares'
-import { videoChannelsNameWithHostValidator, videoChannelsOwnSearchValidator, videosSortValidator } from '../../middlewares/validators'
+import { videoChannelsListValidator, videoChannelsNameWithHostValidator, videosSortValidator } from '../../middlewares/validators'
import { updateAvatarValidator, updateBannerValidator } from '../../middlewares/validators/actor-image'
import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists'
import { AccountModel } from '../../models/account/account'
videoChannelsSortValidator,
setDefaultSort,
setDefaultPagination,
- videoChannelsOwnSearchValidator,
+ videoChannelsListValidator,
asyncMiddleware(listVideoChannels)
)
return res.json({ banner: banner.toFormattedJSON() })
}
+
async function updateVideoChannelAvatar (req: express.Request, res: express.Response) {
const avatarPhysicalFile = req.files['avatarfile'][0]
const videoChannel = res.locals.videoChannel
await deleteLocalActorImageFile(videoChannel, ActorImageType.AVATAR)
- return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
+ return res.status(HttpStatusCode.NO_CONTENT_204).end()
}
async function deleteVideoChannelBanner (req: express.Request, res: express.Response) {
await deleteLocalActorImageFile(videoChannel, ActorImageType.BANNER)
- return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
+ return res.status(HttpStatusCode.NO_CONTENT_204).end()
}
async function addVideoChannel (req: express.Request, res: express.Response) {
try {
await sequelizeTypescript.transaction(async t => {
- const sequelizeOptions = {
- transaction: t
- }
-
if (videoChannelInfoToUpdate.displayName !== undefined) videoChannelInstance.name = videoChannelInfoToUpdate.displayName
if (videoChannelInfoToUpdate.description !== undefined) videoChannelInstance.description = videoChannelInfoToUpdate.description
}
}
- const videoChannelInstanceUpdated = await videoChannelInstance.save(sequelizeOptions) as MChannelBannerAccountDefault
+ const videoChannelInstanceUpdated = await videoChannelInstance.save({ transaction: t }) as MChannelBannerAccountDefault
await sendUpdateActor(videoChannelInstanceUpdated, t)
auditLogger.update(
const videoChannelInstance = res.locals.videoChannel
const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined
const countVideos = getCountVideos(req)
+ const query = req.query as VideosCommonQuery
const apiOptions = await Hooks.wrapObject({
followerActorId,
- start: req.query.start,
- count: req.query.count,
- sort: req.query.sort,
+ start: query.start,
+ count: query.count,
+ sort: query.sort,
includeLocalVideos: true,
- categoryOneOf: req.query.categoryOneOf,
- licenceOneOf: req.query.licenceOneOf,
- languageOneOf: req.query.languageOneOf,
- tagsOneOf: req.query.tagsOneOf,
- tagsAllOf: req.query.tagsAllOf,
- filter: req.query.filter,
- nsfw: buildNSFWFilter(res, req.query.nsfw),
+ categoryOneOf: query.categoryOneOf,
+ licenceOneOf: query.licenceOneOf,
+ languageOneOf: query.languageOneOf,
+ tagsOneOf: query.tagsOneOf,
+ tagsAllOf: query.tagsAllOf,
+ filter: query.filter,
+ nsfw: buildNSFWFilter(res, query.nsfw),
withFiles: false,
videoChannelId: videoChannelInstance.id,
user: res.locals.oauth ? res.locals.oauth.token.User : undefined,