+ param('hostOrHandle')
+ .custom(value => isHostValid(value) || isRemoteHandleValid(value))
+ .withMessage('Should have a valid host/handle'),
+
+ async (req: express.Request, res: express.Response, next: express.NextFunction) => {
+ logger.debug('Checking unfollowing parameters', { parameters: req.params })
+
+ if (areValidationErrors(req, res)) return
+
+ const serverActor = await getServerActor()
+
+ const { name, host } = getRemoteNameAndHost(req.params.hostOrHandle)
+ const follow = await ActorFollowModel.loadByActorAndTargetNameAndHostForAPI({
+ actorId: serverActor.id,
+ targetName: name,
+ targetHost: host
+ })
+
+ if (!follow) {
+ return res.fail({
+ status: HttpStatusCode.NOT_FOUND_404,
+ message: `Follow ${req.params.hostOrHandle} not found.`
+ })
+ }
+
+ res.locals.follow = follow
+ return next()
+ }
+]
+
+const getFollowerValidator = [
+ param('nameWithHost').custom(isValidActorHandle).withMessage('Should have a valid nameWithHost'),
+
+ async (req: express.Request, res: express.Response, next: express.NextFunction) => {
+ logger.debug('Checking get follower parameters', { parameters: req.params })
+
+ if (areValidationErrors(req, res)) return
+
+ let follow: MActorFollowActorsDefault
+ try {
+ const actorUrl = await loadActorUrlOrGetFromWebfinger(req.params.nameWithHost)
+ const actor = await ActorModel.loadByUrl(actorUrl)