diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-20 09:43:39 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:52 +0100 |
commit | 54141398354e6e7b94aa3065a705a1251390111c (patch) | |
tree | 8d30d1b9ea8acbe04f6d404125b04fc0c9897b70 /server/lib/activitypub/send/send-accept.ts | |
parent | eb8b27c93e61a896a08923dc1ca3c87ba8cf4948 (diff) | |
download | PeerTube-54141398354e6e7b94aa3065a705a1251390111c.tar.gz PeerTube-54141398354e6e7b94aa3065a705a1251390111c.tar.zst PeerTube-54141398354e6e7b94aa3065a705a1251390111c.zip |
Refractor activity pub lib/helpers
Diffstat (limited to 'server/lib/activitypub/send/send-accept.ts')
-rw-r--r-- | server/lib/activitypub/send/send-accept.ts | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/server/lib/activitypub/send/send-accept.ts b/server/lib/activitypub/send/send-accept.ts new file mode 100644 index 000000000..0324a30fa --- /dev/null +++ b/server/lib/activitypub/send/send-accept.ts | |||
@@ -0,0 +1,34 @@ | |||
1 | import { Transaction } from 'sequelize' | ||
2 | import { ActivityAccept } 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 { getAccountFollowAcceptActivityPubUrl } from '../../../helpers/activitypub' | ||
7 | |||
8 | async function sendAccept (accountFollow: AccountFollowInstance, t: Transaction) { | ||
9 | const follower = accountFollow.AccountFollower | ||
10 | const me = accountFollow.AccountFollowing | ||
11 | |||
12 | const url = getAccountFollowAcceptActivityPubUrl(accountFollow) | ||
13 | const data = await acceptActivityData(url, me) | ||
14 | |||
15 | return unicastTo(data, me, follower.inboxUrl, t) | ||
16 | } | ||
17 | |||
18 | // --------------------------------------------------------------------------- | ||
19 | |||
20 | export { | ||
21 | sendAccept | ||
22 | } | ||
23 | |||
24 | // --------------------------------------------------------------------------- | ||
25 | |||
26 | async function acceptActivityData (url: string, byAccount: AccountInstance) { | ||
27 | const activity: ActivityAccept = { | ||
28 | type: 'Accept', | ||
29 | id: url, | ||
30 | actor: byAccount.url | ||
31 | } | ||
32 | |||
33 | return activity | ||
34 | } | ||