From 0f6acda11681de90d38dd18669863c6e270851ee Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 19 Mar 2019 09:26:50 +0100 Subject: Does exist --- server/middlewares/validators/blocklist.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'server/middlewares/validators/blocklist.ts') diff --git a/server/middlewares/validators/blocklist.ts b/server/middlewares/validators/blocklist.ts index 109276c63..d7ec649b6 100644 --- a/server/middlewares/validators/blocklist.ts +++ b/server/middlewares/validators/blocklist.ts @@ -2,7 +2,7 @@ import { body, param } from 'express-validator/check' import * as express from 'express' import { logger } from '../../helpers/logger' import { areValidationErrors } from './utils' -import { isAccountNameWithHostExist } from '../../helpers/custom-validators/accounts' +import { doesAccountNameWithHostExist } from '../../helpers/custom-validators/accounts' import { UserModel } from '../../models/account/user' import { AccountBlocklistModel } from '../../models/account/account-blocklist' import { isHostValid } from '../../helpers/custom-validators/servers' @@ -18,7 +18,7 @@ const blockAccountValidator = [ logger.debug('Checking blockAccountByAccountValidator parameters', { parameters: req.body }) if (areValidationErrors(req, res)) return - if (!await isAccountNameWithHostExist(req.body.accountName, res)) return + if (!await doesAccountNameWithHostExist(req.body.accountName, res)) return const user = res.locals.oauth.token.User as UserModel const accountToBlock = res.locals.account @@ -42,11 +42,11 @@ const unblockAccountByAccountValidator = [ logger.debug('Checking unblockAccountByAccountValidator parameters', { parameters: req.params }) if (areValidationErrors(req, res)) return - if (!await isAccountNameWithHostExist(req.params.accountName, res)) return + if (!await doesAccountNameWithHostExist(req.params.accountName, res)) return const user = res.locals.oauth.token.User as UserModel const targetAccount = res.locals.account - if (!await isUnblockAccountExists(user.Account.id, targetAccount.id, res)) return + if (!await doesUnblockAccountExist(user.Account.id, targetAccount.id, res)) return return next() } @@ -59,11 +59,11 @@ const unblockAccountByServerValidator = [ logger.debug('Checking unblockAccountByServerValidator parameters', { parameters: req.params }) if (areValidationErrors(req, res)) return - if (!await isAccountNameWithHostExist(req.params.accountName, res)) return + if (!await doesAccountNameWithHostExist(req.params.accountName, res)) return const serverActor = await getServerActor() const targetAccount = res.locals.account - if (!await isUnblockAccountExists(serverActor.Account.id, targetAccount.id, res)) return + if (!await doesUnblockAccountExist(serverActor.Account.id, targetAccount.id, res)) return return next() } @@ -107,7 +107,7 @@ const unblockServerByAccountValidator = [ if (areValidationErrors(req, res)) return const user = res.locals.oauth.token.User as UserModel - if (!await isUnblockServerExists(user.Account.id, req.params.host, res)) return + if (!await doesUnblockServerExist(user.Account.id, req.params.host, res)) return return next() } @@ -122,7 +122,7 @@ const unblockServerByServerValidator = [ if (areValidationErrors(req, res)) return const serverActor = await getServerActor() - if (!await isUnblockServerExists(serverActor.Account.id, req.params.host, res)) return + if (!await doesUnblockServerExist(serverActor.Account.id, req.params.host, res)) return return next() } @@ -141,7 +141,7 @@ export { // --------------------------------------------------------------------------- -async function isUnblockAccountExists (accountId: number, targetAccountId: number, res: express.Response) { +async function doesUnblockAccountExist (accountId: number, targetAccountId: number, res: express.Response) { const accountBlock = await AccountBlocklistModel.loadByAccountAndTarget(accountId, targetAccountId) if (!accountBlock) { res.status(404) @@ -156,7 +156,7 @@ async function isUnblockAccountExists (accountId: number, targetAccountId: numbe return true } -async function isUnblockServerExists (accountId: number, host: string, res: express.Response) { +async function doesUnblockServerExist (accountId: number, host: string, res: express.Response) { const serverBlock = await ServerBlocklistModel.loadByAccountAndHost(accountId, host) if (!serverBlock) { res.status(404) -- cgit v1.2.3