(req: express.Request, res: express.Response, next: express.NextFunction) => {
if (areValidationErrors(req, res)) return
(req: express.Request, res: express.Response, next: express.NextFunction) => {
if (areValidationErrors(req, res)) return
if (areValidationErrors(req, res)) return
const body: ServerFollowCreate = req.body
if (areValidationErrors(req, res)) return
const body: ServerFollowCreate = req.body
if (areValidationErrors(req, res)) return
const serverActor = await getServerActor()
const { name, host } = getRemoteNameAndHost(req.params.hostOrHandle)
if (areValidationErrors(req, res)) return
const serverActor = await getServerActor()
const { name, host } = getRemoteNameAndHost(req.params.hostOrHandle)
- const follow = await ActorFollowModel.loadByActorAndTargetNameAndHostForAPI(serverActor.id, name, host)
+ const follow = await ActorFollowModel.loadByActorAndTargetNameAndHostForAPI({
+ actorId: serverActor.id,
+ targetName: name,
+ targetHost: host
+ })
if (areValidationErrors(req, res)) return
let follow: MActorFollowActorsDefault
if (areValidationErrors(req, res)) return
let follow: MActorFollowActorsDefault
- logger.debug('Checking accept/reject follower parameters', { parameters: req.params })
+ const follow = res.locals.follow
+ if (follow.state !== 'pending' && follow.state !== 'rejected') {
+ return res.fail({ message: 'Follow is not in pending/rejected state.' })
+ }
- if (follow.state !== 'pending') {
- return res.fail({ message: 'Follow is not in pending state.' })
+ if (follow.state !== 'pending' && follow.state !== 'accepted') {
+ return res.fail({ message: 'Follow is not in pending/accepted state.' })