X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fapi%2Fusers%2Fmy-blocklist.ts;h=713c16022322a25fed2a8ab09037fd1fd4cd02a4;hb=6aa541481390980f9c85d2e66514ba0e6ce77a35;hp=95a4105ec31d380ce60da830ba7756bbc83ce3aa;hpb=af5767ffae41b2d5604e41ba9a7225c623dd6735;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/api/users/my-blocklist.ts b/server/controllers/api/users/my-blocklist.ts index 95a4105ec..713c16022 100644 --- a/server/controllers/api/users/my-blocklist.ts +++ b/server/controllers/api/users/my-blocklist.ts @@ -12,17 +12,14 @@ import { } from '../../../middlewares' import { accountsBlocklistSortValidator, - blockAccountByAccountValidator, - blockServerByAccountValidator, + blockAccountValidator, + blockServerValidator, serversBlocklistSortValidator, unblockServerByAccountValidator } from '../../../middlewares/validators' -import { UserModel } from '../../../models/account/user' -import { AccountModel } from '../../../models/account/account' import { AccountBlocklistModel } from '../../../models/account/account-blocklist' import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist' import { ServerBlocklistModel } from '../../../models/server/server-blocklist' -import { ServerModel } from '../../../models/server/server' const myBlocklistRouter = express.Router() @@ -37,7 +34,7 @@ myBlocklistRouter.get('/me/blocklist/accounts', myBlocklistRouter.post('/me/blocklist/accounts', authenticate, - asyncMiddleware(blockAccountByAccountValidator), + asyncMiddleware(blockAccountValidator), asyncRetryTransactionMiddleware(blockAccount) ) @@ -58,7 +55,7 @@ myBlocklistRouter.get('/me/blocklist/servers', myBlocklistRouter.post('/me/blocklist/servers', authenticate, - asyncMiddleware(blockServerByAccountValidator), + asyncMiddleware(blockServerValidator), asyncRetryTransactionMiddleware(blockServer) ) @@ -75,7 +72,7 @@ export { // --------------------------------------------------------------------------- async function listBlockedAccounts (req: express.Request, res: express.Response) { - const user: UserModel = res.locals.oauth.token.User + const user = res.locals.oauth.token.User const resultList = await AccountBlocklistModel.listForApi(user.Account.id, req.query.start, req.query.count, req.query.sort) @@ -83,8 +80,8 @@ async function listBlockedAccounts (req: express.Request, res: express.Response) } async function blockAccount (req: express.Request, res: express.Response) { - const user: UserModel = res.locals.oauth.token.User - const accountToBlock: AccountModel = res.locals.account + const user = res.locals.oauth.token.User + const accountToBlock = res.locals.account await addAccountInBlocklist(user.Account.id, accountToBlock.id) @@ -92,7 +89,7 @@ async function blockAccount (req: express.Request, res: express.Response) { } async function unblockAccount (req: express.Request, res: express.Response) { - const accountBlock: AccountBlocklistModel = res.locals.accountBlock + const accountBlock = res.locals.accountBlock await removeAccountFromBlocklist(accountBlock) @@ -100,7 +97,7 @@ async function unblockAccount (req: express.Request, res: express.Response) { } async function listBlockedServers (req: express.Request, res: express.Response) { - const user: UserModel = res.locals.oauth.token.User + const user = res.locals.oauth.token.User const resultList = await ServerBlocklistModel.listForApi(user.Account.id, req.query.start, req.query.count, req.query.sort) @@ -108,8 +105,8 @@ async function listBlockedServers (req: express.Request, res: express.Response) } async function blockServer (req: express.Request, res: express.Response) { - const user: UserModel = res.locals.oauth.token.User - const serverToBlock: ServerModel = res.locals.server + const user = res.locals.oauth.token.User + const serverToBlock = res.locals.server await addServerInBlocklist(user.Account.id, serverToBlock.id) @@ -117,7 +114,7 @@ async function blockServer (req: express.Request, res: express.Response) { } async function unblockServer (req: express.Request, res: express.Response) { - const serverBlock: ServerBlocklistModel = res.locals.serverBlock + const serverBlock = res.locals.serverBlock await removeServerFromBlocklist(serverBlock)