import { getServerActor } from '@server/models/application/application'
import { guessAdditionalAttributesFromQuery } from '@server/models/video/formatter/video-format-utils'
import { MChannelBannerAccountDefault } from '@server/types/models'
-import { ActorImageType, HttpStatusCode, VideoChannelCreate, VideoChannelUpdate } from '@shared/models'
+import { ActorImageType, HttpStatusCode, VideoChannelCreate, VideoChannelUpdate, VideosImportInChannelCreate } from '@shared/models'
import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger'
import { resetSequelizeInstance } from '../../helpers/database-utils'
import { buildNSFWFilter, createReqFiles, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
asyncRetryTransactionMiddleware,
authenticate,
commonVideosFiltersValidator,
- ensureCanManageChannel,
+ ensureCanManageChannelOrAccount,
optionalAuthenticate,
paginationValidator,
setDefaultPagination,
reqAvatarFile,
asyncMiddleware(videoChannelsNameWithHostValidator),
ensureIsLocalChannel,
- ensureCanManageChannel,
+ ensureCanManageChannelOrAccount,
updateAvatarValidator,
asyncMiddleware(updateVideoChannelAvatar)
)
reqBannerFile,
asyncMiddleware(videoChannelsNameWithHostValidator),
ensureIsLocalChannel,
- ensureCanManageChannel,
+ ensureCanManageChannelOrAccount,
updateBannerValidator,
asyncMiddleware(updateVideoChannelBanner)
)
authenticate,
asyncMiddleware(videoChannelsNameWithHostValidator),
ensureIsLocalChannel,
- ensureCanManageChannel,
+ ensureCanManageChannelOrAccount,
asyncMiddleware(deleteVideoChannelAvatar)
)
authenticate,
asyncMiddleware(videoChannelsNameWithHostValidator),
ensureIsLocalChannel,
- ensureCanManageChannel,
+ ensureCanManageChannelOrAccount,
asyncMiddleware(deleteVideoChannelBanner)
)
authenticate,
asyncMiddleware(videoChannelsNameWithHostValidator),
ensureIsLocalChannel,
- ensureCanManageChannel,
+ ensureCanManageChannelOrAccount,
videoChannelsUpdateValidator,
asyncRetryTransactionMiddleware(updateVideoChannel)
)
authenticate,
asyncMiddleware(videoChannelsNameWithHostValidator),
ensureIsLocalChannel,
- ensureCanManageChannel,
+ ensureCanManageChannelOrAccount,
asyncMiddleware(videoChannelsRemoveValidator),
asyncRetryTransactionMiddleware(removeVideoChannel)
)
videoChannelRouter.get('/:nameWithHost/followers',
authenticate,
asyncMiddleware(videoChannelsNameWithHostValidator),
- ensureCanManageChannel,
+ ensureCanManageChannelOrAccount,
paginationValidator,
videoChannelsFollowersSortValidator,
setDefaultSort,
videoChannelRouter.post('/:nameWithHost/import-videos',
authenticate,
asyncMiddleware(videoChannelsNameWithHostValidator),
- videoChannelImportVideosValidator,
+ asyncMiddleware(videoChannelImportVideosValidator),
ensureIsLocalChannel,
- ensureCanManageChannel,
+ ensureCanManageChannelOrAccount,
asyncMiddleware(ensureChannelOwnerCanUpload),
asyncMiddleware(importVideosInChannel)
)
async function updateVideoChannel (req: express.Request, res: express.Response) {
const videoChannelInstance = res.locals.videoChannel
- const videoChannelFieldsSave = videoChannelInstance.toJSON()
const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannelInstance.toFormattedJSON())
const videoChannelInfoToUpdate = req.body as VideoChannelUpdate
let doBulkVideoUpdate = false
} catch (err) {
logger.debug('Cannot update the video channel.', { err })
- // Force fields we want to update
// If the transaction is retried, sequelize will think the object has not changed
- // So it will skip the SQL request, even if the last one was ROLLBACKed!
- resetSequelizeInstance(videoChannelInstance, videoChannelFieldsSave)
+ // So we need to restore the previous fields
+ await resetSequelizeInstance(videoChannelInstance)
throw err
}
}
async function importVideosInChannel (req: express.Request, res: express.Response) {
- const { externalChannelUrl } = req.body
+ const { externalChannelUrl } = req.body as VideosImportInChannelCreate
await JobQueue.Instance.createJob({
type: 'video-channel-import',
payload: {
externalChannelUrl,
- videoChannelId: res.locals.videoChannel.id
+ videoChannelId: res.locals.videoChannel.id,
+ partOfChannelSyncId: res.locals.videoChannelSync?.id
}
})