- // Don't use findOrCreate by sequelize that breaks our actor follow hooks
- let created = false
- let actorFollow: MActorFollowActors = await ActorFollowModel.loadByActorAndTarget(byActor.id, targetActor.id, t)
-
- if (!actorFollow) {
- created = true
-
- actorFollow = await ActorFollowModel.create({
- actorId: byActor.id,
- targetActorId: targetActor.id,
- url: activityId,
-
- state: CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL
- ? 'pending'
- : 'accepted'
- }, { transaction: t })
- }
+ const [ actorFollow, created ] = await ActorFollowModel.findOrCreateCustom({
+ byActor,
+ targetActor,
+ activityId,
+ state: CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL
+ ? 'pending'
+ : 'accepted',
+ transaction: t
+ })