diff options
Diffstat (limited to 'server/middlewares/validators/follows.ts')
-rw-r--r-- | server/middlewares/validators/follows.ts | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/server/middlewares/validators/follows.ts b/server/middlewares/validators/follows.ts index 10482e5d0..2240d30db 100644 --- a/server/middlewares/validators/follows.ts +++ b/server/middlewares/validators/follows.ts | |||
@@ -1,10 +1,9 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body, param } from 'express-validator/check' | 2 | import { body, param } from 'express-validator/check' |
3 | import { getServerAccount, isTestInstance, logger } from '../../helpers' | 3 | import { getServerActor, isTestInstance, logger } from '../../helpers' |
4 | import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' | 4 | import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers' |
5 | import { isEachUniqueHostValid } from '../../helpers/custom-validators/servers' | ||
6 | import { CONFIG } from '../../initializers' | 5 | import { CONFIG } from '../../initializers' |
7 | import { AccountFollowModel } from '../../models/account/account-follow' | 6 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' |
8 | import { areValidationErrors } from './utils' | 7 | import { areValidationErrors } from './utils' |
9 | 8 | ||
10 | const followValidator = [ | 9 | const followValidator = [ |
@@ -29,15 +28,15 @@ const followValidator = [ | |||
29 | ] | 28 | ] |
30 | 29 | ||
31 | const removeFollowingValidator = [ | 30 | const removeFollowingValidator = [ |
32 | param('accountId').custom(isIdOrUUIDValid).withMessage('Should have a valid account id'), | 31 | param('host').custom(isHostValid).withMessage('Should have a valid host'), |
33 | 32 | ||
34 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 33 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
35 | logger.debug('Checking unfollow parameters', { parameters: req.params }) | 34 | logger.debug('Checking unfollow parameters', { parameters: req.params }) |
36 | 35 | ||
37 | if (areValidationErrors(req, res)) return | 36 | if (areValidationErrors(req, res)) return |
38 | 37 | ||
39 | const serverAccount = await getServerAccount() | 38 | const serverActor = await getServerActor() |
40 | const follow = await AccountFollowModel.loadByAccountAndTarget(serverAccount.id, req.params.accountId) | 39 | const follow = await ActorFollowModel.loadByActorAndTargetHost(serverActor.id, req.params.host) |
41 | 40 | ||
42 | if (!follow) { | 41 | if (!follow) { |
43 | return res.status(404) | 42 | return res.status(404) |