- broadcastToFollowers,
- getAccountsInvolvedInVideo,
- getAudience,
- getObjectFollowersAudience,
- getOriginVideoAudience,
- unicastTo
-} from './misc'
-import { createActivityData, createDislikeActivityData } from './send-create'
-import { followActivityData } from './send-follow'
-import { likeActivityData } from './send-like'
-
-async function sendUndoFollow (accountFollow: AccountFollowModel, t: Transaction) {
- const me = accountFollow.AccountFollower
- const following = accountFollow.AccountFollowing
-
- const followUrl = getAccountFollowActivityPubUrl(accountFollow)
- const undoUrl = getUndoActivityPubUrl(followUrl)
-
- const object = followActivityData(followUrl, me, following)
- const data = await undoActivityData(undoUrl, me, object, t)
-
- return unicastTo(data, me, following.inboxUrl, t)
+ MActor,
+ MActorAudience,
+ MActorFollowActors,
+ MActorLight,
+ MVideo,
+ MVideoAccountLight,
+ MVideoRedundancyVideo,
+ MVideoShare
+} from '../../../types/models'
+import { audiencify, getAudience } from '../audience'
+import { getUndoActivityPubUrl, getVideoDislikeActivityPubUrlByLocalActor, getVideoLikeActivityPubUrlByLocalActor } from '../url'
+import { buildAnnounceWithVideoAudience } from './send-announce'
+import { buildCreateActivity } from './send-create'
+import { buildDislikeActivity } from './send-dislike'
+import { buildFollowActivity } from './send-follow'
+import { buildLikeActivity } from './send-like'
+import { broadcastToFollowers, sendVideoRelatedActivity, unicastTo } from './utils'
+
+function sendUndoFollow (actorFollow: MActorFollowActors, t: Transaction) {
+ const me = actorFollow.ActorFollower
+ const following = actorFollow.ActorFollowing
+
+ // Same server as ours
+ if (!following.serverId) return
+
+ logger.info('Creating job to send an unfollow request to %s.', following.url)
+
+ const undoUrl = getUndoActivityPubUrl(actorFollow.url)
+
+ const followActivity = buildFollowActivity(actorFollow.url, me, following)
+ const undoActivity = undoActivityData(undoUrl, me, followActivity)
+
+ t.afterCommit(() => unicastTo(undoActivity, me, following.inboxUrl))