diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-12 17:53:50 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-13 16:50:33 +0100 |
commit | 3fd3ab2d34d512b160a5e6084d7609be7b4f4452 (patch) | |
tree | e5ca358287fca6ecacce83defcf23af1e8e9f419 /server/lib/activitypub/send/send-update.ts | |
parent | c893d4514e6ecbf282c7985fe5f82b8acd8a1137 (diff) | |
download | PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.tar.gz PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.tar.zst PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.zip |
Move models to typescript-sequelize
Diffstat (limited to 'server/lib/activitypub/send/send-update.ts')
-rw-r--r-- | server/lib/activitypub/send/send-update.ts | 23 |
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 @@ | |||
1 | import { Transaction } from 'sequelize' | 1 | import { Transaction } from 'sequelize' |
2 | import { ActivityUpdate } from '../../../../shared/models/activitypub/activity' | 2 | import { ActivityUpdate } from '../../../../shared/models/activitypub' |
3 | import { database as db } from '../../../initializers' | 3 | import { AccountModel } from '../../../models/account/account' |
4 | import { AccountInstance, VideoChannelInstance, VideoInstance } from '../../../models' | 4 | import { VideoModel } from '../../../models/video/video' |
5 | import { VideoChannelModel } from '../../../models/video/video-channel' | ||
6 | import { VideoChannelShareModel } from '../../../models/video/video-channel-share' | ||
7 | import { VideoShareModel } from '../../../models/video/video-share' | ||
5 | import { getUpdateActivityPubUrl } from '../url' | 8 | import { getUpdateActivityPubUrl } from '../url' |
6 | import { broadcastToFollowers, getAudience } from './misc' | 9 | import { broadcastToFollowers, getAudience } from './misc' |
7 | 10 | ||
8 | async function sendUpdateVideoChannel (videoChannel: VideoChannelInstance, t: Transaction) { | 11 | async 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 | ||
21 | async function sendUpdateVideo (video: VideoInstance, t: Transaction) { | 24 | async 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 | ||
43 | async function updateActivityData (url: string, byAccount: AccountInstance, object: any, t: Transaction) { | 46 | async 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 | } |