import express from 'express'
import { body, param, query } from 'express-validator'
import { areValidActorHandles } from '@server/helpers/custom-validators/activitypub/actor'
-import { toArray } from '@server/helpers/custom-validators/misc'
import { getServerActor } from '@server/models/application/application'
+import { arrayify } from '@shared/core-utils'
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers'
-import { logger } from '../../helpers/logger'
import { WEBSERVER } from '../../initializers/constants'
import { AccountBlocklistModel } from '../../models/account/account-blocklist'
import { ServerModel } from '../../models/server/server'
.exists(),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
- logger.debug('Checking blockAccountByAccountValidator parameters', { parameters: req.body })
-
if (areValidationErrors(req, res)) return
if (!await doesAccountNameWithHostExist(req.body.accountName, res)) return
.exists(),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
- logger.debug('Checking unblockAccountByAccountValidator parameters', { parameters: req.params })
-
if (areValidationErrors(req, res)) return
if (!await doesAccountNameWithHostExist(req.params.accountName, res)) return
.exists(),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
- logger.debug('Checking unblockAccountByServerValidator parameters', { parameters: req.params })
-
if (areValidationErrors(req, res)) return
if (!await doesAccountNameWithHostExist(req.params.accountName, res)) return
.custom(isHostValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
- logger.debug('Checking serverGetValidator parameters', { parameters: req.body })
-
if (areValidationErrors(req, res)) return
const host: string = req.body.host
.custom(isHostValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
- logger.debug('Checking unblockServerByAccountValidator parameters', { parameters: req.params })
-
if (areValidationErrors(req, res)) return
const user = res.locals.oauth.token.User
.custom(isHostValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
- logger.debug('Checking unblockServerByServerValidator parameters', { parameters: req.params })
-
if (areValidationErrors(req, res)) return
const serverActor = await getServerActor()
const blocklistStatusValidator = [
query('hosts')
.optional()
- .customSanitizer(toArray)
+ .customSanitizer(arrayify)
.custom(isEachUniqueHostValid).withMessage('Should have a valid hosts array'),
query('accounts')
.optional()
- .customSanitizer(toArray)
+ .customSanitizer(arrayify)
.custom(areValidActorHandles).withMessage('Should have a valid accounts array'),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
- logger.debug('Checking blocklistStatusValidator parameters', { query: req.query })
-
if (areValidationErrors(req, res)) return
return next()