1 import { Transaction } from 'sequelize'
2 import { ActivityFollow, ActivityUndo } from '../../../../shared/models/activitypub/activity'
3 import { AccountInstance } from '../../../models'
4 import { AccountFollowInstance } from '../../../models/account/account-follow-interface'
5 import { unicastTo } from './misc'
6 import { getAccountFollowActivityPubUrl, getUndoActivityPubUrl } from '../../../helpers/activitypub'
7 import { followActivityData } from './send-follow'
9 async function sendUndoFollow (accountFollow: AccountFollowInstance, t: Transaction) {
10 const me = accountFollow.AccountFollower
11 const following = accountFollow.AccountFollowing
13 const followUrl = getAccountFollowActivityPubUrl(accountFollow)
14 const undoUrl = getUndoActivityPubUrl(followUrl)
16 const object = await followActivityData(followUrl, me, following)
17 const data = await undoActivityData(undoUrl, me, object)
19 return unicastTo(data, me, following.inboxUrl, t)
22 // ---------------------------------------------------------------------------
28 // ---------------------------------------------------------------------------
30 async function undoActivityData (url: string, byAccount: AccountInstance, object: ActivityFollow) {
31 const activity: ActivityUndo = {