aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/send
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub/send')
-rw-r--r--server/lib/activitypub/send/misc.ts56
-rw-r--r--server/lib/activitypub/send/send-accept.ts12
-rw-r--r--server/lib/activitypub/send/send-add.ts20
-rw-r--r--server/lib/activitypub/send/send-announce.ts35
-rw-r--r--server/lib/activitypub/send/send-create.ts46
-rw-r--r--server/lib/activitypub/send/send-delete.ts25
-rw-r--r--server/lib/activitypub/send/send-follow.ts14
-rw-r--r--server/lib/activitypub/send/send-like.ts19
-rw-r--r--server/lib/activitypub/send/send-undo.ts26
-rw-r--r--server/lib/activitypub/send/send-update.ts23
10 files changed, 134 insertions, 142 deletions
diff --git a/server/lib/activitypub/send/misc.ts b/server/lib/activitypub/send/misc.ts
index 999def701..ffc221477 100644
--- a/server/lib/activitypub/send/misc.ts
+++ b/server/lib/activitypub/send/misc.ts
@@ -1,19 +1,19 @@
1import { Transaction } from 'sequelize' 1import { Transaction } from 'sequelize'
2import { Activity } from '../../../../shared/models/activitypub/activity' 2import { Activity } from '../../../../shared/models/activitypub'
3import { logger } from '../../../helpers/logger' 3import { logger } from '../../../helpers'
4import { ACTIVITY_PUB, database as db } from '../../../initializers' 4import { ACTIVITY_PUB } from '../../../initializers'
5import { AccountInstance } from '../../../models/account/account-interface' 5import { AccountModel } from '../../../models/account/account'
6import { VideoChannelInstance } from '../../../models/index' 6import { AccountFollowModel } from '../../../models/account/account-follow'
7import { VideoInstance } from '../../../models/video/video-interface' 7import { VideoModel } from '../../../models/video/video'
8import { 8import { VideoChannelModel } from '../../../models/video/video-channel'
9 activitypubHttpJobScheduler, 9import { VideoChannelShareModel } from '../../../models/video/video-channel-share'
10 ActivityPubHttpPayload 10import { VideoShareModel } from '../../../models/video/video-share'
11} from '../../jobs/activitypub-http-job-scheduler/activitypub-http-job-scheduler' 11import { activitypubHttpJobScheduler, ActivityPubHttpPayload } from '../../jobs/activitypub-http-job-scheduler'
12 12
13async function forwardActivity ( 13async function forwardActivity (
14 activity: Activity, 14 activity: Activity,
15 t: Transaction, 15 t: Transaction,
16 followersException: AccountInstance[] = [] 16 followersException: AccountModel[] = []
17) { 17) {
18 const to = activity.to || [] 18 const to = activity.to || []
19 const cc = activity.cc || [] 19 const cc = activity.cc || []
@@ -25,7 +25,7 @@ async function forwardActivity (
25 } 25 }
26 } 26 }
27 27
28 const toAccountFollowers = await db.Account.listByFollowersUrls(followersUrls, t) 28 const toAccountFollowers = await AccountModel.listByFollowersUrls(followersUrls, t)
29 const uris = await computeFollowerUris(toAccountFollowers, followersException, t) 29 const uris = await computeFollowerUris(toAccountFollowers, followersException, t)
30 30
31 if (uris.length === 0) { 31 if (uris.length === 0) {
@@ -45,10 +45,10 @@ async function forwardActivity (
45 45
46async function broadcastToFollowers ( 46async function broadcastToFollowers (
47 data: any, 47 data: any,
48 byAccount: AccountInstance, 48 byAccount: AccountModel,
49 toAccountFollowers: AccountInstance[], 49 toAccountFollowers: AccountModel[],
50 t: Transaction, 50 t: Transaction,
51 followersException: AccountInstance[] = [] 51 followersException: AccountModel[] = []
52) { 52) {
53 const uris = await computeFollowerUris(toAccountFollowers, followersException, t) 53 const uris = await computeFollowerUris(toAccountFollowers, followersException, t)
54 if (uris.length === 0) { 54 if (uris.length === 0) {
@@ -67,7 +67,7 @@ async function broadcastToFollowers (
67 return activitypubHttpJobScheduler.createJob(t, 'activitypubHttpBroadcastHandler', jobPayload) 67 return activitypubHttpJobScheduler.createJob(t, 'activitypubHttpBroadcastHandler', jobPayload)
68} 68}
69 69
70async function unicastTo (data: any, byAccount: AccountInstance, toAccountUrl: string, t: Transaction) { 70async function unicastTo (data: any, byAccount: AccountModel, toAccountUrl: string, t: Transaction) {
71 logger.debug('Creating unicast job.', { uri: toAccountUrl }) 71 logger.debug('Creating unicast job.', { uri: toAccountUrl })
72 72
73 const jobPayload: ActivityPubHttpPayload = { 73 const jobPayload: ActivityPubHttpPayload = {
@@ -79,42 +79,42 @@ async function unicastTo (data: any, byAccount: AccountInstance, toAccountUrl: s
79 return activitypubHttpJobScheduler.createJob(t, 'activitypubHttpUnicastHandler', jobPayload) 79 return activitypubHttpJobScheduler.createJob(t, 'activitypubHttpUnicastHandler', jobPayload)
80} 80}
81 81
82function getOriginVideoAudience (video: VideoInstance, accountsInvolvedInVideo: AccountInstance[]) { 82function getOriginVideoAudience (video: VideoModel, accountsInvolvedInVideo: AccountModel[]) {
83 return { 83 return {
84 to: [ video.VideoChannel.Account.url ], 84 to: [ video.VideoChannel.Account.url ],
85 cc: accountsInvolvedInVideo.map(a => a.followersUrl) 85 cc: accountsInvolvedInVideo.map(a => a.followersUrl)
86 } 86 }
87} 87}
88 88
89function getOriginVideoChannelAudience (videoChannel: VideoChannelInstance, accountsInvolved: AccountInstance[]) { 89function getOriginVideoChannelAudience (videoChannel: VideoChannelModel, accountsInvolved: AccountModel[]) {
90 return { 90 return {
91 to: [ videoChannel.Account.url ], 91 to: [ videoChannel.Account.url ],
92 cc: accountsInvolved.map(a => a.followersUrl) 92 cc: accountsInvolved.map(a => a.followersUrl)
93 } 93 }
94} 94}
95 95
96function getObjectFollowersAudience (accountsInvolvedInObject: AccountInstance[]) { 96function getObjectFollowersAudience (accountsInvolvedInObject: AccountModel[]) {
97 return { 97 return {
98 to: accountsInvolvedInObject.map(a => a.followersUrl), 98 to: accountsInvolvedInObject.map(a => a.followersUrl),
99 cc: [] 99 cc: []
100 } 100 }
101} 101}
102 102
103async function getAccountsInvolvedInVideo (video: VideoInstance, t: Transaction) { 103async function getAccountsInvolvedInVideo (video: VideoModel, t: Transaction) {
104 const accountsToForwardView = await db.VideoShare.loadAccountsByShare(video.id, t) 104 const accountsToForwardView = await VideoShareModel.loadAccountsByShare(video.id, t)
105 accountsToForwardView.push(video.VideoChannel.Account) 105 accountsToForwardView.push(video.VideoChannel.Account)
106 106
107 return accountsToForwardView 107 return accountsToForwardView
108} 108}
109 109
110async function getAccountsInvolvedInVideoChannel (videoChannel: VideoChannelInstance, t: Transaction) { 110async function getAccountsInvolvedInVideoChannel (videoChannel: VideoChannelModel, t: Transaction) {
111 const accountsToForwardView = await db.VideoChannelShare.loadAccountsByShare(videoChannel.id, t) 111 const accountsToForwardView = await VideoChannelShareModel.loadAccountsByShare(videoChannel.id, t)
112 accountsToForwardView.push(videoChannel.Account) 112 accountsToForwardView.push(videoChannel.Account)
113 113
114 return accountsToForwardView 114 return accountsToForwardView
115} 115}
116 116
117async function getAudience (accountSender: AccountInstance, t: Transaction, isPublic = true) { 117async function getAudience (accountSender: AccountModel, t: Transaction, isPublic = true) {
118 const followerInboxUrls = await accountSender.getFollowerSharedInboxUrls(t) 118 const followerInboxUrls = await accountSender.getFollowerSharedInboxUrls(t)
119 119
120 // Thanks Mastodon: https://github.com/tootsuite/mastodon/blob/master/app/lib/activitypub/tag_manager.rb#L47 120 // Thanks Mastodon: https://github.com/tootsuite/mastodon/blob/master/app/lib/activitypub/tag_manager.rb#L47
@@ -132,14 +132,12 @@ async function getAudience (accountSender: AccountInstance, t: Transaction, isPu
132 return { to, cc } 132 return { to, cc }
133} 133}
134 134
135async function computeFollowerUris (toAccountFollower: AccountInstance[], followersException: AccountInstance[], t: Transaction) { 135async function computeFollowerUris (toAccountFollower: AccountModel[], followersException: AccountModel[], t: Transaction) {
136 const toAccountFollowerIds = toAccountFollower.map(a => a.id) 136 const toAccountFollowerIds = toAccountFollower.map(a => a.id)
137 137
138 const result = await db.AccountFollow.listAcceptedFollowerSharedInboxUrls(toAccountFollowerIds, t) 138 const result = await AccountFollowModel.listAcceptedFollowerSharedInboxUrls(toAccountFollowerIds, t)
139 const followersSharedInboxException = followersException.map(f => f.sharedInboxUrl) 139 const followersSharedInboxException = followersException.map(f => f.sharedInboxUrl)
140 const uris = result.data.filter(sharedInbox => followersSharedInboxException.indexOf(sharedInbox) === -1) 140 return result.data.filter(sharedInbox => followersSharedInboxException.indexOf(sharedInbox) === -1)
141
142 return uris
143} 141}
144 142
145// --------------------------------------------------------------------------- 143// ---------------------------------------------------------------------------
diff --git a/server/lib/activitypub/send/send-accept.ts b/server/lib/activitypub/send/send-accept.ts
index d3f8fbe38..f160af3c9 100644
--- a/server/lib/activitypub/send/send-accept.ts
+++ b/server/lib/activitypub/send/send-accept.ts
@@ -1,11 +1,11 @@
1import { Transaction } from 'sequelize' 1import { Transaction } from 'sequelize'
2import { ActivityAccept } from '../../../../shared/models/activitypub/activity' 2import { ActivityAccept } from '../../../../shared/models/activitypub'
3import { AccountInstance } from '../../../models' 3import { AccountModel } from '../../../models/account/account'
4import { AccountFollowInstance } from '../../../models/account/account-follow-interface' 4import { AccountFollowModel } from '../../../models/account/account-follow'
5import { unicastTo } from './misc'
6import { getAccountFollowAcceptActivityPubUrl } from '../url' 5import { getAccountFollowAcceptActivityPubUrl } from '../url'
6import { unicastTo } from './misc'
7 7
8async function sendAccept (accountFollow: AccountFollowInstance, t: Transaction) { 8async function sendAccept (accountFollow: AccountFollowModel, t: Transaction) {
9 const follower = accountFollow.AccountFollower 9 const follower = accountFollow.AccountFollower
10 const me = accountFollow.AccountFollowing 10 const me = accountFollow.AccountFollowing
11 11
@@ -23,7 +23,7 @@ export {
23 23
24// --------------------------------------------------------------------------- 24// ---------------------------------------------------------------------------
25 25
26function acceptActivityData (url: string, byAccount: AccountInstance) { 26function acceptActivityData (url: string, byAccount: AccountModel) {
27 const activity: ActivityAccept = { 27 const activity: ActivityAccept = {
28 type: 'Accept', 28 type: 'Accept',
29 id: url, 29 id: url,
diff --git a/server/lib/activitypub/send/send-add.ts b/server/lib/activitypub/send/send-add.ts
index d8ac2853e..fd614db75 100644
--- a/server/lib/activitypub/send/send-add.ts
+++ b/server/lib/activitypub/send/send-add.ts
@@ -1,10 +1,11 @@
1import { Transaction } from 'sequelize' 1import { Transaction } from 'sequelize'
2import { ActivityAdd } from '../../../../shared/models/activitypub/activity' 2import { ActivityAdd } from '../../../../shared/models/activitypub'
3import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' 3import { VideoPrivacy } from '../../../../shared/models/videos'
4import { AccountInstance, VideoInstance } from '../../../models' 4import { AccountModel } from '../../../models/account/account'
5import { VideoModel } from '../../../models/video/video'
5import { broadcastToFollowers, getAudience } from './misc' 6import { broadcastToFollowers, getAudience } from './misc'
6 7
7async function sendAddVideo (video: VideoInstance, t: Transaction) { 8async function sendAddVideo (video: VideoModel, t: Transaction) {
8 const byAccount = video.VideoChannel.Account 9 const byAccount = video.VideoChannel.Account
9 10
10 const videoObject = video.toActivityPubObject() 11 const videoObject = video.toActivityPubObject()
@@ -15,16 +16,17 @@ async function sendAddVideo (video: VideoInstance, t: Transaction) {
15 16
16async function addActivityData ( 17async function addActivityData (
17 url: string, 18 url: string,
18 byAccount: AccountInstance, 19 byAccount: AccountModel,
19 video: VideoInstance, 20 video: VideoModel,
20 target: string, 21 target: string,
21 object: any, 22 object: any,
22 t: Transaction 23 t: Transaction
23) { 24): Promise<ActivityAdd> {
24 const videoPublic = video.privacy === VideoPrivacy.PUBLIC 25 const videoPublic = video.privacy === VideoPrivacy.PUBLIC
25 26
26 const { to, cc } = await getAudience(byAccount, t, videoPublic) 27 const { to, cc } = await getAudience(byAccount, t, videoPublic)
27 const activity: ActivityAdd = { 28
29 return {
28 type: 'Add', 30 type: 'Add',
29 id: url, 31 id: url,
30 actor: byAccount.url, 32 actor: byAccount.url,
@@ -33,8 +35,6 @@ async function addActivityData (
33 object, 35 object,
34 target 36 target
35 } 37 }
36
37 return activity
38} 38}
39 39
40// --------------------------------------------------------------------------- 40// ---------------------------------------------------------------------------
diff --git a/server/lib/activitypub/send/send-announce.ts b/server/lib/activitypub/send/send-announce.ts
index 3acf604cd..e685323e8 100644
--- a/server/lib/activitypub/send/send-announce.ts
+++ b/server/lib/activitypub/send/send-announce.ts
@@ -1,8 +1,9 @@
1import { Transaction } from 'sequelize' 1import { Transaction } from 'sequelize'
2import { ActivityAdd } from '../../../../shared/index' 2import { ActivityAdd } from '../../../../shared/index'
3import { ActivityAnnounce, ActivityAudience, ActivityCreate } from '../../../../shared/models/activitypub/activity' 3import { ActivityAnnounce, ActivityAudience, ActivityCreate } from '../../../../shared/models/activitypub'
4import { AccountInstance, VideoInstance } from '../../../models' 4import { AccountModel } from '../../../models/account/account'
5import { VideoChannelInstance } from '../../../models/video/video-channel-interface' 5import { VideoModel } from '../../../models/video/video'
6import { VideoChannelModel } from '../../../models/video/video-channel'
6import { getAnnounceActivityPubUrl } from '../url' 7import { getAnnounceActivityPubUrl } from '../url'
7import { 8import {
8 broadcastToFollowers, 9 broadcastToFollowers,
@@ -17,7 +18,7 @@ import {
17import { addActivityData } from './send-add' 18import { addActivityData } from './send-add'
18import { createActivityData } from './send-create' 19import { createActivityData } from './send-create'
19 20
20async function buildVideoAnnounceToFollowers (byAccount: AccountInstance, video: VideoInstance, t: Transaction) { 21async function buildVideoAnnounceToFollowers (byAccount: AccountModel, video: VideoModel, t: Transaction) {
21 const url = getAnnounceActivityPubUrl(video.url, byAccount) 22 const url = getAnnounceActivityPubUrl(video.url, byAccount)
22 23
23 const videoChannel = video.VideoChannel 24 const videoChannel = video.VideoChannel
@@ -25,18 +26,16 @@ async function buildVideoAnnounceToFollowers (byAccount: AccountInstance, video:
25 26
26 const accountsToForwardView = await getAccountsInvolvedInVideo(video, t) 27 const accountsToForwardView = await getAccountsInvolvedInVideo(video, t)
27 const audience = getObjectFollowersAudience(accountsToForwardView) 28 const audience = getObjectFollowersAudience(accountsToForwardView)
28 const data = await announceActivityData(url, byAccount, announcedActivity, t, audience) 29 return announceActivityData(url, byAccount, announcedActivity, t, audience)
29
30 return data
31} 30}
32 31
33async function sendVideoAnnounceToFollowers (byAccount: AccountInstance, video: VideoInstance, t: Transaction) { 32async function sendVideoAnnounceToFollowers (byAccount: AccountModel, video: VideoModel, t: Transaction) {
34 const data = await buildVideoAnnounceToFollowers(byAccount, video, t) 33 const data = await buildVideoAnnounceToFollowers(byAccount, video, t)
35 34
36 return broadcastToFollowers(data, byAccount, [ byAccount ], t) 35 return broadcastToFollowers(data, byAccount, [ byAccount ], t)
37} 36}
38 37
39async function sendVideoAnnounceToOrigin (byAccount: AccountInstance, video: VideoInstance, t: Transaction) { 38async function sendVideoAnnounceToOrigin (byAccount: AccountModel, video: VideoModel, t: Transaction) {
40 const url = getAnnounceActivityPubUrl(video.url, byAccount) 39 const url = getAnnounceActivityPubUrl(video.url, byAccount)
41 40
42 const videoChannel = video.VideoChannel 41 const videoChannel = video.VideoChannel
@@ -49,24 +48,22 @@ async function sendVideoAnnounceToOrigin (byAccount: AccountInstance, video: Vid
49 return unicastTo(data, byAccount, videoChannel.Account.sharedInboxUrl, t) 48 return unicastTo(data, byAccount, videoChannel.Account.sharedInboxUrl, t)
50} 49}
51 50
52async function buildVideoChannelAnnounceToFollowers (byAccount: AccountInstance, videoChannel: VideoChannelInstance, t: Transaction) { 51async function buildVideoChannelAnnounceToFollowers (byAccount: AccountModel, videoChannel: VideoChannelModel, t: Transaction) {
53 const url = getAnnounceActivityPubUrl(videoChannel.url, byAccount) 52 const url = getAnnounceActivityPubUrl(videoChannel.url, byAccount)
54 const announcedActivity = await createActivityData(url, videoChannel.Account, videoChannel.toActivityPubObject(), t) 53 const announcedActivity = await createActivityData(url, videoChannel.Account, videoChannel.toActivityPubObject(), t)
55 54
56 const accountsToForwardView = await getAccountsInvolvedInVideoChannel(videoChannel, t) 55 const accountsToForwardView = await getAccountsInvolvedInVideoChannel(videoChannel, t)
57 const audience = getObjectFollowersAudience(accountsToForwardView) 56 const audience = getObjectFollowersAudience(accountsToForwardView)
58 const data = await announceActivityData(url, byAccount, announcedActivity, t, audience) 57 return announceActivityData(url, byAccount, announcedActivity, t, audience)
59
60 return data
61} 58}
62 59
63async function sendVideoChannelAnnounceToFollowers (byAccount: AccountInstance, videoChannel: VideoChannelInstance, t: Transaction) { 60async function sendVideoChannelAnnounceToFollowers (byAccount: AccountModel, videoChannel: VideoChannelModel, t: Transaction) {
64 const data = await buildVideoChannelAnnounceToFollowers(byAccount, videoChannel, t) 61 const data = await buildVideoChannelAnnounceToFollowers(byAccount, videoChannel, t)
65 62
66 return broadcastToFollowers(data, byAccount, [ byAccount ], t) 63 return broadcastToFollowers(data, byAccount, [ byAccount ], t)
67} 64}
68 65
69async function sendVideoChannelAnnounceToOrigin (byAccount: AccountInstance, videoChannel: VideoChannelInstance, t: Transaction) { 66async function sendVideoChannelAnnounceToOrigin (byAccount: AccountModel, videoChannel: VideoChannelModel, t: Transaction) {
70 const url = getAnnounceActivityPubUrl(videoChannel.url, byAccount) 67 const url = getAnnounceActivityPubUrl(videoChannel.url, byAccount)
71 const announcedActivity = await createActivityData(url, videoChannel.Account, videoChannel.toActivityPubObject(), t) 68 const announcedActivity = await createActivityData(url, videoChannel.Account, videoChannel.toActivityPubObject(), t)
72 69
@@ -79,16 +76,16 @@ async function sendVideoChannelAnnounceToOrigin (byAccount: AccountInstance, vid
79 76
80async function announceActivityData ( 77async function announceActivityData (
81 url: string, 78 url: string,
82 byAccount: AccountInstance, 79 byAccount: AccountModel,
83 object: ActivityCreate | ActivityAdd, 80 object: ActivityCreate | ActivityAdd,
84 t: Transaction, 81 t: Transaction,
85 audience?: ActivityAudience 82 audience?: ActivityAudience
86) { 83): Promise<ActivityAnnounce> {
87 if (!audience) { 84 if (!audience) {
88 audience = await getAudience(byAccount, t) 85 audience = await getAudience(byAccount, t)
89 } 86 }
90 87
91 const activity: ActivityAnnounce = { 88 return {
92 type: 'Announce', 89 type: 'Announce',
93 to: audience.to, 90 to: audience.to,
94 cc: audience.cc, 91 cc: audience.cc,
@@ -96,8 +93,6 @@ async function announceActivityData (
96 actor: byAccount.url, 93 actor: byAccount.url,
97 object 94 object
98 } 95 }
99
100 return activity
101} 96}
102 97
103// --------------------------------------------------------------------------- 98// ---------------------------------------------------------------------------
diff --git a/server/lib/activitypub/send/send-create.ts b/server/lib/activitypub/send/send-create.ts
index a34d3776c..9fbaa8196 100644
--- a/server/lib/activitypub/send/send-create.ts
+++ b/server/lib/activitypub/send/send-create.ts
@@ -1,8 +1,10 @@
1import { Transaction } from 'sequelize' 1import { Transaction } from 'sequelize'
2import { ActivityAudience, ActivityCreate } from '../../../../shared/models/activitypub/activity' 2import { ActivityAudience, ActivityCreate } from '../../../../shared/models/activitypub'
3import { getServerAccount } from '../../../helpers/utils' 3import { getServerAccount } from '../../../helpers'
4import { AccountInstance, VideoChannelInstance, VideoInstance } from '../../../models' 4import { AccountModel } from '../../../models/account/account'
5import { VideoAbuseInstance } from '../../../models/video/video-abuse-interface' 5import { VideoModel } from '../../../models/video/video'
6import { VideoAbuseModel } from '../../../models/video/video-abuse'
7import { VideoChannelModel } from '../../../models/video/video-channel'
6import { getVideoAbuseActivityPubUrl, getVideoDislikeActivityPubUrl, getVideoViewActivityPubUrl } from '../url' 8import { getVideoAbuseActivityPubUrl, getVideoDislikeActivityPubUrl, getVideoViewActivityPubUrl } from '../url'
7import { 9import {
8 broadcastToFollowers, 10 broadcastToFollowers,
@@ -13,7 +15,7 @@ import {
13 unicastTo 15 unicastTo
14} from './misc' 16} from './misc'
15 17
16async function sendCreateVideoChannel (videoChannel: VideoChannelInstance, t: Transaction) { 18async function sendCreateVideoChannel (videoChannel: VideoChannelModel, t: Transaction) {
17 const byAccount = videoChannel.Account 19 const byAccount = videoChannel.Account
18 20
19 const videoChannelObject = videoChannel.toActivityPubObject() 21 const videoChannelObject = videoChannel.toActivityPubObject()
@@ -22,7 +24,7 @@ async function sendCreateVideoChannel (videoChannel: VideoChannelInstance, t: Tr
22 return broadcastToFollowers(data, byAccount, [ byAccount ], t) 24 return broadcastToFollowers(data, byAccount, [ byAccount ], t)
23} 25}
24 26
25async function sendVideoAbuse (byAccount: AccountInstance, videoAbuse: VideoAbuseInstance, video: VideoInstance, t: Transaction) { 27async function sendVideoAbuse (byAccount: AccountModel, videoAbuse: VideoAbuseModel, video: VideoModel, t: Transaction) {
26 const url = getVideoAbuseActivityPubUrl(videoAbuse) 28 const url = getVideoAbuseActivityPubUrl(videoAbuse)
27 29
28 const audience = { to: [ video.VideoChannel.Account.url ], cc: [] } 30 const audience = { to: [ video.VideoChannel.Account.url ], cc: [] }
@@ -31,7 +33,7 @@ async function sendVideoAbuse (byAccount: AccountInstance, videoAbuse: VideoAbus
31 return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t) 33 return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t)
32} 34}
33 35
34async function sendCreateViewToOrigin (byAccount: AccountInstance, video: VideoInstance, t: Transaction) { 36async function sendCreateViewToOrigin (byAccount: AccountModel, video: VideoModel, t: Transaction) {
35 const url = getVideoViewActivityPubUrl(byAccount, video) 37 const url = getVideoViewActivityPubUrl(byAccount, video)
36 const viewActivity = createViewActivityData(byAccount, video) 38 const viewActivity = createViewActivityData(byAccount, video)
37 39
@@ -42,7 +44,7 @@ async function sendCreateViewToOrigin (byAccount: AccountInstance, video: VideoI
42 return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t) 44 return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t)
43} 45}
44 46
45async function sendCreateViewToVideoFollowers (byAccount: AccountInstance, video: VideoInstance, t: Transaction) { 47async function sendCreateViewToVideoFollowers (byAccount: AccountModel, video: VideoModel, t: Transaction) {
46 const url = getVideoViewActivityPubUrl(byAccount, video) 48 const url = getVideoViewActivityPubUrl(byAccount, video)
47 const viewActivity = createViewActivityData(byAccount, video) 49 const viewActivity = createViewActivityData(byAccount, video)
48 50
@@ -56,7 +58,7 @@ async function sendCreateViewToVideoFollowers (byAccount: AccountInstance, video
56 return broadcastToFollowers(data, serverAccount, accountsToForwardView, t, followersException) 58 return broadcastToFollowers(data, serverAccount, accountsToForwardView, t, followersException)
57} 59}
58 60
59async function sendCreateDislikeToOrigin (byAccount: AccountInstance, video: VideoInstance, t: Transaction) { 61async function sendCreateDislikeToOrigin (byAccount: AccountModel, video: VideoModel, t: Transaction) {
60 const url = getVideoDislikeActivityPubUrl(byAccount, video) 62 const url = getVideoDislikeActivityPubUrl(byAccount, video)
61 const dislikeActivity = createDislikeActivityData(byAccount, video) 63 const dislikeActivity = createDislikeActivityData(byAccount, video)
62 64
@@ -67,7 +69,7 @@ async function sendCreateDislikeToOrigin (byAccount: AccountInstance, video: Vid
67 return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t) 69 return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t)
68} 70}
69 71
70async function sendCreateDislikeToVideoFollowers (byAccount: AccountInstance, video: VideoInstance, t: Transaction) { 72async function sendCreateDislikeToVideoFollowers (byAccount: AccountModel, video: VideoModel, t: Transaction) {
71 const url = getVideoDislikeActivityPubUrl(byAccount, video) 73 const url = getVideoDislikeActivityPubUrl(byAccount, video)
72 const dislikeActivity = createDislikeActivityData(byAccount, video) 74 const dislikeActivity = createDislikeActivityData(byAccount, video)
73 75
@@ -79,12 +81,18 @@ async function sendCreateDislikeToVideoFollowers (byAccount: AccountInstance, vi
79 return broadcastToFollowers(data, byAccount, accountsToForwardView, t, followersException) 81 return broadcastToFollowers(data, byAccount, accountsToForwardView, t, followersException)
80} 82}
81 83
82async function createActivityData (url: string, byAccount: AccountInstance, object: any, t: Transaction, audience?: ActivityAudience) { 84async function createActivityData (
85 url: string,
86 byAccount: AccountModel,
87 object: any,
88 t: Transaction,
89 audience?: ActivityAudience
90): Promise<ActivityCreate> {
83 if (!audience) { 91 if (!audience) {
84 audience = await getAudience(byAccount, t) 92 audience = await getAudience(byAccount, t)
85 } 93 }
86 94
87 const activity: ActivityCreate = { 95 return {
88 type: 'Create', 96 type: 'Create',
89 id: url, 97 id: url,
90 actor: byAccount.url, 98 actor: byAccount.url,
@@ -92,18 +100,14 @@ async function createActivityData (url: string, byAccount: AccountInstance, obje
92 cc: audience.cc, 100 cc: audience.cc,
93 object 101 object
94 } 102 }
95
96 return activity
97} 103}
98 104
99function createDislikeActivityData (byAccount: AccountInstance, video: VideoInstance) { 105function createDislikeActivityData (byAccount: AccountModel, video: VideoModel) {
100 const obj = { 106 return {
101 type: 'Dislike', 107 type: 'Dislike',
102 actor: byAccount.url, 108 actor: byAccount.url,
103 object: video.url 109 object: video.url
104 } 110 }
105
106 return obj
107} 111}
108 112
109// --------------------------------------------------------------------------- 113// ---------------------------------------------------------------------------
@@ -121,12 +125,10 @@ export {
121 125
122// --------------------------------------------------------------------------- 126// ---------------------------------------------------------------------------
123 127
124function createViewActivityData (byAccount: AccountInstance, video: VideoInstance) { 128function createViewActivityData (byAccount: AccountModel, video: VideoModel) {
125 const obj = { 129 return {
126 type: 'View', 130 type: 'View',
127 actor: byAccount.url, 131 actor: byAccount.url,
128 object: video.url 132 object: video.url
129 } 133 }
130
131 return obj
132} 134}
diff --git a/server/lib/activitypub/send/send-delete.ts b/server/lib/activitypub/send/send-delete.ts
index 8193790b3..0a45ea10f 100644
--- a/server/lib/activitypub/send/send-delete.ts
+++ b/server/lib/activitypub/send/send-delete.ts
@@ -1,32 +1,35 @@
1import { Transaction } from 'sequelize' 1import { Transaction } from 'sequelize'
2import { ActivityDelete } from '../../../../shared/models/activitypub/activity' 2import { ActivityDelete } from '../../../../shared/models/activitypub'
3import { database as db } from '../../../initializers' 3import { AccountModel } from '../../../models/account/account'
4import { AccountInstance, VideoChannelInstance, VideoInstance } from '../../../models' 4import { VideoModel } from '../../../models/video/video'
5import { VideoChannelModel } from '../../../models/video/video-channel'
6import { VideoChannelShareModel } from '../../../models/video/video-channel-share'
7import { VideoShareModel } from '../../../models/video/video-share'
5import { broadcastToFollowers } from './misc' 8import { broadcastToFollowers } from './misc'
6 9
7async function sendDeleteVideoChannel (videoChannel: VideoChannelInstance, t: Transaction) { 10async function sendDeleteVideoChannel (videoChannel: VideoChannelModel, t: Transaction) {
8 const byAccount = videoChannel.Account 11 const byAccount = videoChannel.Account
9 12
10 const data = deleteActivityData(videoChannel.url, byAccount) 13 const data = deleteActivityData(videoChannel.url, byAccount)
11 14
12 const accountsInvolved = await db.VideoChannelShare.loadAccountsByShare(videoChannel.id, t) 15 const accountsInvolved = await VideoChannelShareModel.loadAccountsByShare(videoChannel.id, t)
13 accountsInvolved.push(byAccount) 16 accountsInvolved.push(byAccount)
14 17
15 return broadcastToFollowers(data, byAccount, accountsInvolved, t) 18 return broadcastToFollowers(data, byAccount, accountsInvolved, t)
16} 19}
17 20
18async function sendDeleteVideo (video: VideoInstance, t: Transaction) { 21async function sendDeleteVideo (video: VideoModel, t: Transaction) {
19 const byAccount = video.VideoChannel.Account 22 const byAccount = video.VideoChannel.Account
20 23
21 const data = deleteActivityData(video.url, byAccount) 24 const data = deleteActivityData(video.url, byAccount)
22 25
23 const accountsInvolved = await db.VideoShare.loadAccountsByShare(video.id, t) 26 const accountsInvolved = await VideoShareModel.loadAccountsByShare(video.id, t)
24 accountsInvolved.push(byAccount) 27 accountsInvolved.push(byAccount)
25 28
26 return broadcastToFollowers(data, byAccount, accountsInvolved, t) 29 return broadcastToFollowers(data, byAccount, accountsInvolved, t)
27} 30}
28 31
29async function sendDeleteAccount (account: AccountInstance, t: Transaction) { 32async function sendDeleteAccount (account: AccountModel, t: Transaction) {
30 const data = deleteActivityData(account.url, account) 33 const data = deleteActivityData(account.url, account)
31 34
32 return broadcastToFollowers(data, account, [ account ], t) 35 return broadcastToFollowers(data, account, [ account ], t)
@@ -42,12 +45,10 @@ export {
42 45
43// --------------------------------------------------------------------------- 46// ---------------------------------------------------------------------------
44 47
45function deleteActivityData (url: string, byAccount: AccountInstance) { 48function deleteActivityData (url: string, byAccount: AccountModel): ActivityDelete {
46 const activity: ActivityDelete = { 49 return {
47 type: 'Delete', 50 type: 'Delete',
48 id: url, 51 id: url,
49 actor: byAccount.url 52 actor: byAccount.url
50 } 53 }
51
52 return activity
53} 54}
diff --git a/server/lib/activitypub/send/send-follow.ts b/server/lib/activitypub/send/send-follow.ts
index 8fba1b6b5..51735ddfd 100644
--- a/server/lib/activitypub/send/send-follow.ts
+++ b/server/lib/activitypub/send/send-follow.ts
@@ -1,11 +1,11 @@
1import { Transaction } from 'sequelize' 1import { Transaction } from 'sequelize'
2import { ActivityFollow } from '../../../../shared/models/activitypub/activity' 2import { ActivityFollow } from '../../../../shared/models/activitypub'
3import { AccountInstance } from '../../../models' 3import { AccountModel } from '../../../models/account/account'
4import { AccountFollowInstance } from '../../../models/account/account-follow-interface' 4import { AccountFollowModel } from '../../../models/account/account-follow'
5import { getAccountFollowActivityPubUrl } from '../url' 5import { getAccountFollowActivityPubUrl } from '../url'
6import { unicastTo } from './misc' 6import { unicastTo } from './misc'
7 7
8function sendFollow (accountFollow: AccountFollowInstance, t: Transaction) { 8function sendFollow (accountFollow: AccountFollowModel, t: Transaction) {
9 const me = accountFollow.AccountFollower 9 const me = accountFollow.AccountFollower
10 const following = accountFollow.AccountFollowing 10 const following = accountFollow.AccountFollowing
11 11
@@ -15,15 +15,13 @@ function sendFollow (accountFollow: AccountFollowInstance, t: Transaction) {
15 return unicastTo(data, me, following.inboxUrl, t) 15 return unicastTo(data, me, following.inboxUrl, t)
16} 16}
17 17
18function followActivityData (url: string, byAccount: AccountInstance, targetAccount: AccountInstance) { 18function followActivityData (url: string, byAccount: AccountModel, targetAccount: AccountModel): ActivityFollow {
19 const activity: ActivityFollow = { 19 return {
20 type: 'Follow', 20 type: 'Follow',
21 id: url, 21 id: url,
22 actor: byAccount.url, 22 actor: byAccount.url,
23 object: targetAccount.url 23 object: targetAccount.url
24 } 24 }
25
26 return activity
27} 25}
28 26
29// --------------------------------------------------------------------------- 27// ---------------------------------------------------------------------------
diff --git a/server/lib/activitypub/send/send-like.ts b/server/lib/activitypub/send/send-like.ts
index 0c464b2d3..1a35d0db0 100644
--- a/server/lib/activitypub/send/send-like.ts
+++ b/server/lib/activitypub/send/send-like.ts
@@ -1,6 +1,7 @@
1import { Transaction } from 'sequelize' 1import { Transaction } from 'sequelize'
2import { ActivityAudience, ActivityLike } from '../../../../shared/models/activitypub/activity' 2import { ActivityAudience, ActivityLike } from '../../../../shared/models/activitypub'
3import { AccountInstance, VideoInstance } from '../../../models' 3import { AccountModel } from '../../../models/account/account'
4import { VideoModel } from '../../../models/video/video'
4import { getVideoLikeActivityPubUrl } from '../url' 5import { getVideoLikeActivityPubUrl } from '../url'
5import { 6import {
6 broadcastToFollowers, 7 broadcastToFollowers,
@@ -11,7 +12,7 @@ import {
11 unicastTo 12 unicastTo
12} from './misc' 13} from './misc'
13 14
14async function sendLikeToOrigin (byAccount: AccountInstance, video: VideoInstance, t: Transaction) { 15async function sendLikeToOrigin (byAccount: AccountModel, video: VideoModel, t: Transaction) {
15 const url = getVideoLikeActivityPubUrl(byAccount, video) 16 const url = getVideoLikeActivityPubUrl(byAccount, video)
16 17
17 const accountsInvolvedInVideo = await getAccountsInvolvedInVideo(video, t) 18 const accountsInvolvedInVideo = await getAccountsInvolvedInVideo(video, t)
@@ -21,7 +22,7 @@ async function sendLikeToOrigin (byAccount: AccountInstance, video: VideoInstanc
21 return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t) 22 return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t)
22} 23}
23 24
24async function sendLikeToVideoFollowers (byAccount: AccountInstance, video: VideoInstance, t: Transaction) { 25async function sendLikeToVideoFollowers (byAccount: AccountModel, video: VideoModel, t: Transaction) {
25 const url = getVideoLikeActivityPubUrl(byAccount, video) 26 const url = getVideoLikeActivityPubUrl(byAccount, video)
26 27
27 const accountsInvolvedInVideo = await getAccountsInvolvedInVideo(video, t) 28 const accountsInvolvedInVideo = await getAccountsInvolvedInVideo(video, t)
@@ -34,16 +35,16 @@ async function sendLikeToVideoFollowers (byAccount: AccountInstance, video: Vide
34 35
35async function likeActivityData ( 36async function likeActivityData (
36 url: string, 37 url: string,
37 byAccount: AccountInstance, 38 byAccount: AccountModel,
38 video: VideoInstance, 39 video: VideoModel,
39 t: Transaction, 40 t: Transaction,
40 audience?: ActivityAudience 41 audience?: ActivityAudience
41) { 42): Promise<ActivityLike> {
42 if (!audience) { 43 if (!audience) {
43 audience = await getAudience(byAccount, t) 44 audience = await getAudience(byAccount, t)
44 } 45 }
45 46
46 const activity: ActivityLike = { 47 return {
47 type: 'Like', 48 type: 'Like',
48 id: url, 49 id: url,
49 actor: byAccount.url, 50 actor: byAccount.url,
@@ -51,8 +52,6 @@ async function likeActivityData (
51 cc: audience.cc, 52 cc: audience.cc,
52 object: video.url 53 object: video.url
53 } 54 }
54
55 return activity
56} 55}
57 56
58// --------------------------------------------------------------------------- 57// ---------------------------------------------------------------------------
diff --git a/server/lib/activitypub/send/send-undo.ts b/server/lib/activitypub/send/send-undo.ts
index 015f02b35..699f920f0 100644
--- a/server/lib/activitypub/send/send-undo.ts
+++ b/server/lib/activitypub/send/send-undo.ts
@@ -5,10 +5,10 @@ import {
5 ActivityFollow, 5 ActivityFollow,
6 ActivityLike, 6 ActivityLike,
7 ActivityUndo 7 ActivityUndo
8} from '../../../../shared/models/activitypub/activity' 8} from '../../../../shared/models/activitypub'
9import { AccountInstance } from '../../../models' 9import { AccountModel } from '../../../models/account/account'
10import { AccountFollowInstance } from '../../../models/account/account-follow-interface' 10import { AccountFollowModel } from '../../../models/account/account-follow'
11import { VideoInstance } from '../../../models/video/video-interface' 11import { VideoModel } from '../../../models/video/video'
12import { getAccountFollowActivityPubUrl, getUndoActivityPubUrl, getVideoDislikeActivityPubUrl, getVideoLikeActivityPubUrl } from '../url' 12import { getAccountFollowActivityPubUrl, getUndoActivityPubUrl, getVideoDislikeActivityPubUrl, getVideoLikeActivityPubUrl } from '../url'
13import { 13import {
14 broadcastToFollowers, 14 broadcastToFollowers,
@@ -22,7 +22,7 @@ import { createActivityData, createDislikeActivityData } from './send-create'
22import { followActivityData } from './send-follow' 22import { followActivityData } from './send-follow'
23import { likeActivityData } from './send-like' 23import { likeActivityData } from './send-like'
24 24
25async function sendUndoFollow (accountFollow: AccountFollowInstance, t: Transaction) { 25async function sendUndoFollow (accountFollow: AccountFollowModel, t: Transaction) {
26 const me = accountFollow.AccountFollower 26 const me = accountFollow.AccountFollower
27 const following = accountFollow.AccountFollowing 27 const following = accountFollow.AccountFollowing
28 28
@@ -35,7 +35,7 @@ async function sendUndoFollow (accountFollow: AccountFollowInstance, t: Transact
35 return unicastTo(data, me, following.inboxUrl, t) 35 return unicastTo(data, me, following.inboxUrl, t)
36} 36}
37 37
38async function sendUndoLikeToOrigin (byAccount: AccountInstance, video: VideoInstance, t: Transaction) { 38async function sendUndoLikeToOrigin (byAccount: AccountModel, video: VideoModel, t: Transaction) {
39 const likeUrl = getVideoLikeActivityPubUrl(byAccount, video) 39 const likeUrl = getVideoLikeActivityPubUrl(byAccount, video)
40 const undoUrl = getUndoActivityPubUrl(likeUrl) 40 const undoUrl = getUndoActivityPubUrl(likeUrl)
41 41
@@ -47,7 +47,7 @@ async function sendUndoLikeToOrigin (byAccount: AccountInstance, video: VideoIns
47 return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t) 47 return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t)
48} 48}
49 49
50async function sendUndoLikeToVideoFollowers (byAccount: AccountInstance, video: VideoInstance, t: Transaction) { 50async function sendUndoLikeToVideoFollowers (byAccount: AccountModel, video: VideoModel, t: Transaction) {
51 const likeUrl = getVideoLikeActivityPubUrl(byAccount, video) 51 const likeUrl = getVideoLikeActivityPubUrl(byAccount, video)
52 const undoUrl = getUndoActivityPubUrl(likeUrl) 52 const undoUrl = getUndoActivityPubUrl(likeUrl)
53 53
@@ -60,7 +60,7 @@ async function sendUndoLikeToVideoFollowers (byAccount: AccountInstance, video:
60 return broadcastToFollowers(data, byAccount, toAccountsFollowers, t, followersException) 60 return broadcastToFollowers(data, byAccount, toAccountsFollowers, t, followersException)
61} 61}
62 62
63async function sendUndoDislikeToOrigin (byAccount: AccountInstance, video: VideoInstance, t: Transaction) { 63async function sendUndoDislikeToOrigin (byAccount: AccountModel, video: VideoModel, t: Transaction) {
64 const dislikeUrl = getVideoDislikeActivityPubUrl(byAccount, video) 64 const dislikeUrl = getVideoDislikeActivityPubUrl(byAccount, video)
65 const undoUrl = getUndoActivityPubUrl(dislikeUrl) 65 const undoUrl = getUndoActivityPubUrl(dislikeUrl)
66 66
@@ -74,7 +74,7 @@ async function sendUndoDislikeToOrigin (byAccount: AccountInstance, video: Video
74 return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t) 74 return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t)
75} 75}
76 76
77async function sendUndoDislikeToVideoFollowers (byAccount: AccountInstance, video: VideoInstance, t: Transaction) { 77async function sendUndoDislikeToVideoFollowers (byAccount: AccountModel, video: VideoModel, t: Transaction) {
78 const dislikeUrl = getVideoDislikeActivityPubUrl(byAccount, video) 78 const dislikeUrl = getVideoDislikeActivityPubUrl(byAccount, video)
79 const undoUrl = getUndoActivityPubUrl(dislikeUrl) 79 const undoUrl = getUndoActivityPubUrl(dislikeUrl)
80 80
@@ -103,16 +103,16 @@ export {
103 103
104async function undoActivityData ( 104async function undoActivityData (
105 url: string, 105 url: string,
106 byAccount: AccountInstance, 106 byAccount: AccountModel,
107 object: ActivityFollow | ActivityLike | ActivityCreate, 107 object: ActivityFollow | ActivityLike | ActivityCreate,
108 t: Transaction, 108 t: Transaction,
109 audience?: ActivityAudience 109 audience?: ActivityAudience
110) { 110): Promise<ActivityUndo> {
111 if (!audience) { 111 if (!audience) {
112 audience = await getAudience(byAccount, t) 112 audience = await getAudience(byAccount, t)
113 } 113 }
114 114
115 const activity: ActivityUndo = { 115 return {
116 type: 'Undo', 116 type: 'Undo',
117 id: url, 117 id: url,
118 actor: byAccount.url, 118 actor: byAccount.url,
@@ -120,6 +120,4 @@ async function undoActivityData (
120 cc: audience.cc, 120 cc: audience.cc,
121 object 121 object
122 } 122 }
123
124 return activity
125} 123}
diff --git a/server/lib/activitypub/send/send-update.ts b/server/lib/activitypub/send/send-update.ts
index 59524e523..9baf13a87 100644
--- a/server/lib/activitypub/send/send-update.ts
+++ b/server/lib/activitypub/send/send-update.ts
@@ -1,31 +1,34 @@
1import { Transaction } from 'sequelize' 1import { Transaction } from 'sequelize'
2import { ActivityUpdate } from '../../../../shared/models/activitypub/activity' 2import { ActivityUpdate } from '../../../../shared/models/activitypub'
3import { database as db } from '../../../initializers' 3import { AccountModel } from '../../../models/account/account'
4import { AccountInstance, VideoChannelInstance, VideoInstance } from '../../../models' 4import { VideoModel } from '../../../models/video/video'
5import { VideoChannelModel } from '../../../models/video/video-channel'
6import { VideoChannelShareModel } from '../../../models/video/video-channel-share'
7import { VideoShareModel } from '../../../models/video/video-share'
5import { getUpdateActivityPubUrl } from '../url' 8import { getUpdateActivityPubUrl } from '../url'
6import { broadcastToFollowers, getAudience } from './misc' 9import { broadcastToFollowers, getAudience } from './misc'
7 10
8async function sendUpdateVideoChannel (videoChannel: VideoChannelInstance, t: Transaction) { 11async function sendUpdateVideoChannel (videoChannel: VideoChannelModel, t: Transaction) {
9 const byAccount = videoChannel.Account 12 const byAccount = videoChannel.Account
10 13
11 const url = getUpdateActivityPubUrl(videoChannel.url, videoChannel.updatedAt.toISOString()) 14 const url = getUpdateActivityPubUrl(videoChannel.url, videoChannel.updatedAt.toISOString())
12 const videoChannelObject = videoChannel.toActivityPubObject() 15 const videoChannelObject = videoChannel.toActivityPubObject()
13 const data = await updateActivityData(url, byAccount, videoChannelObject, t) 16 const data = await updateActivityData(url, byAccount, videoChannelObject, t)
14 17
15 const accountsInvolved = await db.VideoChannelShare.loadAccountsByShare(videoChannel.id, t) 18 const accountsInvolved = await VideoChannelShareModel.loadAccountsByShare(videoChannel.id, t)
16 accountsInvolved.push(byAccount) 19 accountsInvolved.push(byAccount)
17 20
18 return broadcastToFollowers(data, byAccount, accountsInvolved, t) 21 return broadcastToFollowers(data, byAccount, accountsInvolved, t)
19} 22}
20 23
21async function sendUpdateVideo (video: VideoInstance, t: Transaction) { 24async function sendUpdateVideo (video: VideoModel, t: Transaction) {
22 const byAccount = video.VideoChannel.Account 25 const byAccount = video.VideoChannel.Account
23 26
24 const url = getUpdateActivityPubUrl(video.url, video.updatedAt.toISOString()) 27 const url = getUpdateActivityPubUrl(video.url, video.updatedAt.toISOString())
25 const videoObject = video.toActivityPubObject() 28 const videoObject = video.toActivityPubObject()
26 const data = await updateActivityData(url, byAccount, videoObject, t) 29 const data = await updateActivityData(url, byAccount, videoObject, t)
27 30
28 const accountsInvolved = await db.VideoShare.loadAccountsByShare(video.id, t) 31 const accountsInvolved = await VideoShareModel.loadAccountsByShare(video.id, t)
29 accountsInvolved.push(byAccount) 32 accountsInvolved.push(byAccount)
30 33
31 return broadcastToFollowers(data, byAccount, accountsInvolved, t) 34 return broadcastToFollowers(data, byAccount, accountsInvolved, t)
@@ -40,9 +43,9 @@ export {
40 43
41// --------------------------------------------------------------------------- 44// ---------------------------------------------------------------------------
42 45
43async function updateActivityData (url: string, byAccount: AccountInstance, object: any, t: Transaction) { 46async function updateActivityData (url: string, byAccount: AccountModel, object: any, t: Transaction): Promise<ActivityUpdate> {
44 const { to, cc } = await getAudience(byAccount, t) 47 const { to, cc } = await getAudience(byAccount, t)
45 const activity: ActivityUpdate = { 48 return {
46 type: 'Update', 49 type: 'Update',
47 id: url, 50 id: url,
48 actor: byAccount.url, 51 actor: byAccount.url,
@@ -50,6 +53,4 @@ async function updateActivityData (url: string, byAccount: AccountInstance, obje
50 cc, 53 cc,
51 object 54 object
52 } 55 }
53
54 return activity
55} 56}