aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/send/send-update.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub/send/send-update.ts')
-rw-r--r--server/lib/activitypub/send/send-update.ts23
1 files changed, 12 insertions, 11 deletions
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}