}
getExternalLoginHref () {
- if (this.serverConfig.client.menu.login.redirectOnSingleExternalAuth !== true) return undefined
+ if (!this.serverConfig || this.serverConfig.client.menu.login.redirectOnSingleExternalAuth !== true) return undefined
const externalAuths = this.serverConfig.plugin.registeredExternalAuths
if (externalAuths.length !== 1) return undefined
})
try {
- const videoInstanceUpdated = await sequelizeTypescript.transaction(async t => {
+ const { videoInstanceUpdated, isNewVideo } = await sequelizeTypescript.transaction(async t => {
// Refresh video since thumbnails to prevent concurrent updates
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoFromReq.id, t)
transaction: t
})
- await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, t)
-
auditLogger.update(
getAuditIdFromRes(res),
new VideoAuditView(videoInstanceUpdated.toFormattedDetailsJSON()),
)
logger.info('Video with name %s and uuid %s updated.', video.name, video.uuid, lTags(video.uuid))
- return videoInstanceUpdated
+ return { videoInstanceUpdated, isNewVideo }
})
if (videoInfoToUpdate.name) await updateTorrentsMetadata(videoInstanceUpdated)
+
+ await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, undefined)
+
if (wasConfidentialVideo) Notifier.Instance.notifyOnNewVideoIfNeeded(videoInstanceUpdated)
Hooks.runAction('action:api.video.updated', { video: videoInstanceUpdated, body: req.body, req, res })
async function updateTorrentsMetadata (video: MVideoFullLight) {
for (const file of video.getAllFiles()) {
await updateTorrentMetadata(video, file)
+
+ await file.save()
}
}
import { MVideoFile, MVideoFileRedundanciesOpt } from '@server/types/models/video/video-file'
import { MStreamingPlaylistVideo } from '@server/types/models/video/video-streaming-playlist'
import { CONFIG } from '../initializers/config'
-import { promisify2 } from './core-utils'
+import { promisify2, sha1 } from './core-utils'
import { logger } from './logger'
import { generateVideoImportTmpPath } from './utils'
import { extractVideo } from './video'
await remove(join(CONFIG.STORAGE.TORRENTS_DIR, videoFile.torrentFilename))
videoFile.torrentFilename = newTorrentFilename
+ videoFile.infoHash = sha1(encode(decoded.info))
}
function generateMagnetUri (
import express from 'express'
import { ProblemDocument, ProblemDocumentExtension } from 'http-problem-details'
+import { logger } from '@server/helpers/logger'
import { HttpStatusCode } from '@shared/models'
function apiFailMiddleware (req: express.Request, res: express.Response, next: express.NextFunction) {
res.status(status)
res.setHeader('Content-Type', 'application/problem+json')
- res.json(new ProblemDocument({
+
+ const json = new ProblemDocument({
status,
title,
instance,
type: type
? `https://docs.joinpeertube.org/api-rest-reference.html#section/Errors/${type}`
: undefined
- }, extension))
+ }, extension)
+
+ logger.debug('Bad HTTP request.', { json })
+
+ res.json(json)
}
if (next) next()