-function follow (fromActor: ActorModel, targetActor: ActorModel) {
- if (fromActor.id === targetActor.id) {
- throw new Error('Follower is the same than target actor.')
- }
-
- return sequelizeTypescript.transaction(async t => {
- const [ actorFollow ] = await ActorFollowModel.findOrCreate({
- where: {
- actorId: fromActor.id,
- targetActorId: targetActor.id
- },
- defaults: {
- state: 'pending',
- actorId: fromActor.id,
- targetActorId: targetActor.id
- },
- transaction: t
- })
- actorFollow.ActorFollowing = targetActor
- actorFollow.ActorFollower = fromActor
-
- // Send a notification to remote server
- await sendFollow(actorFollow)
- })
-}
-
-async function removeFollow (req: express.Request, res: express.Response, next: express.NextFunction) {
- const follow: ActorFollowModel = res.locals.follow
+async function removeFollowing (req: express.Request, res: express.Response) {
+ const follow = res.locals.follow