]>
Commit | Line | Data |
---|---|---|
54141398 C |
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' | |
54141398 | 6 | import { followActivityData } from './send-follow' |
892211e8 | 7 | import { getAccountFollowActivityPubUrl, getUndoActivityPubUrl } from '../url' |
54141398 C |
8 | |
9 | async function sendUndoFollow (accountFollow: AccountFollowInstance, t: Transaction) { | |
10 | const me = accountFollow.AccountFollower | |
11 | const following = accountFollow.AccountFollowing | |
12 | ||
13 | const followUrl = getAccountFollowActivityPubUrl(accountFollow) | |
14 | const undoUrl = getUndoActivityPubUrl(followUrl) | |
15 | ||
16 | const object = await followActivityData(followUrl, me, following) | |
17 | const data = await undoActivityData(undoUrl, me, object) | |
18 | ||
19 | return unicastTo(data, me, following.inboxUrl, t) | |
20 | } | |
21 | ||
22 | // --------------------------------------------------------------------------- | |
23 | ||
24 | export { | |
25 | sendUndoFollow | |
26 | } | |
27 | ||
28 | // --------------------------------------------------------------------------- | |
29 | ||
30 | async function undoActivityData (url: string, byAccount: AccountInstance, object: ActivityFollow) { | |
31 | const activity: ActivityUndo = { | |
32 | type: 'Undo', | |
33 | id: url, | |
34 | actor: byAccount.url, | |
35 | object | |
36 | } | |
37 | ||
38 | return activity | |
39 | } |