mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
replace numbers with typed http status codes (#3409)
This commit is contained in:
parent
adc1f09c0d
commit
2d53be0267
149 changed files with 1721 additions and 1108 deletions
|
@ -52,6 +52,7 @@ import { myVideosHistoryRouter } from './my-history'
|
|||
import { myNotificationsRouter } from './my-notifications'
|
||||
import { mySubscriptionsRouter } from './my-subscriptions'
|
||||
import { myVideoPlaylistsRouter } from './my-video-playlists'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
|
||||
const auditLogger = auditLoggerFactory('users')
|
||||
|
||||
|
@ -255,7 +256,7 @@ async function registerUser (req: express.Request, res: express.Response) {
|
|||
|
||||
Hooks.runAction('action:api.user.registered', { body, user, account, videoChannel })
|
||||
|
||||
return res.type('json').status(204).end()
|
||||
return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
|
||||
}
|
||||
|
||||
async function unblockUser (req: express.Request, res: express.Response) {
|
||||
|
@ -265,7 +266,7 @@ async function unblockUser (req: express.Request, res: express.Response) {
|
|||
|
||||
Hooks.runAction('action:api.user.unblocked', { user })
|
||||
|
||||
return res.status(204).end()
|
||||
return res.status(HttpStatusCode.NO_CONTENT_204).end()
|
||||
}
|
||||
|
||||
async function blockUser (req: express.Request, res: express.Response) {
|
||||
|
@ -276,7 +277,7 @@ async function blockUser (req: express.Request, res: express.Response) {
|
|||
|
||||
Hooks.runAction('action:api.user.blocked', { user })
|
||||
|
||||
return res.status(204).end()
|
||||
return res.status(HttpStatusCode.NO_CONTENT_204).end()
|
||||
}
|
||||
|
||||
function getUser (req: express.Request, res: express.Response) {
|
||||
|
@ -310,7 +311,7 @@ async function removeUser (req: express.Request, res: express.Response) {
|
|||
|
||||
Hooks.runAction('action:api.user.deleted', { user })
|
||||
|
||||
return res.sendStatus(204)
|
||||
return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
|
||||
}
|
||||
|
||||
async function updateUser (req: express.Request, res: express.Response) {
|
||||
|
@ -338,7 +339,7 @@ async function updateUser (req: express.Request, res: express.Response) {
|
|||
|
||||
// Don't need to send this update to followers, these attributes are not federated
|
||||
|
||||
return res.sendStatus(204)
|
||||
return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
|
||||
}
|
||||
|
||||
async function askResetUserPassword (req: express.Request, res: express.Response) {
|
||||
|
@ -348,7 +349,7 @@ async function askResetUserPassword (req: express.Request, res: express.Response
|
|||
const url = WEBSERVER.URL + '/reset-password?userId=' + user.id + '&verificationString=' + verificationString
|
||||
await Emailer.Instance.addPasswordResetEmailJob(user.username, user.email, url)
|
||||
|
||||
return res.status(204).end()
|
||||
return res.status(HttpStatusCode.NO_CONTENT_204).end()
|
||||
}
|
||||
|
||||
async function resetUserPassword (req: express.Request, res: express.Response) {
|
||||
|
@ -358,7 +359,7 @@ async function resetUserPassword (req: express.Request, res: express.Response) {
|
|||
await user.save()
|
||||
await Redis.Instance.removePasswordVerificationString(user.id)
|
||||
|
||||
return res.status(204).end()
|
||||
return res.status(HttpStatusCode.NO_CONTENT_204).end()
|
||||
}
|
||||
|
||||
async function reSendVerifyUserEmail (req: express.Request, res: express.Response) {
|
||||
|
@ -366,7 +367,7 @@ async function reSendVerifyUserEmail (req: express.Request, res: express.Respons
|
|||
|
||||
await sendVerifyUserEmail(user)
|
||||
|
||||
return res.status(204).end()
|
||||
return res.status(HttpStatusCode.NO_CONTENT_204).end()
|
||||
}
|
||||
|
||||
async function verifyUserEmail (req: express.Request, res: express.Response) {
|
||||
|
@ -380,7 +381,7 @@ async function verifyUserEmail (req: express.Request, res: express.Response) {
|
|||
|
||||
await user.save()
|
||||
|
||||
return res.status(204).end()
|
||||
return res.status(HttpStatusCode.NO_CONTENT_204).end()
|
||||
}
|
||||
|
||||
async function changeUserBlock (res: express.Response, user: MUserAccountDefault, block: boolean, reason?: string) {
|
||||
|
|
|
@ -28,6 +28,7 @@ import { AccountVideoRateModel } from '../../../models/account/account-video-rat
|
|||
import { UserModel } from '../../../models/account/user'
|
||||
import { VideoModel } from '../../../models/video/video'
|
||||
import { VideoImportModel } from '../../../models/video/video-import'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
|
||||
const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR })
|
||||
|
||||
|
@ -162,7 +163,7 @@ async function deleteMe (req: express.Request, res: express.Response) {
|
|||
|
||||
await user.destroy()
|
||||
|
||||
return res.sendStatus(204)
|
||||
return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
|
||||
}
|
||||
|
||||
async function updateMe (req: express.Request, res: express.Response) {
|
||||
|
@ -210,7 +211,7 @@ async function updateMe (req: express.Request, res: express.Response) {
|
|||
await sendVerifyUserEmail(user, true)
|
||||
}
|
||||
|
||||
return res.sendStatus(204)
|
||||
return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
|
||||
}
|
||||
|
||||
async function updateMyAvatar (req: express.Request, res: express.Response) {
|
||||
|
|
|
@ -22,6 +22,7 @@ import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist
|
|||
import { ServerBlocklistModel } from '../../../models/server/server-blocklist'
|
||||
import { UserNotificationModel } from '@server/models/account/user-notification'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
|
||||
const myBlocklistRouter = express.Router()
|
||||
|
||||
|
@ -99,7 +100,7 @@ async function blockAccount (req: express.Request, res: express.Response) {
|
|||
forUserId: user.id
|
||||
}).catch(err => logger.error('Cannot remove notifications after an account mute.', { err }))
|
||||
|
||||
return res.status(204).end()
|
||||
return res.status(HttpStatusCode.NO_CONTENT_204).end()
|
||||
}
|
||||
|
||||
async function unblockAccount (req: express.Request, res: express.Response) {
|
||||
|
@ -107,7 +108,7 @@ async function unblockAccount (req: express.Request, res: express.Response) {
|
|||
|
||||
await removeAccountFromBlocklist(accountBlock)
|
||||
|
||||
return res.status(204).end()
|
||||
return res.status(HttpStatusCode.NO_CONTENT_204).end()
|
||||
}
|
||||
|
||||
async function listBlockedServers (req: express.Request, res: express.Response) {
|
||||
|
@ -136,7 +137,7 @@ async function blockServer (req: express.Request, res: express.Response) {
|
|||
forUserId: user.id
|
||||
}).catch(err => logger.error('Cannot remove notifications after a server mute.', { err }))
|
||||
|
||||
return res.status(204).end()
|
||||
return res.status(HttpStatusCode.NO_CONTENT_204).end()
|
||||
}
|
||||
|
||||
async function unblockServer (req: express.Request, res: express.Response) {
|
||||
|
@ -144,5 +145,5 @@ async function unblockServer (req: express.Request, res: express.Response) {
|
|||
|
||||
await removeServerFromBlocklist(serverBlock)
|
||||
|
||||
return res.status(204).end()
|
||||
return res.status(HttpStatusCode.NO_CONTENT_204).end()
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import {
|
|||
import { getFormattedObjects } from '../../../helpers/utils'
|
||||
import { UserVideoHistoryModel } from '../../../models/account/user-video-history'
|
||||
import { sequelizeTypescript } from '../../../initializers/database'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
|
||||
const myVideosHistoryRouter = express.Router()
|
||||
|
||||
|
@ -50,5 +51,7 @@ async function removeUserHistory (req: express.Request, res: express.Response) {
|
|||
return UserVideoHistoryModel.removeUserHistoryBefore(user, beforeDate, t)
|
||||
})
|
||||
|
||||
return res.type('json').status(204).end()
|
||||
return res.type('json')
|
||||
.status(HttpStatusCode.NO_CONTENT_204)
|
||||
.end()
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import {
|
|||
} from '../../../middlewares/validators/user-notifications'
|
||||
import { UserNotificationSetting } from '../../../../shared/models/users'
|
||||
import { UserNotificationSettingModel } from '../../../models/account/user-notification-setting'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
|
||||
const myNotificationsRouter = express.Router()
|
||||
|
||||
|
@ -84,7 +85,7 @@ async function updateNotificationSettings (req: express.Request, res: express.Re
|
|||
|
||||
await UserNotificationSettingModel.update(values, query)
|
||||
|
||||
return res.status(204).end()
|
||||
return res.status(HttpStatusCode.NO_CONTENT_204).end()
|
||||
}
|
||||
|
||||
async function listUserNotifications (req: express.Request, res: express.Response) {
|
||||
|
@ -100,7 +101,7 @@ async function markAsReadUserNotifications (req: express.Request, res: express.R
|
|||
|
||||
await UserNotificationModel.markAsRead(user.id, req.body.ids)
|
||||
|
||||
return res.status(204).end()
|
||||
return res.status(HttpStatusCode.NO_CONTENT_204).end()
|
||||
}
|
||||
|
||||
async function markAsReadAllUserNotifications (req: express.Request, res: express.Response) {
|
||||
|
@ -108,5 +109,5 @@ async function markAsReadAllUserNotifications (req: express.Request, res: expres
|
|||
|
||||
await UserNotificationModel.markAllAsRead(user.id)
|
||||
|
||||
return res.status(204).end()
|
||||
return res.status(HttpStatusCode.NO_CONTENT_204).end()
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import {
|
|||
import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
|
||||
import { VideoModel } from '../../../models/video/video'
|
||||
import { sendUndoFollow } from '@server/lib/activitypub/send'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
|
||||
const mySubscriptionsRouter = express.Router()
|
||||
|
||||
|
@ -126,7 +127,7 @@ function addUserSubscription (req: express.Request, res: express.Response) {
|
|||
|
||||
JobQueue.Instance.createJob({ type: 'activitypub-follow', payload })
|
||||
|
||||
return res.status(204).end()
|
||||
return res.status(HttpStatusCode.NO_CONTENT_204).end()
|
||||
}
|
||||
|
||||
function getUserSubscription (req: express.Request, res: express.Response) {
|
||||
|
@ -144,7 +145,9 @@ async function deleteUserSubscription (req: express.Request, res: express.Respon
|
|||
return subscription.destroy({ transaction: t })
|
||||
})
|
||||
|
||||
return res.type('json').status(204).end()
|
||||
return res.type('json')
|
||||
.status(HttpStatusCode.NO_CONTENT_204)
|
||||
.end()
|
||||
}
|
||||
|
||||
async function getUserSubscriptions (req: express.Request, res: express.Response) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue