diff options
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r-- | server/controllers/api/videos/blacklist.ts | 6 | ||||
-rw-r--r-- | server/controllers/api/videos/comment.ts | 5 | ||||
-rw-r--r-- | server/controllers/api/videos/import.ts | 21 | ||||
-rw-r--r-- | server/controllers/api/videos/index.ts | 4 | ||||
-rw-r--r-- | server/controllers/api/videos/live.ts | 2 | ||||
-rw-r--r-- | server/controllers/api/videos/ownership.ts | 4 | ||||
-rw-r--r-- | server/controllers/api/videos/upload.ts | 7 |
7 files changed, 27 insertions, 22 deletions
diff --git a/server/controllers/api/videos/blacklist.ts b/server/controllers/api/videos/blacklist.ts index fa8448c86..ca2b85ea5 100644 --- a/server/controllers/api/videos/blacklist.ts +++ b/server/controllers/api/videos/blacklist.ts | |||
@@ -70,7 +70,7 @@ async function addVideoToBlacklistController (req: express.Request, res: express | |||
70 | 70 | ||
71 | logger.info('Video %s blacklisted.', videoInstance.uuid) | 71 | logger.info('Video %s blacklisted.', videoInstance.uuid) |
72 | 72 | ||
73 | return res.type('json').sendStatus(HttpStatusCode.NO_CONTENT_204) | 73 | return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end() |
74 | } | 74 | } |
75 | 75 | ||
76 | async function updateVideoBlacklistController (req: express.Request, res: express.Response) { | 76 | async function updateVideoBlacklistController (req: express.Request, res: express.Response) { |
@@ -82,7 +82,7 @@ async function updateVideoBlacklistController (req: express.Request, res: expres | |||
82 | return videoBlacklist.save({ transaction: t }) | 82 | return videoBlacklist.save({ transaction: t }) |
83 | }) | 83 | }) |
84 | 84 | ||
85 | return res.type('json').sendStatus(HttpStatusCode.NO_CONTENT_204) | 85 | return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end() |
86 | } | 86 | } |
87 | 87 | ||
88 | async function listBlacklist (req: express.Request, res: express.Response) { | 88 | async function listBlacklist (req: express.Request, res: express.Response) { |
@@ -105,5 +105,5 @@ async function removeVideoFromBlacklistController (req: express.Request, res: ex | |||
105 | 105 | ||
106 | logger.info('Video %s removed from blacklist.', video.uuid) | 106 | logger.info('Video %s removed from blacklist.', video.uuid) |
107 | 107 | ||
108 | return res.type('json').sendStatus(HttpStatusCode.NO_CONTENT_204) | 108 | return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end() |
109 | } | 109 | } |
diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.ts index cfdf2773f..e6f28c1cb 100644 --- a/server/controllers/api/videos/comment.ts +++ b/server/controllers/api/videos/comment.ts | |||
@@ -166,7 +166,10 @@ async function listVideoThreadComments (req: express.Request, res: express.Respo | |||
166 | } | 166 | } |
167 | 167 | ||
168 | if (resultList.data.length === 0) { | 168 | if (resultList.data.length === 0) { |
169 | return res.sendStatus(HttpStatusCode.NOT_FOUND_404) | 169 | return res.fail({ |
170 | status: HttpStatusCode.NOT_FOUND_404, | ||
171 | message: 'No comments were found' | ||
172 | }) | ||
170 | } | 173 | } |
171 | 174 | ||
172 | return res.json(buildFormattedCommentTree(resultList)) | 175 | return res.json(buildFormattedCommentTree(resultList)) |
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index 0d5d7a962..6ee109a8f 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/controllers/api/videos/import.ts | |||
@@ -18,7 +18,6 @@ import { | |||
18 | } from '@server/types/models' | 18 | } from '@server/types/models' |
19 | import { MVideoImportFormattable } from '@server/types/models/video/video-import' | 19 | import { MVideoImportFormattable } from '@server/types/models/video/video-import' |
20 | import { ServerErrorCode, VideoImportCreate, VideoImportState, VideoPrivacy, VideoState } from '../../../../shared' | 20 | import { ServerErrorCode, VideoImportCreate, VideoImportState, VideoPrivacy, VideoState } from '../../../../shared' |
21 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
22 | import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type' | 21 | import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type' |
23 | import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger' | 22 | import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger' |
24 | import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' | 23 | import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' |
@@ -143,10 +142,12 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response) | |||
143 | } catch (err) { | 142 | } catch (err) { |
144 | logger.info('Cannot fetch information from import for URL %s.', targetUrl, { err }) | 143 | logger.info('Cannot fetch information from import for URL %s.', targetUrl, { err }) |
145 | 144 | ||
146 | return res.status(HttpStatusCode.BAD_REQUEST_400) | 145 | return res.fail({ |
147 | .json({ | 146 | message: 'Cannot fetch remote information of this URL.', |
148 | error: 'Cannot fetch remote information of this URL.' | 147 | data: { |
149 | }) | 148 | targetUrl |
149 | } | ||
150 | }) | ||
150 | } | 151 | } |
151 | 152 | ||
152 | const video = buildVideo(res.locals.videoChannel.id, body, youtubeDLInfo) | 153 | const video = buildVideo(res.locals.videoChannel.id, body, youtubeDLInfo) |
@@ -333,12 +334,10 @@ async function processTorrentOrAbortRequest (req: express.Request, res: express. | |||
333 | if (parsedTorrent.files.length !== 1) { | 334 | if (parsedTorrent.files.length !== 1) { |
334 | cleanUpReqFiles(req) | 335 | cleanUpReqFiles(req) |
335 | 336 | ||
336 | res.status(HttpStatusCode.BAD_REQUEST_400) | 337 | res.fail({ |
337 | .json({ | 338 | type: ServerErrorCode.INCORRECT_FILES_IN_TORRENT.toString(), |
338 | code: ServerErrorCode.INCORRECT_FILES_IN_TORRENT, | 339 | message: 'Torrents with only 1 file are supported.' |
339 | error: 'Torrents with only 1 file are supported.' | 340 | }) |
340 | }) | ||
341 | |||
342 | return undefined | 341 | return undefined |
343 | } | 342 | } |
344 | 343 | ||
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 6483d2e8a..47ab098ef 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -146,7 +146,7 @@ async function viewVideo (req: express.Request, res: express.Response) { | |||
146 | const exists = await Redis.Instance.doesVideoIPViewExist(ip, immutableVideoAttrs.uuid) | 146 | const exists = await Redis.Instance.doesVideoIPViewExist(ip, immutableVideoAttrs.uuid) |
147 | if (exists) { | 147 | if (exists) { |
148 | logger.debug('View for ip %s and video %s already exists.', ip, immutableVideoAttrs.uuid) | 148 | logger.debug('View for ip %s and video %s already exists.', ip, immutableVideoAttrs.uuid) |
149 | return res.sendStatus(HttpStatusCode.NO_CONTENT_204) | 149 | return res.status(HttpStatusCode.NO_CONTENT_204).end() |
150 | } | 150 | } |
151 | 151 | ||
152 | const video = await VideoModel.load(immutableVideoAttrs.id) | 152 | const video = await VideoModel.load(immutableVideoAttrs.id) |
@@ -179,7 +179,7 @@ async function viewVideo (req: express.Request, res: express.Response) { | |||
179 | 179 | ||
180 | Hooks.runAction('action:api.video.viewed', { video, ip }) | 180 | Hooks.runAction('action:api.video.viewed', { video, ip }) |
181 | 181 | ||
182 | return res.sendStatus(HttpStatusCode.NO_CONTENT_204) | 182 | return res.status(HttpStatusCode.NO_CONTENT_204).end() |
183 | } | 183 | } |
184 | 184 | ||
185 | async function getVideoDescription (req: express.Request, res: express.Response) { | 185 | async function getVideoDescription (req: express.Request, res: express.Response) { |
diff --git a/server/controllers/api/videos/live.ts b/server/controllers/api/videos/live.ts index 04d2494ce..6b733c577 100644 --- a/server/controllers/api/videos/live.ts +++ b/server/controllers/api/videos/live.ts | |||
@@ -76,7 +76,7 @@ async function updateLiveVideo (req: express.Request, res: express.Response) { | |||
76 | 76 | ||
77 | await federateVideoIfNeeded(video, false) | 77 | await federateVideoIfNeeded(video, false) |
78 | 78 | ||
79 | return res.sendStatus(HttpStatusCode.NO_CONTENT_204) | 79 | return res.status(HttpStatusCode.NO_CONTENT_204).end() |
80 | } | 80 | } |
81 | 81 | ||
82 | async function addLiveVideo (req: express.Request, res: express.Response) { | 82 | async function addLiveVideo (req: express.Request, res: express.Response) { |
diff --git a/server/controllers/api/videos/ownership.ts b/server/controllers/api/videos/ownership.ts index 6102f28dc..2d6ca60a8 100644 --- a/server/controllers/api/videos/ownership.ts +++ b/server/controllers/api/videos/ownership.ts | |||
@@ -122,7 +122,7 @@ function acceptOwnership (req: express.Request, res: express.Response) { | |||
122 | videoChangeOwnership.status = VideoChangeOwnershipStatus.ACCEPTED | 122 | videoChangeOwnership.status = VideoChangeOwnershipStatus.ACCEPTED |
123 | await videoChangeOwnership.save({ transaction: t }) | 123 | await videoChangeOwnership.save({ transaction: t }) |
124 | 124 | ||
125 | return res.sendStatus(HttpStatusCode.NO_CONTENT_204) | 125 | return res.status(HttpStatusCode.NO_CONTENT_204).end() |
126 | }) | 126 | }) |
127 | } | 127 | } |
128 | 128 | ||
@@ -133,6 +133,6 @@ function refuseOwnership (req: express.Request, res: express.Response) { | |||
133 | videoChangeOwnership.status = VideoChangeOwnershipStatus.REFUSED | 133 | videoChangeOwnership.status = VideoChangeOwnershipStatus.REFUSED |
134 | await videoChangeOwnership.save({ transaction: t }) | 134 | await videoChangeOwnership.save({ transaction: t }) |
135 | 135 | ||
136 | return res.sendStatus(HttpStatusCode.NO_CONTENT_204) | 136 | return res.status(HttpStatusCode.NO_CONTENT_204).end() |
137 | }) | 137 | }) |
138 | } | 138 | } |
diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.ts index ebc17c760..c33d7fcb9 100644 --- a/server/controllers/api/videos/upload.ts +++ b/server/controllers/api/videos/upload.ts | |||
@@ -97,8 +97,11 @@ export async function addVideoLegacy (req: express.Request, res: express.Respons | |||
97 | // Uploading the video could be long | 97 | // Uploading the video could be long |
98 | // Set timeout to 10 minutes, as Express's default is 2 minutes | 98 | // Set timeout to 10 minutes, as Express's default is 2 minutes |
99 | req.setTimeout(1000 * 60 * 10, () => { | 99 | req.setTimeout(1000 * 60 * 10, () => { |
100 | logger.error('Upload video has timed out.') | 100 | logger.error('Video upload has timed out.') |
101 | return res.sendStatus(HttpStatusCode.REQUEST_TIMEOUT_408) | 101 | return res.fail({ |
102 | status: HttpStatusCode.REQUEST_TIMEOUT_408, | ||
103 | message: 'Video upload has timed out.' | ||
104 | }) | ||
102 | }) | 105 | }) |
103 | 106 | ||
104 | const videoPhysicalFile = req.files['videofile'][0] | 107 | const videoPhysicalFile = req.files['videofile'][0] |