import { WEBSERVER } from '../../initializers/constants'
import { doesAccountNameWithHostExist } from '../../helpers/middlewares'
import { getServerActor } from '@server/models/application/application'
+import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
const blockAccountValidator = [
body('accountName').exists().withMessage('Should have an account name with host'),
const accountToBlock = res.locals.account
if (user.Account.id === accountToBlock.id) {
- res.status(409)
- .send({ error: 'You cannot block yourself.' })
- .end()
+ res.status(HttpStatusCode.CONFLICT_409)
+ .json({ error: 'You cannot block yourself.' })
return
}
const host: string = req.body.host
if (host === WEBSERVER.HOST) {
- return res.status(409)
- .send({ error: 'You cannot block your own server.' })
- .end()
+ return res.status(HttpStatusCode.CONFLICT_409)
+ .json({ error: 'You cannot block your own server.' })
}
const server = await ServerModel.loadOrCreateByHost(host)
async function doesUnblockAccountExist (accountId: number, targetAccountId: number, res: express.Response) {
const accountBlock = await AccountBlocklistModel.loadByAccountAndTarget(accountId, targetAccountId)
if (!accountBlock) {
- res.status(404)
- .send({ error: 'Account block entry not found.' })
- .end()
+ res.status(HttpStatusCode.NOT_FOUND_404)
+ .json({ error: 'Account block entry not found.' })
return false
}
async function doesUnblockServerExist (accountId: number, host: string, res: express.Response) {
const serverBlock = await ServerBlocklistModel.loadByAccountAndHost(accountId, host)
if (!serverBlock) {
- res.status(404)
- .send({ error: 'Server block entry not found.' })
- .end()
+ res.status(HttpStatusCode.NOT_FOUND_404)
+ .json({ error: 'Server block entry not found.' })
return false
}