aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api')
-rw-r--r--server/controllers/api/abuse.ts7
-rw-r--r--server/controllers/api/bulk.ts5
-rw-r--r--server/controllers/api/index.ts3
-rw-r--r--server/controllers/api/oauth-clients.ts3
-rw-r--r--server/controllers/api/plugins.ts11
-rw-r--r--server/controllers/api/search.ts5
-rw-r--r--server/controllers/api/server/contact.ts3
-rw-r--r--server/controllers/api/server/follows.ts9
-rw-r--r--server/controllers/api/server/redundancy.ts7
-rw-r--r--server/controllers/api/server/server-blocklist.ts9
-rw-r--r--server/controllers/api/users/index.ts19
-rw-r--r--server/controllers/api/users/me.ts5
-rw-r--r--server/controllers/api/users/my-blocklist.ts9
-rw-r--r--server/controllers/api/users/my-history.ts5
-rw-r--r--server/controllers/api/users/my-notifications.ts7
-rw-r--r--server/controllers/api/users/my-subscriptions.ts7
-rw-r--r--server/controllers/api/video-channel.ts5
-rw-r--r--server/controllers/api/video-playlist.ts13
-rw-r--r--server/controllers/api/videos/blacklist.ts7
-rw-r--r--server/controllers/api/videos/captions.ts5
-rw-r--r--server/controllers/api/videos/comment.ts7
-rw-r--r--server/controllers/api/videos/import.ts3
-rw-r--r--server/controllers/api/videos/index.ts15
-rw-r--r--server/controllers/api/videos/live.ts3
-rw-r--r--server/controllers/api/videos/ownership.ts9
-rw-r--r--server/controllers/api/videos/rate.ts5
-rw-r--r--server/controllers/api/videos/watching.ts5
27 files changed, 117 insertions, 74 deletions
diff --git a/server/controllers/api/abuse.ts b/server/controllers/api/abuse.ts
index 25d6e2ab0..0ab74bdff 100644
--- a/server/controllers/api/abuse.ts
+++ b/server/controllers/api/abuse.ts
@@ -6,6 +6,7 @@ import { AbuseModel } from '@server/models/abuse/abuse'
6import { AbuseMessageModel } from '@server/models/abuse/abuse-message' 6import { AbuseMessageModel } from '@server/models/abuse/abuse-message'
7import { getServerActor } from '@server/models/application/application' 7import { getServerActor } from '@server/models/application/application'
8import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' 8import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse'
9import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
9import { AbuseCreate, AbuseState, UserRight } from '../../../shared' 10import { AbuseCreate, AbuseState, UserRight } from '../../../shared'
10import { getFormattedObjects } from '../../helpers/utils' 11import { getFormattedObjects } from '../../helpers/utils'
11import { sequelizeTypescript } from '../../initializers/database' 12import { sequelizeTypescript } from '../../initializers/database'
@@ -141,7 +142,7 @@ async function updateAbuse (req: express.Request, res: express.Response) {
141 142
142 // Do not send the delete to other instances, we updated OUR copy of this abuse 143 // Do not send the delete to other instances, we updated OUR copy of this abuse
143 144
144 return res.sendStatus(204) 145 return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
145} 146}
146 147
147async function deleteAbuse (req: express.Request, res: express.Response) { 148async function deleteAbuse (req: express.Request, res: express.Response) {
@@ -153,7 +154,7 @@ async function deleteAbuse (req: express.Request, res: express.Response) {
153 154
154 // Do not send the delete to other instances, we delete OUR copy of this abuse 155 // Do not send the delete to other instances, we delete OUR copy of this abuse
155 156
156 return res.sendStatus(204) 157 return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
157} 158}
158 159
159async function reportAbuse (req: express.Request, res: express.Response) { 160async function reportAbuse (req: express.Request, res: express.Response) {
@@ -243,5 +244,5 @@ async function deleteAbuseMessage (req: express.Request, res: express.Response)
243 return abuseMessage.destroy({ transaction: t }) 244 return abuseMessage.destroy({ transaction: t })
244 }) 245 })
245 246
246 return res.sendStatus(204) 247 return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
247} 248}
diff --git a/server/controllers/api/bulk.ts b/server/controllers/api/bulk.ts
index 1fe139c92..649351029 100644
--- a/server/controllers/api/bulk.ts
+++ b/server/controllers/api/bulk.ts
@@ -2,8 +2,9 @@ import * as express from 'express'
2import { asyncMiddleware, authenticate } from '../../middlewares' 2import { asyncMiddleware, authenticate } from '../../middlewares'
3import { bulkRemoveCommentsOfValidator } from '@server/middlewares/validators/bulk' 3import { bulkRemoveCommentsOfValidator } from '@server/middlewares/validators/bulk'
4import { VideoCommentModel } from '@server/models/video/video-comment' 4import { VideoCommentModel } from '@server/models/video/video-comment'
5import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model'
6import { removeComment } from '@server/lib/video-comment' 5import { removeComment } from '@server/lib/video-comment'
6import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model'
7import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
7 8
8const bulkRouter = express.Router() 9const bulkRouter = express.Router()
9 10
@@ -33,7 +34,7 @@ async function bulkRemoveCommentsOf (req: express.Request, res: express.Response
33 const comments = await VideoCommentModel.listForBulkDelete(account, filter) 34 const comments = await VideoCommentModel.listForBulkDelete(account, filter)
34 35
35 // Don't wait result 36 // Don't wait result
36 res.sendStatus(204) 37 res.sendStatus(HttpStatusCode.NO_CONTENT_204)
37 38
38 for (const comment of comments) { 39 for (const comment of comments) {
39 await removeComment(comment) 40 await removeComment(comment)
diff --git a/server/controllers/api/index.ts b/server/controllers/api/index.ts
index eda9e04d1..7ade1df3a 100644
--- a/server/controllers/api/index.ts
+++ b/server/controllers/api/index.ts
@@ -1,6 +1,7 @@
1import * as cors from 'cors' 1import * as cors from 'cors'
2import * as express from 'express' 2import * as express from 'express'
3import * as RateLimit from 'express-rate-limit' 3import * as RateLimit from 'express-rate-limit'
4import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
4import { badRequest } from '../../helpers/express-utils' 5import { badRequest } from '../../helpers/express-utils'
5import { CONFIG } from '../../initializers/config' 6import { CONFIG } from '../../initializers/config'
6import { abuseRouter } from './abuse' 7import { abuseRouter } from './abuse'
@@ -56,5 +57,5 @@ export { apiRouter }
56// --------------------------------------------------------------------------- 57// ---------------------------------------------------------------------------
57 58
58function pong (req: express.Request, res: express.Response) { 59function pong (req: express.Request, res: express.Response) {
59 return res.send('pong').status(200).end() 60 return res.send('pong').status(HttpStatusCode.OK_200).end()
60} 61}
diff --git a/server/controllers/api/oauth-clients.ts b/server/controllers/api/oauth-clients.ts
index b2de8bcf5..c21e2298d 100644
--- a/server/controllers/api/oauth-clients.ts
+++ b/server/controllers/api/oauth-clients.ts
@@ -1,5 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { OAuthClientLocal } from '../../../shared' 2import { OAuthClientLocal } from '../../../shared'
3import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
3import { logger } from '../../helpers/logger' 4import { logger } from '../../helpers/logger'
4import { CONFIG } from '../../initializers/config' 5import { CONFIG } from '../../initializers/config'
5import { asyncMiddleware } from '../../middlewares' 6import { asyncMiddleware } from '../../middlewares'
@@ -23,7 +24,7 @@ async function getLocalClient (req: express.Request, res: express.Response, next
23 // Don't make this check if this is a test instance 24 // Don't make this check if this is a test instance
24 if (process.env.NODE_ENV !== 'test' && req.get('host') !== headerHostShouldBe) { 25 if (process.env.NODE_ENV !== 'test' && req.get('host') !== headerHostShouldBe) {
25 logger.info('Getting client tokens for host %s is forbidden (expected %s).', req.get('host'), headerHostShouldBe) 26 logger.info('Getting client tokens for host %s is forbidden (expected %s).', req.get('host'), headerHostShouldBe)
26 return res.type('json').status(403).end() 27 return res.type('json').status(HttpStatusCode.FORBIDDEN_403).end()
27 } 28 }
28 29
29 const client = await OAuthClientModel.loadFirstClient() 30 const client = await OAuthClientModel.loadFirstClient()
diff --git a/server/controllers/api/plugins.ts b/server/controllers/api/plugins.ts
index f8a0d19ca..1c0b5edb1 100644
--- a/server/controllers/api/plugins.ts
+++ b/server/controllers/api/plugins.ts
@@ -27,6 +27,7 @@ import { listAvailablePluginsFromIndex } from '../../lib/plugins/plugin-index'
27import { PeertubePluginIndexList } from '../../../shared/models/plugins/peertube-plugin-index-list.model' 27import { PeertubePluginIndexList } from '../../../shared/models/plugins/peertube-plugin-index-list.model'
28import { RegisteredServerSettings } from '../../../shared/models/plugins/register-server-setting.model' 28import { RegisteredServerSettings } from '../../../shared/models/plugins/register-server-setting.model'
29import { PublicServerSetting } from '../../../shared/models/plugins/public-server.setting' 29import { PublicServerSetting } from '../../../shared/models/plugins/public-server.setting'
30import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
30 31
31const pluginRouter = express.Router() 32const pluginRouter = express.Router()
32 33
@@ -140,7 +141,7 @@ async function installPlugin (req: express.Request, res: express.Response) {
140 return res.json(plugin.toFormattedJSON()) 141 return res.json(plugin.toFormattedJSON())
141 } catch (err) { 142 } catch (err) {
142 logger.warn('Cannot install plugin %s.', toInstall, { err }) 143 logger.warn('Cannot install plugin %s.', toInstall, { err })
143 return res.sendStatus(400) 144 return res.sendStatus(HttpStatusCode.BAD_REQUEST_400)
144 } 145 }
145} 146}
146 147
@@ -155,7 +156,7 @@ async function updatePlugin (req: express.Request, res: express.Response) {
155 return res.json(plugin.toFormattedJSON()) 156 return res.json(plugin.toFormattedJSON())
156 } catch (err) { 157 } catch (err) {
157 logger.warn('Cannot update plugin %s.', toUpdate, { err }) 158 logger.warn('Cannot update plugin %s.', toUpdate, { err })
158 return res.sendStatus(400) 159 return res.sendStatus(HttpStatusCode.BAD_REQUEST_400)
159 } 160 }
160} 161}
161 162
@@ -164,7 +165,7 @@ async function uninstallPlugin (req: express.Request, res: express.Response) {
164 165
165 await PluginManager.Instance.uninstall(body.npmName) 166 await PluginManager.Instance.uninstall(body.npmName)
166 167
167 return res.sendStatus(204) 168 return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
168} 169}
169 170
170function getPublicPluginSettings (req: express.Request, res: express.Response) { 171function getPublicPluginSettings (req: express.Request, res: express.Response) {
@@ -193,7 +194,7 @@ async function updatePluginSettings (req: express.Request, res: express.Response
193 194
194 await PluginManager.Instance.onSettingsChanged(plugin.name, plugin.settings) 195 await PluginManager.Instance.onSettingsChanged(plugin.name, plugin.settings)
195 196
196 return res.sendStatus(204) 197 return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
197} 198}
198 199
199async function listAvailablePlugins (req: express.Request, res: express.Response) { 200async function listAvailablePlugins (req: express.Request, res: express.Response) {
@@ -202,7 +203,7 @@ async function listAvailablePlugins (req: express.Request, res: express.Response
202 const resultList = await listAvailablePluginsFromIndex(query) 203 const resultList = await listAvailablePluginsFromIndex(query)
203 204
204 if (!resultList) { 205 if (!resultList) {
205 return res.status(503) 206 return res.status(HttpStatusCode.SERVICE_UNAVAILABLE_503)
206 .json({ error: 'Plugin index unavailable. Please retry later' }) 207 .json({ error: 'Plugin index unavailable. Please retry later' })
207 .end() 208 .end()
208 } 209 }
diff --git a/server/controllers/api/search.ts b/server/controllers/api/search.ts
index 6e2d11d93..353fd171b 100644
--- a/server/controllers/api/search.ts
+++ b/server/controllers/api/search.ts
@@ -6,6 +6,7 @@ import { getOrCreateVideoAndAccountAndChannel } from '@server/lib/activitypub/vi
6import { AccountBlocklistModel } from '@server/models/account/account-blocklist' 6import { AccountBlocklistModel } from '@server/models/account/account-blocklist'
7import { getServerActor } from '@server/models/application/application' 7import { getServerActor } from '@server/models/application/application'
8import { ServerBlocklistModel } from '@server/models/server/server-blocklist' 8import { ServerBlocklistModel } from '@server/models/server/server-blocklist'
9import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
9import { ResultList, Video, VideoChannel } from '@shared/models' 10import { ResultList, Video, VideoChannel } from '@shared/models'
10import { SearchTargetQuery } from '@shared/models/search/search-target-query.model' 11import { SearchTargetQuery } from '@shared/models/search/search-target-query.model'
11import { VideoChannelsSearchQuery, VideosSearchQuery } from '../../../shared/models/search' 12import { VideoChannelsSearchQuery, VideosSearchQuery } from '../../../shared/models/search'
@@ -99,7 +100,7 @@ async function searchVideoChannelsIndex (query: VideoChannelsSearchQuery, res: e
99 } catch (err) { 100 } catch (err) {
100 logger.warn('Cannot use search index to make video channels search.', { err }) 101 logger.warn('Cannot use search index to make video channels search.', { err })
101 102
102 return res.sendStatus(500) 103 return res.sendStatus(HttpStatusCode.INTERNAL_SERVER_ERROR_500)
103 } 104 }
104} 105}
105 106
@@ -191,7 +192,7 @@ async function searchVideosIndex (query: VideosSearchQuery, res: express.Respons
191 } catch (err) { 192 } catch (err) {
192 logger.warn('Cannot use search index to make video search.', { err }) 193 logger.warn('Cannot use search index to make video search.', { err })
193 194
194 return res.sendStatus(500) 195 return res.sendStatus(HttpStatusCode.INTERNAL_SERVER_ERROR_500)
195 } 196 }
196} 197}
197 198
diff --git a/server/controllers/api/server/contact.ts b/server/controllers/api/server/contact.ts
index de02ffc0b..caddc0909 100644
--- a/server/controllers/api/server/contact.ts
+++ b/server/controllers/api/server/contact.ts
@@ -3,6 +3,7 @@ import { asyncMiddleware, contactAdministratorValidator } from '../../../middlew
3import { Redis } from '../../../lib/redis' 3import { Redis } from '../../../lib/redis'
4import { Emailer } from '../../../lib/emailer' 4import { Emailer } from '../../../lib/emailer'
5import { ContactForm } from '../../../../shared/models/server' 5import { ContactForm } from '../../../../shared/models/server'
6import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
6 7
7const contactRouter = express.Router() 8const contactRouter = express.Router()
8 9
@@ -18,7 +19,7 @@ async function contactAdministrator (req: express.Request, res: express.Response
18 19
19 await Redis.Instance.setContactFormIp(req.ip) 20 await Redis.Instance.setContactFormIp(req.ip)
20 21
21 return res.status(204).end() 22 return res.status(HttpStatusCode.NO_CONTENT_204).end()
22} 23}
23 24
24// --------------------------------------------------------------------------- 25// ---------------------------------------------------------------------------
diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts
index 517d1897e..80025bc5b 100644
--- a/server/controllers/api/server/follows.ts
+++ b/server/controllers/api/server/follows.ts
@@ -28,6 +28,7 @@ import { removeRedundanciesOfServer } from '../../../lib/redundancy'
28import { sequelizeTypescript } from '../../../initializers/database' 28import { sequelizeTypescript } from '../../../initializers/database'
29import { autoFollowBackIfNeeded } from '../../../lib/activitypub/follow' 29import { autoFollowBackIfNeeded } from '../../../lib/activitypub/follow'
30import { getServerActor } from '@server/models/application/application' 30import { getServerActor } from '@server/models/application/application'
31import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
31 32
32const serverFollowsRouter = express.Router() 33const serverFollowsRouter = express.Router()
33serverFollowsRouter.get('/following', 34serverFollowsRouter.get('/following',
@@ -138,7 +139,7 @@ async function followInstance (req: express.Request, res: express.Response) {
138 JobQueue.Instance.createJob({ type: 'activitypub-follow', payload }) 139 JobQueue.Instance.createJob({ type: 'activitypub-follow', payload })
139 } 140 }
140 141
141 return res.status(204).end() 142 return res.status(HttpStatusCode.NO_CONTENT_204).end()
142} 143}
143 144
144async function removeFollowing (req: express.Request, res: express.Response) { 145async function removeFollowing (req: express.Request, res: express.Response) {
@@ -159,7 +160,7 @@ async function removeFollowing (req: express.Request, res: express.Response) {
159 await follow.destroy({ transaction: t }) 160 await follow.destroy({ transaction: t })
160 }) 161 })
161 162
162 return res.status(204).end() 163 return res.status(HttpStatusCode.NO_CONTENT_204).end()
163} 164}
164 165
165async function removeOrRejectFollower (req: express.Request, res: express.Response) { 166async function removeOrRejectFollower (req: express.Request, res: express.Response) {
@@ -169,7 +170,7 @@ async function removeOrRejectFollower (req: express.Request, res: express.Respon
169 170
170 await follow.destroy() 171 await follow.destroy()
171 172
172 return res.status(204).end() 173 return res.status(HttpStatusCode.NO_CONTENT_204).end()
173} 174}
174 175
175async function acceptFollower (req: express.Request, res: express.Response) { 176async function acceptFollower (req: express.Request, res: express.Response) {
@@ -182,5 +183,5 @@ async function acceptFollower (req: express.Request, res: express.Response) {
182 183
183 await autoFollowBackIfNeeded(follow) 184 await autoFollowBackIfNeeded(follow)
184 185
185 return res.status(204).end() 186 return res.status(HttpStatusCode.NO_CONTENT_204).end()
186} 187}
diff --git a/server/controllers/api/server/redundancy.ts b/server/controllers/api/server/redundancy.ts
index 1ced0759e..7c13dc21b 100644
--- a/server/controllers/api/server/redundancy.ts
+++ b/server/controllers/api/server/redundancy.ts
@@ -19,6 +19,7 @@ import { removeRedundanciesOfServer, removeVideoRedundancy } from '../../../lib/
19import { logger } from '../../../helpers/logger' 19import { logger } from '../../../helpers/logger'
20import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy' 20import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy'
21import { JobQueue } from '@server/lib/job-queue' 21import { JobQueue } from '@server/lib/job-queue'
22import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
22 23
23const serverRedundancyRouter = express.Router() 24const serverRedundancyRouter = express.Router()
24 25
@@ -89,13 +90,13 @@ async function addVideoRedundancy (req: express.Request, res: express.Response)
89 payload 90 payload
90 }) 91 })
91 92
92 return res.sendStatus(204) 93 return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
93} 94}
94 95
95async function removeVideoRedundancyController (req: express.Request, res: express.Response) { 96async function removeVideoRedundancyController (req: express.Request, res: express.Response) {
96 await removeVideoRedundancy(res.locals.videoRedundancy) 97 await removeVideoRedundancy(res.locals.videoRedundancy)
97 98
98 return res.sendStatus(204) 99 return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
99} 100}
100 101
101async function updateRedundancy (req: express.Request, res: express.Response) { 102async function updateRedundancy (req: express.Request, res: express.Response) {
@@ -109,5 +110,5 @@ async function updateRedundancy (req: express.Request, res: express.Response) {
109 removeRedundanciesOfServer(server.id) 110 removeRedundanciesOfServer(server.id)
110 .catch(err => logger.error('Cannot remove redundancy of %s.', server.host, { err })) 111 .catch(err => logger.error('Cannot remove redundancy of %s.', server.host, { err }))
111 112
112 return res.sendStatus(204) 113 return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
113} 114}
diff --git a/server/controllers/api/server/server-blocklist.ts b/server/controllers/api/server/server-blocklist.ts
index 78e8a7e09..6e341c0fb 100644
--- a/server/controllers/api/server/server-blocklist.ts
+++ b/server/controllers/api/server/server-blocklist.ts
@@ -25,6 +25,7 @@ import {
25} from '../../../middlewares/validators' 25} from '../../../middlewares/validators'
26import { AccountBlocklistModel } from '../../../models/account/account-blocklist' 26import { AccountBlocklistModel } from '../../../models/account/account-blocklist'
27import { ServerBlocklistModel } from '../../../models/server/server-blocklist' 27import { ServerBlocklistModel } from '../../../models/server/server-blocklist'
28import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
28 29
29const serverBlocklistRouter = express.Router() 30const serverBlocklistRouter = express.Router()
30 31
@@ -108,7 +109,7 @@ async function blockAccount (req: express.Request, res: express.Response) {
108 forUserId: null // For all users 109 forUserId: null // For all users
109 }).catch(err => logger.error('Cannot remove notifications after an account mute.', { err })) 110 }).catch(err => logger.error('Cannot remove notifications after an account mute.', { err }))
110 111
111 return res.status(204).end() 112 return res.status(HttpStatusCode.NO_CONTENT_204).end()
112} 113}
113 114
114async function unblockAccount (req: express.Request, res: express.Response) { 115async function unblockAccount (req: express.Request, res: express.Response) {
@@ -116,7 +117,7 @@ async function unblockAccount (req: express.Request, res: express.Response) {
116 117
117 await removeAccountFromBlocklist(accountBlock) 118 await removeAccountFromBlocklist(accountBlock)
118 119
119 return res.status(204).end() 120 return res.status(HttpStatusCode.NO_CONTENT_204).end()
120} 121}
121 122
122async function listBlockedServers (req: express.Request, res: express.Response) { 123async function listBlockedServers (req: express.Request, res: express.Response) {
@@ -145,7 +146,7 @@ async function blockServer (req: express.Request, res: express.Response) {
145 forUserId: null // For all users 146 forUserId: null // For all users
146 }).catch(err => logger.error('Cannot remove notifications after a server mute.', { err })) 147 }).catch(err => logger.error('Cannot remove notifications after a server mute.', { err }))
147 148
148 return res.status(204).end() 149 return res.status(HttpStatusCode.NO_CONTENT_204).end()
149} 150}
150 151
151async function unblockServer (req: express.Request, res: express.Response) { 152async function unblockServer (req: express.Request, res: express.Response) {
@@ -153,5 +154,5 @@ async function unblockServer (req: express.Request, res: express.Response) {
153 154
154 await removeServerFromBlocklist(serverBlock) 155 await removeServerFromBlocklist(serverBlock)
155 156
156 return res.status(204).end() 157 return res.status(HttpStatusCode.NO_CONTENT_204).end()
157} 158}
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts
index 5b113feac..d743a9912 100644
--- a/server/controllers/api/users/index.ts
+++ b/server/controllers/api/users/index.ts
@@ -52,6 +52,7 @@ import { myVideosHistoryRouter } from './my-history'
52import { myNotificationsRouter } from './my-notifications' 52import { myNotificationsRouter } from './my-notifications'
53import { mySubscriptionsRouter } from './my-subscriptions' 53import { mySubscriptionsRouter } from './my-subscriptions'
54import { myVideoPlaylistsRouter } from './my-video-playlists' 54import { myVideoPlaylistsRouter } from './my-video-playlists'
55import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
55 56
56const auditLogger = auditLoggerFactory('users') 57const auditLogger = auditLoggerFactory('users')
57 58
@@ -255,7 +256,7 @@ async function registerUser (req: express.Request, res: express.Response) {
255 256
256 Hooks.runAction('action:api.user.registered', { body, user, account, videoChannel }) 257 Hooks.runAction('action:api.user.registered', { body, user, account, videoChannel })
257 258
258 return res.type('json').status(204).end() 259 return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
259} 260}
260 261
261async function unblockUser (req: express.Request, res: express.Response) { 262async function unblockUser (req: express.Request, res: express.Response) {
@@ -265,7 +266,7 @@ async function unblockUser (req: express.Request, res: express.Response) {
265 266
266 Hooks.runAction('action:api.user.unblocked', { user }) 267 Hooks.runAction('action:api.user.unblocked', { user })
267 268
268 return res.status(204).end() 269 return res.status(HttpStatusCode.NO_CONTENT_204).end()
269} 270}
270 271
271async function blockUser (req: express.Request, res: express.Response) { 272async function blockUser (req: express.Request, res: express.Response) {
@@ -276,7 +277,7 @@ async function blockUser (req: express.Request, res: express.Response) {
276 277
277 Hooks.runAction('action:api.user.blocked', { user }) 278 Hooks.runAction('action:api.user.blocked', { user })
278 279
279 return res.status(204).end() 280 return res.status(HttpStatusCode.NO_CONTENT_204).end()
280} 281}
281 282
282function getUser (req: express.Request, res: express.Response) { 283function getUser (req: express.Request, res: express.Response) {
@@ -310,7 +311,7 @@ async function removeUser (req: express.Request, res: express.Response) {
310 311
311 Hooks.runAction('action:api.user.deleted', { user }) 312 Hooks.runAction('action:api.user.deleted', { user })
312 313
313 return res.sendStatus(204) 314 return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
314} 315}
315 316
316async function updateUser (req: express.Request, res: express.Response) { 317async function updateUser (req: express.Request, res: express.Response) {
@@ -338,7 +339,7 @@ async function updateUser (req: express.Request, res: express.Response) {
338 339
339 // Don't need to send this update to followers, these attributes are not federated 340 // Don't need to send this update to followers, these attributes are not federated
340 341
341 return res.sendStatus(204) 342 return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
342} 343}
343 344
344async function askResetUserPassword (req: express.Request, res: express.Response) { 345async function askResetUserPassword (req: express.Request, res: express.Response) {
@@ -348,7 +349,7 @@ async function askResetUserPassword (req: express.Request, res: express.Response
348 const url = WEBSERVER.URL + '/reset-password?userId=' + user.id + '&verificationString=' + verificationString 349 const url = WEBSERVER.URL + '/reset-password?userId=' + user.id + '&verificationString=' + verificationString
349 await Emailer.Instance.addPasswordResetEmailJob(user.username, user.email, url) 350 await Emailer.Instance.addPasswordResetEmailJob(user.username, user.email, url)
350 351
351 return res.status(204).end() 352 return res.status(HttpStatusCode.NO_CONTENT_204).end()
352} 353}
353 354
354async function resetUserPassword (req: express.Request, res: express.Response) { 355async function resetUserPassword (req: express.Request, res: express.Response) {
@@ -358,7 +359,7 @@ async function resetUserPassword (req: express.Request, res: express.Response) {
358 await user.save() 359 await user.save()
359 await Redis.Instance.removePasswordVerificationString(user.id) 360 await Redis.Instance.removePasswordVerificationString(user.id)
360 361
361 return res.status(204).end() 362 return res.status(HttpStatusCode.NO_CONTENT_204).end()
362} 363}
363 364
364async function reSendVerifyUserEmail (req: express.Request, res: express.Response) { 365async function reSendVerifyUserEmail (req: express.Request, res: express.Response) {
@@ -366,7 +367,7 @@ async function reSendVerifyUserEmail (req: express.Request, res: express.Respons
366 367
367 await sendVerifyUserEmail(user) 368 await sendVerifyUserEmail(user)
368 369
369 return res.status(204).end() 370 return res.status(HttpStatusCode.NO_CONTENT_204).end()
370} 371}
371 372
372async function verifyUserEmail (req: express.Request, res: express.Response) { 373async function verifyUserEmail (req: express.Request, res: express.Response) {
@@ -380,7 +381,7 @@ async function verifyUserEmail (req: express.Request, res: express.Response) {
380 381
381 await user.save() 382 await user.save()
382 383
383 return res.status(204).end() 384 return res.status(HttpStatusCode.NO_CONTENT_204).end()
384} 385}
385 386
386async function changeUserBlock (res: express.Response, user: MUserAccountDefault, block: boolean, reason?: string) { 387async function changeUserBlock (res: express.Response, user: MUserAccountDefault, block: boolean, reason?: string) {
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts
index b490518fc..3d2a325fe 100644
--- a/server/controllers/api/users/me.ts
+++ b/server/controllers/api/users/me.ts
@@ -28,6 +28,7 @@ import { AccountVideoRateModel } from '../../../models/account/account-video-rat
28import { UserModel } from '../../../models/account/user' 28import { UserModel } from '../../../models/account/user'
29import { VideoModel } from '../../../models/video/video' 29import { VideoModel } from '../../../models/video/video'
30import { VideoImportModel } from '../../../models/video/video-import' 30import { VideoImportModel } from '../../../models/video/video-import'
31import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
31 32
32const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) 33const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR })
33 34
@@ -162,7 +163,7 @@ async function deleteMe (req: express.Request, res: express.Response) {
162 163
163 await user.destroy() 164 await user.destroy()
164 165
165 return res.sendStatus(204) 166 return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
166} 167}
167 168
168async function updateMe (req: express.Request, res: express.Response) { 169async function updateMe (req: express.Request, res: express.Response) {
@@ -210,7 +211,7 @@ async function updateMe (req: express.Request, res: express.Response) {
210 await sendVerifyUserEmail(user, true) 211 await sendVerifyUserEmail(user, true)
211 } 212 }
212 213
213 return res.sendStatus(204) 214 return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
214} 215}
215 216
216async function updateMyAvatar (req: express.Request, res: express.Response) { 217async function updateMyAvatar (req: express.Request, res: express.Response) {
diff --git a/server/controllers/api/users/my-blocklist.ts b/server/controllers/api/users/my-blocklist.ts
index 6eba22d52..faaef3ac0 100644
--- a/server/controllers/api/users/my-blocklist.ts
+++ b/server/controllers/api/users/my-blocklist.ts
@@ -22,6 +22,7 @@ import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist
22import { ServerBlocklistModel } from '../../../models/server/server-blocklist' 22import { ServerBlocklistModel } from '../../../models/server/server-blocklist'
23import { UserNotificationModel } from '@server/models/account/user-notification' 23import { UserNotificationModel } from '@server/models/account/user-notification'
24import { logger } from '@server/helpers/logger' 24import { logger } from '@server/helpers/logger'
25import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
25 26
26const myBlocklistRouter = express.Router() 27const myBlocklistRouter = express.Router()
27 28
@@ -99,7 +100,7 @@ async function blockAccount (req: express.Request, res: express.Response) {
99 forUserId: user.id 100 forUserId: user.id
100 }).catch(err => logger.error('Cannot remove notifications after an account mute.', { err })) 101 }).catch(err => logger.error('Cannot remove notifications after an account mute.', { err }))
101 102
102 return res.status(204).end() 103 return res.status(HttpStatusCode.NO_CONTENT_204).end()
103} 104}
104 105
105async function unblockAccount (req: express.Request, res: express.Response) { 106async function unblockAccount (req: express.Request, res: express.Response) {
@@ -107,7 +108,7 @@ async function unblockAccount (req: express.Request, res: express.Response) {
107 108
108 await removeAccountFromBlocklist(accountBlock) 109 await removeAccountFromBlocklist(accountBlock)
109 110
110 return res.status(204).end() 111 return res.status(HttpStatusCode.NO_CONTENT_204).end()
111} 112}
112 113
113async function listBlockedServers (req: express.Request, res: express.Response) { 114async function listBlockedServers (req: express.Request, res: express.Response) {
@@ -136,7 +137,7 @@ async function blockServer (req: express.Request, res: express.Response) {
136 forUserId: user.id 137 forUserId: user.id
137 }).catch(err => logger.error('Cannot remove notifications after a server mute.', { err })) 138 }).catch(err => logger.error('Cannot remove notifications after a server mute.', { err }))
138 139
139 return res.status(204).end() 140 return res.status(HttpStatusCode.NO_CONTENT_204).end()
140} 141}
141 142
142async function unblockServer (req: express.Request, res: express.Response) { 143async function unblockServer (req: express.Request, res: express.Response) {
@@ -144,5 +145,5 @@ async function unblockServer (req: express.Request, res: express.Response) {
144 145
145 await removeServerFromBlocklist(serverBlock) 146 await removeServerFromBlocklist(serverBlock)
146 147
147 return res.status(204).end() 148 return res.status(HttpStatusCode.NO_CONTENT_204).end()
148} 149}
diff --git a/server/controllers/api/users/my-history.ts b/server/controllers/api/users/my-history.ts
index dc915977f..80d4dc748 100644
--- a/server/controllers/api/users/my-history.ts
+++ b/server/controllers/api/users/my-history.ts
@@ -10,6 +10,7 @@ import {
10import { getFormattedObjects } from '../../../helpers/utils' 10import { getFormattedObjects } from '../../../helpers/utils'
11import { UserVideoHistoryModel } from '../../../models/account/user-video-history' 11import { UserVideoHistoryModel } from '../../../models/account/user-video-history'
12import { sequelizeTypescript } from '../../../initializers/database' 12import { sequelizeTypescript } from '../../../initializers/database'
13import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
13 14
14const myVideosHistoryRouter = express.Router() 15const myVideosHistoryRouter = express.Router()
15 16
@@ -50,5 +51,7 @@ async function removeUserHistory (req: express.Request, res: express.Response) {
50 return UserVideoHistoryModel.removeUserHistoryBefore(user, beforeDate, t) 51 return UserVideoHistoryModel.removeUserHistoryBefore(user, beforeDate, t)
51 }) 52 })
52 53
53 return res.type('json').status(204).end() 54 return res.type('json')
55 .status(HttpStatusCode.NO_CONTENT_204)
56 .end()
54} 57}
diff --git a/server/controllers/api/users/my-notifications.ts b/server/controllers/api/users/my-notifications.ts
index 050866960..5f5e4c5e6 100644
--- a/server/controllers/api/users/my-notifications.ts
+++ b/server/controllers/api/users/my-notifications.ts
@@ -19,6 +19,7 @@ import {
19} from '../../../middlewares/validators/user-notifications' 19} from '../../../middlewares/validators/user-notifications'
20import { UserNotificationSetting } from '../../../../shared/models/users' 20import { UserNotificationSetting } from '../../../../shared/models/users'
21import { UserNotificationSettingModel } from '../../../models/account/user-notification-setting' 21import { UserNotificationSettingModel } from '../../../models/account/user-notification-setting'
22import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
22 23
23const myNotificationsRouter = express.Router() 24const myNotificationsRouter = express.Router()
24 25
@@ -84,7 +85,7 @@ async function updateNotificationSettings (req: express.Request, res: express.Re
84 85
85 await UserNotificationSettingModel.update(values, query) 86 await UserNotificationSettingModel.update(values, query)
86 87
87 return res.status(204).end() 88 return res.status(HttpStatusCode.NO_CONTENT_204).end()
88} 89}
89 90
90async function listUserNotifications (req: express.Request, res: express.Response) { 91async function listUserNotifications (req: express.Request, res: express.Response) {
@@ -100,7 +101,7 @@ async function markAsReadUserNotifications (req: express.Request, res: express.R
100 101
101 await UserNotificationModel.markAsRead(user.id, req.body.ids) 102 await UserNotificationModel.markAsRead(user.id, req.body.ids)
102 103
103 return res.status(204).end() 104 return res.status(HttpStatusCode.NO_CONTENT_204).end()
104} 105}
105 106
106async function markAsReadAllUserNotifications (req: express.Request, res: express.Response) { 107async function markAsReadAllUserNotifications (req: express.Request, res: express.Response) {
@@ -108,5 +109,5 @@ async function markAsReadAllUserNotifications (req: express.Request, res: expres
108 109
109 await UserNotificationModel.markAllAsRead(user.id) 110 await UserNotificationModel.markAllAsRead(user.id)
110 111
111 return res.status(204).end() 112 return res.status(HttpStatusCode.NO_CONTENT_204).end()
112} 113}
diff --git a/server/controllers/api/users/my-subscriptions.ts b/server/controllers/api/users/my-subscriptions.ts
index 66b33c477..ec77ddd7a 100644
--- a/server/controllers/api/users/my-subscriptions.ts
+++ b/server/controllers/api/users/my-subscriptions.ts
@@ -27,6 +27,7 @@ import {
27import { ActorFollowModel } from '../../../models/activitypub/actor-follow' 27import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
28import { VideoModel } from '../../../models/video/video' 28import { VideoModel } from '../../../models/video/video'
29import { sendUndoFollow } from '@server/lib/activitypub/send' 29import { sendUndoFollow } from '@server/lib/activitypub/send'
30import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
30 31
31const mySubscriptionsRouter = express.Router() 32const mySubscriptionsRouter = express.Router()
32 33
@@ -126,7 +127,7 @@ function addUserSubscription (req: express.Request, res: express.Response) {
126 127
127 JobQueue.Instance.createJob({ type: 'activitypub-follow', payload }) 128 JobQueue.Instance.createJob({ type: 'activitypub-follow', payload })
128 129
129 return res.status(204).end() 130 return res.status(HttpStatusCode.NO_CONTENT_204).end()
130} 131}
131 132
132function getUserSubscription (req: express.Request, res: express.Response) { 133function getUserSubscription (req: express.Request, res: express.Response) {
@@ -144,7 +145,9 @@ async function deleteUserSubscription (req: express.Request, res: express.Respon
144 return subscription.destroy({ transaction: t }) 145 return subscription.destroy({ transaction: t })
145 }) 146 })
146 147
147 return res.type('json').status(204).end() 148 return res.type('json')
149 .status(HttpStatusCode.NO_CONTENT_204)
150 .end()
148} 151}
149 152
150async function getUserSubscriptions (req: express.Request, res: express.Response) { 153async function getUserSubscriptions (req: express.Request, res: express.Response) {
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts
index 45c936978..5c96950c5 100644
--- a/server/controllers/api/video-channel.ts
+++ b/server/controllers/api/video-channel.ts
@@ -38,6 +38,7 @@ import { AccountModel } from '../../models/account/account'
38import { VideoModel } from '../../models/video/video' 38import { VideoModel } from '../../models/video/video'
39import { VideoChannelModel } from '../../models/video/video-channel' 39import { VideoChannelModel } from '../../models/video/video-channel'
40import { VideoPlaylistModel } from '../../models/video/video-playlist' 40import { VideoPlaylistModel } from '../../models/video/video-playlist'
41import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
41 42
42const auditLogger = auditLoggerFactory('channels') 43const auditLogger = auditLoggerFactory('channels')
43const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) 44const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR })
@@ -212,7 +213,7 @@ async function updateVideoChannel (req: express.Request, res: express.Response)
212 throw err 213 throw err
213 } 214 }
214 215
215 res.type('json').status(204).end() 216 res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
216 217
217 // Don't process in a transaction, and after the response because it could be long 218 // Don't process in a transaction, and after the response because it could be long
218 if (doBulkVideoUpdate) { 219 if (doBulkVideoUpdate) {
@@ -232,7 +233,7 @@ async function removeVideoChannel (req: express.Request, res: express.Response)
232 logger.info('Video channel %s deleted.', videoChannelInstance.Actor.url) 233 logger.info('Video channel %s deleted.', videoChannelInstance.Actor.url)
233 }) 234 })
234 235
235 return res.type('json').status(204).end() 236 return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
236} 237}
237 238
238async function getVideoChannel (req: express.Request, res: express.Response) { 239async function getVideoChannel (req: express.Request, res: express.Response) {
diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts
index fb08a63b2..f3dc8b2a9 100644
--- a/server/controllers/api/video-playlist.ts
+++ b/server/controllers/api/video-playlist.ts
@@ -42,6 +42,7 @@ import {
42import { AccountModel } from '../../models/account/account' 42import { AccountModel } from '../../models/account/account'
43import { VideoPlaylistModel } from '../../models/video/video-playlist' 43import { VideoPlaylistModel } from '../../models/video/video-playlist'
44import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element' 44import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element'
45import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
45 46
46const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR }) 47const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR })
47 48
@@ -271,7 +272,7 @@ async function updateVideoPlaylist (req: express.Request, res: express.Response)
271 throw err 272 throw err
272 } 273 }
273 274
274 return res.type('json').status(204).end() 275 return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
275} 276}
276 277
277async function removeVideoPlaylist (req: express.Request, res: express.Response) { 278async function removeVideoPlaylist (req: express.Request, res: express.Response) {
@@ -285,7 +286,7 @@ async function removeVideoPlaylist (req: express.Request, res: express.Response)
285 logger.info('Video playlist %s deleted.', videoPlaylistInstance.uuid) 286 logger.info('Video playlist %s deleted.', videoPlaylistInstance.uuid)
286 }) 287 })
287 288
288 return res.type('json').status(204).end() 289 return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
289} 290}
290 291
291async function addVideoInPlaylist (req: express.Request, res: express.Response) { 292async function addVideoInPlaylist (req: express.Request, res: express.Response) {
@@ -351,7 +352,7 @@ async function updateVideoPlaylistElement (req: express.Request, res: express.Re
351 352
352 logger.info('Element of position %d of playlist %s updated.', playlistElement.position, videoPlaylist.uuid) 353 logger.info('Element of position %d of playlist %s updated.', playlistElement.position, videoPlaylist.uuid)
353 354
354 return res.type('json').status(204).end() 355 return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
355} 356}
356 357
357async function removeVideoFromPlaylist (req: express.Request, res: express.Response) { 358async function removeVideoFromPlaylist (req: express.Request, res: express.Response) {
@@ -379,7 +380,7 @@ async function removeVideoFromPlaylist (req: express.Request, res: express.Respo
379 sendUpdateVideoPlaylist(videoPlaylist, undefined) 380 sendUpdateVideoPlaylist(videoPlaylist, undefined)
380 .catch(err => logger.error('Cannot send video playlist update.', { err })) 381 .catch(err => logger.error('Cannot send video playlist update.', { err }))
381 382
382 return res.type('json').status(204).end() 383 return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
383} 384}
384 385
385async function reorderVideosPlaylist (req: express.Request, res: express.Response) { 386async function reorderVideosPlaylist (req: express.Request, res: express.Response) {
@@ -391,7 +392,7 @@ async function reorderVideosPlaylist (req: express.Request, res: express.Respons
391 const reorderLength: number = body.reorderLength || 1 392 const reorderLength: number = body.reorderLength || 1
392 393
393 if (start === insertAfter) { 394 if (start === insertAfter) {
394 return res.status(204).end() 395 return res.status(HttpStatusCode.NO_CONTENT_204).end()
395 } 396 }
396 397
397 // Example: if we reorder position 2 and insert after position 5 (so at position 6): # 1 2 3 4 5 6 7 8 9 398 // Example: if we reorder position 2 and insert after position 5 (so at position 6): # 1 2 3 4 5 6 7 8 9
@@ -432,7 +433,7 @@ async function reorderVideosPlaylist (req: express.Request, res: express.Respons
432 videoPlaylist.uuid, insertAfter, start, start + reorderLength - 1 433 videoPlaylist.uuid, insertAfter, start, start + reorderLength - 1
433 ) 434 )
434 435
435 return res.type('json').status(204).end() 436 return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
436} 437}
437 438
438async function getVideoPlaylistVideos (req: express.Request, res: express.Response) { 439async function getVideoPlaylistVideos (req: express.Request, res: express.Response) {
diff --git a/server/controllers/api/videos/blacklist.ts b/server/controllers/api/videos/blacklist.ts
index 3b25ceea2..fa8448c86 100644
--- a/server/controllers/api/videos/blacklist.ts
+++ b/server/controllers/api/videos/blacklist.ts
@@ -18,6 +18,7 @@ import {
18 videosBlacklistUpdateValidator 18 videosBlacklistUpdateValidator
19} from '../../../middlewares' 19} from '../../../middlewares'
20import { VideoBlacklistModel } from '../../../models/video/video-blacklist' 20import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
21import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
21 22
22const blacklistRouter = express.Router() 23const blacklistRouter = express.Router()
23 24
@@ -69,7 +70,7 @@ async function addVideoToBlacklistController (req: express.Request, res: express
69 70
70 logger.info('Video %s blacklisted.', videoInstance.uuid) 71 logger.info('Video %s blacklisted.', videoInstance.uuid)
71 72
72 return res.type('json').sendStatus(204) 73 return res.type('json').sendStatus(HttpStatusCode.NO_CONTENT_204)
73} 74}
74 75
75async function updateVideoBlacklistController (req: express.Request, res: express.Response) { 76async function updateVideoBlacklistController (req: express.Request, res: express.Response) {
@@ -81,7 +82,7 @@ async function updateVideoBlacklistController (req: express.Request, res: expres
81 return videoBlacklist.save({ transaction: t }) 82 return videoBlacklist.save({ transaction: t })
82 }) 83 })
83 84
84 return res.type('json').sendStatus(204) 85 return res.type('json').sendStatus(HttpStatusCode.NO_CONTENT_204)
85} 86}
86 87
87async function listBlacklist (req: express.Request, res: express.Response) { 88async function listBlacklist (req: express.Request, res: express.Response) {
@@ -104,5 +105,5 @@ async function removeVideoFromBlacklistController (req: express.Request, res: ex
104 105
105 logger.info('Video %s removed from blacklist.', video.uuid) 106 logger.info('Video %s removed from blacklist.', video.uuid)
106 107
107 return res.type('json').sendStatus(204) 108 return res.type('json').sendStatus(HttpStatusCode.NO_CONTENT_204)
108} 109}
diff --git a/server/controllers/api/videos/captions.ts b/server/controllers/api/videos/captions.ts
index c4e2ee72c..bf82e2c19 100644
--- a/server/controllers/api/videos/captions.ts
+++ b/server/controllers/api/videos/captions.ts
@@ -11,6 +11,7 @@ import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils'
11import { CONFIG } from '../../../initializers/config' 11import { CONFIG } from '../../../initializers/config'
12import { sequelizeTypescript } from '../../../initializers/database' 12import { sequelizeTypescript } from '../../../initializers/database'
13import { MVideoCaptionVideo } from '@server/types/models' 13import { MVideoCaptionVideo } from '@server/types/models'
14import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
14 15
15const reqVideoCaptionAdd = createReqFiles( 16const reqVideoCaptionAdd = createReqFiles(
16 [ 'captionfile' ], 17 [ 'captionfile' ],
@@ -72,7 +73,7 @@ async function addVideoCaption (req: express.Request, res: express.Response) {
72 await federateVideoIfNeeded(video, false, t) 73 await federateVideoIfNeeded(video, false, t)
73 }) 74 })
74 75
75 return res.status(204).end() 76 return res.status(HttpStatusCode.NO_CONTENT_204).end()
76} 77}
77 78
78async function deleteVideoCaption (req: express.Request, res: express.Response) { 79async function deleteVideoCaption (req: express.Request, res: express.Response) {
@@ -88,5 +89,5 @@ async function deleteVideoCaption (req: express.Request, res: express.Response)
88 89
89 logger.info('Video caption %s of video %s deleted.', videoCaption.language, video.uuid) 90 logger.info('Video caption %s of video %s deleted.', videoCaption.language, video.uuid)
90 91
91 return res.type('json').status(204).end() 92 return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
92} 93}
diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.ts
index 020d0b104..752a33596 100644
--- a/server/controllers/api/videos/comment.ts
+++ b/server/controllers/api/videos/comment.ts
@@ -29,6 +29,7 @@ import {
29} from '../../../middlewares/validators' 29} from '../../../middlewares/validators'
30import { AccountModel } from '../../../models/account/account' 30import { AccountModel } from '../../../models/account/account'
31import { VideoCommentModel } from '../../../models/video/video-comment' 31import { VideoCommentModel } from '../../../models/video/video-comment'
32import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
32 33
33const auditLogger = auditLoggerFactory('comments') 34const auditLogger = auditLoggerFactory('comments')
34const videoCommentRouter = express.Router() 35const videoCommentRouter = express.Router()
@@ -161,7 +162,7 @@ async function listVideoThreadComments (req: express.Request, res: express.Respo
161 } 162 }
162 163
163 if (resultList.data.length === 0) { 164 if (resultList.data.length === 0) {
164 return res.sendStatus(404) 165 return res.sendStatus(HttpStatusCode.NOT_FOUND_404)
165 } 166 }
166 167
167 return res.json(buildFormattedCommentTree(resultList)) 168 return res.json(buildFormattedCommentTree(resultList))
@@ -218,5 +219,7 @@ async function removeVideoComment (req: express.Request, res: express.Response)
218 219
219 auditLogger.delete(getAuditIdFromRes(res), new CommentAuditView(videoCommentInstance.toFormattedJSON())) 220 auditLogger.delete(getAuditIdFromRes(res), new CommentAuditView(videoCommentInstance.toFormattedJSON()))
220 221
221 return res.type('json').status(204).end() 222 return res.type('json')
223 .status(HttpStatusCode.NO_CONTENT_204)
224 .end()
222} 225}
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts
index bc5fea7aa..cd9ba046d 100644
--- a/server/controllers/api/videos/import.ts
+++ b/server/controllers/api/videos/import.ts
@@ -36,6 +36,7 @@ import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoIm
36import { VideoModel } from '../../../models/video/video' 36import { VideoModel } from '../../../models/video/video'
37import { VideoCaptionModel } from '../../../models/video/video-caption' 37import { VideoCaptionModel } from '../../../models/video/video-caption'
38import { VideoImportModel } from '../../../models/video/video-import' 38import { VideoImportModel } from '../../../models/video/video-import'
39import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
39 40
40const auditLogger = auditLoggerFactory('video-imports') 41const auditLogger = auditLoggerFactory('video-imports')
41const videoImportsRouter = express.Router() 42const videoImportsRouter = express.Router()
@@ -146,7 +147,7 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response)
146 } catch (err) { 147 } catch (err) {
147 logger.info('Cannot fetch information from import for URL %s.', targetUrl, { err }) 148 logger.info('Cannot fetch information from import for URL %s.', targetUrl, { err })
148 149
149 return res.status(400).json({ 150 return res.status(HttpStatusCode.BAD_REQUEST_400).json({
150 error: 'Cannot fetch remote information of this URL.' 151 error: 'Cannot fetch remote information of this URL.'
151 }).end() 152 }).end()
152 } 153 }
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 71a0f97e2..e1c775180 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -66,6 +66,7 @@ import { liveRouter } from './live'
66import { ownershipVideoRouter } from './ownership' 66import { ownershipVideoRouter } from './ownership'
67import { rateVideoRouter } from './rate' 67import { rateVideoRouter } from './rate'
68import { watchingRouter } from './watching' 68import { watchingRouter } from './watching'
69import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
69 70
70const auditLogger = auditLoggerFactory('videos') 71const auditLogger = auditLoggerFactory('videos')
71const videosRouter = express.Router() 72const videosRouter = express.Router()
@@ -178,7 +179,7 @@ async function addVideo (req: express.Request, res: express.Response) {
178 // Set timeout to 10 minutes, as Express's default is 2 minutes 179 // Set timeout to 10 minutes, as Express's default is 2 minutes
179 req.setTimeout(1000 * 60 * 10, () => { 180 req.setTimeout(1000 * 60 * 10, () => {
180 logger.error('Upload video has timed out.') 181 logger.error('Upload video has timed out.')
181 return res.sendStatus(408) 182 return res.sendStatus(HttpStatusCode.REQUEST_TIMEOUT_408)
182 }) 183 })
183 184
184 const videoPhysicalFile = req.files['videofile'][0] 185 const videoPhysicalFile = req.files['videofile'][0]
@@ -394,7 +395,9 @@ async function updateVideo (req: express.Request, res: express.Response) {
394 throw err 395 throw err
395 } 396 }
396 397
397 return res.type('json').status(204).end() 398 return res.type('json')
399 .status(HttpStatusCode.NO_CONTENT_204)
400 .end()
398} 401}
399 402
400async function getVideo (req: express.Request, res: express.Response) { 403async function getVideo (req: express.Request, res: express.Response) {
@@ -421,7 +424,7 @@ async function viewVideo (req: express.Request, res: express.Response) {
421 const exists = await Redis.Instance.doesVideoIPViewExist(ip, immutableVideoAttrs.uuid) 424 const exists = await Redis.Instance.doesVideoIPViewExist(ip, immutableVideoAttrs.uuid)
422 if (exists) { 425 if (exists) {
423 logger.debug('View for ip %s and video %s already exists.', ip, immutableVideoAttrs.uuid) 426 logger.debug('View for ip %s and video %s already exists.', ip, immutableVideoAttrs.uuid)
424 return res.sendStatus(204) 427 return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
425 } 428 }
426 429
427 const video = await VideoModel.load(immutableVideoAttrs.id) 430 const video = await VideoModel.load(immutableVideoAttrs.id)
@@ -454,7 +457,7 @@ async function viewVideo (req: express.Request, res: express.Response) {
454 457
455 Hooks.runAction('action:api.video.viewed', { video, ip }) 458 Hooks.runAction('action:api.video.viewed', { video, ip })
456 459
457 return res.sendStatus(204) 460 return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
458} 461}
459 462
460async function getVideoDescription (req: express.Request, res: express.Response) { 463async function getVideoDescription (req: express.Request, res: express.Response) {
@@ -517,5 +520,7 @@ async function removeVideo (req: express.Request, res: express.Response) {
517 520
518 Hooks.runAction('action:api.video.deleted', { video: videoInstance }) 521 Hooks.runAction('action:api.video.deleted', { video: videoInstance })
519 522
520 return res.type('json').status(204).end() 523 return res.type('json')
524 .status(HttpStatusCode.NO_CONTENT_204)
525 .end()
521} 526}
diff --git a/server/controllers/api/videos/live.ts b/server/controllers/api/videos/live.ts
index e67d89612..04d2494ce 100644
--- a/server/controllers/api/videos/live.ts
+++ b/server/controllers/api/videos/live.ts
@@ -16,6 +16,7 @@ import { sequelizeTypescript } from '../../../initializers/database'
16import { createVideoMiniatureFromExisting } from '../../../lib/thumbnail' 16import { createVideoMiniatureFromExisting } from '../../../lib/thumbnail'
17import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares' 17import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares'
18import { VideoModel } from '../../../models/video/video' 18import { VideoModel } from '../../../models/video/video'
19import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
19 20
20const liveRouter = express.Router() 21const liveRouter = express.Router()
21 22
@@ -75,7 +76,7 @@ async function updateLiveVideo (req: express.Request, res: express.Response) {
75 76
76 await federateVideoIfNeeded(video, false) 77 await federateVideoIfNeeded(video, false)
77 78
78 return res.sendStatus(204) 79 return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
79} 80}
80 81
81async function addLiveVideo (req: express.Request, res: express.Response) { 82async 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 d76fee51d..86adb6c69 100644
--- a/server/controllers/api/videos/ownership.ts
+++ b/server/controllers/api/videos/ownership.ts
@@ -19,6 +19,7 @@ import { changeVideoChannelShare } from '../../../lib/activitypub/share'
19import { sendUpdateVideo } from '../../../lib/activitypub/send' 19import { sendUpdateVideo } from '../../../lib/activitypub/send'
20import { VideoModel } from '../../../models/video/video' 20import { VideoModel } from '../../../models/video/video'
21import { MVideoFullLight } from '@server/types/models' 21import { MVideoFullLight } from '@server/types/models'
22import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
22 23
23const ownershipVideoRouter = express.Router() 24const ownershipVideoRouter = express.Router()
24 25
@@ -80,7 +81,9 @@ async function giveVideoOwnership (req: express.Request, res: express.Response)
80 }) 81 })
81 82
82 logger.info('Ownership change for video %s created.', videoInstance.name) 83 logger.info('Ownership change for video %s created.', videoInstance.name)
83 return res.type('json').status(204).end() 84 return res.type('json')
85 .status(HttpStatusCode.NO_CONTENT_204)
86 .end()
84} 87}
85 88
86async function listVideoOwnership (req: express.Request, res: express.Response) { 89async function listVideoOwnership (req: express.Request, res: express.Response) {
@@ -119,7 +122,7 @@ async function acceptOwnership (req: express.Request, res: express.Response) {
119 videoChangeOwnership.status = VideoChangeOwnershipStatus.ACCEPTED 122 videoChangeOwnership.status = VideoChangeOwnershipStatus.ACCEPTED
120 await videoChangeOwnership.save({ transaction: t }) 123 await videoChangeOwnership.save({ transaction: t })
121 124
122 return res.sendStatus(204) 125 return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
123 }) 126 })
124} 127}
125 128
@@ -130,6 +133,6 @@ async function refuseOwnership (req: express.Request, res: express.Response) {
130 videoChangeOwnership.status = VideoChangeOwnershipStatus.REFUSED 133 videoChangeOwnership.status = VideoChangeOwnershipStatus.REFUSED
131 await videoChangeOwnership.save({ transaction: t }) 134 await videoChangeOwnership.save({ transaction: t })
132 135
133 return res.sendStatus(204) 136 return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
134 }) 137 })
135} 138}
diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts
index df1eddb4f..520932c63 100644
--- a/server/controllers/api/videos/rate.ts
+++ b/server/controllers/api/videos/rate.ts
@@ -7,6 +7,7 @@ import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoUp
7import { AccountModel } from '../../../models/account/account' 7import { AccountModel } from '../../../models/account/account'
8import { AccountVideoRateModel } from '../../../models/account/account-video-rate' 8import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
9import { sequelizeTypescript } from '../../../initializers/database' 9import { sequelizeTypescript } from '../../../initializers/database'
10import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
10 11
11const rateVideoRouter = express.Router() 12const rateVideoRouter = express.Router()
12 13
@@ -78,5 +79,7 @@ async function rateVideo (req: express.Request, res: express.Response) {
78 logger.info('Account video rate for video %s of account %s updated.', videoInstance.name, accountInstance.name) 79 logger.info('Account video rate for video %s of account %s updated.', videoInstance.name, accountInstance.name)
79 }) 80 })
80 81
81 return res.type('json').status(204).end() 82 return res.type('json')
83 .status(HttpStatusCode.NO_CONTENT_204)
84 .end()
82} 85}
diff --git a/server/controllers/api/videos/watching.ts b/server/controllers/api/videos/watching.ts
index 036e16f3a..627f12aa9 100644
--- a/server/controllers/api/videos/watching.ts
+++ b/server/controllers/api/videos/watching.ts
@@ -2,6 +2,7 @@ import * as express from 'express'
2import { UserWatchingVideo } from '../../../../shared' 2import { UserWatchingVideo } from '../../../../shared'
3import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoWatchingValidator } from '../../../middlewares' 3import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoWatchingValidator } from '../../../middlewares'
4import { UserVideoHistoryModel } from '../../../models/account/user-video-history' 4import { UserVideoHistoryModel } from '../../../models/account/user-video-history'
5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
5 6
6const watchingRouter = express.Router() 7const watchingRouter = express.Router()
7 8
@@ -31,5 +32,7 @@ async function userWatchVideo (req: express.Request, res: express.Response) {
31 currentTime: body.currentTime 32 currentTime: body.currentTime
32 }) 33 })
33 34
34 return res.type('json').status(204).end() 35 return res.type('json')
36 .status(HttpStatusCode.NO_CONTENT_204)
37 .end()
35} 38}