+
+ 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),
+
+ async (req: express.Request, res: express.Response, next: express.NextFunction) => {
+ if (areValidationErrors(req, res)) return
+
+ let follow: MActorFollowActorsDefault
+ try {
+ const actorUrl = await loadActorUrlOrGetFromWebfinger(req.params.nameWithHost)
+ const actor = await ActorModel.loadByUrl(actorUrl)
+
+ const serverActor = await getServerActor()
+ follow = await ActorFollowModel.loadByActorAndTarget(actor.id, serverActor.id)
+ } catch (err) {
+ logger.warn('Cannot get actor from handle.', { handle: req.params.nameWithHost, err })
+ }