aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/send/send-undo.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub/send/send-undo.ts')
-rw-r--r--server/lib/activitypub/send/send-undo.ts39
1 files changed, 39 insertions, 0 deletions
diff --git a/server/lib/activitypub/send/send-undo.ts b/server/lib/activitypub/send/send-undo.ts
new file mode 100644
index 000000000..39da824f3
--- /dev/null
+++ b/server/lib/activitypub/send/send-undo.ts
@@ -0,0 +1,39 @@
1import { Transaction } from 'sequelize'
2import { ActivityFollow, ActivityUndo } from '../../../../shared/models/activitypub/activity'
3import { AccountInstance } from '../../../models'
4import { AccountFollowInstance } from '../../../models/account/account-follow-interface'
5import { unicastTo } from './misc'
6import { getAccountFollowActivityPubUrl, getUndoActivityPubUrl } from '../../../helpers/activitypub'
7import { followActivityData } from './send-follow'
8
9async 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
24export {
25 sendUndoFollow
26}
27
28// ---------------------------------------------------------------------------
29
30async 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}