diff options
Diffstat (limited to 'server/lib/activitypub/send/send-update.ts')
-rw-r--r-- | server/lib/activitypub/send/send-update.ts | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/server/lib/activitypub/send/send-update.ts b/server/lib/activitypub/send/send-update.ts index e8f11edd0..622648308 100644 --- a/server/lib/activitypub/send/send-update.ts +++ b/server/lib/activitypub/send/send-update.ts | |||
@@ -1,9 +1,10 @@ | |||
1 | import { Transaction } from 'sequelize' | 1 | import { Transaction } from 'sequelize' |
2 | import { ActivityAudience, ActivityUpdate } from '../../../../shared/models/activitypub' | 2 | import { ActivityAudience, ActivityUpdate } from '../../../../shared/models/activitypub' |
3 | import { VideoPrivacy } from '../../../../shared/models/videos' | 3 | import { VideoPrivacy } from '../../../../shared/models/videos' |
4 | import { UserModel } from '../../../models/account/user' | 4 | import { AccountModel } from '../../../models/account/account' |
5 | import { ActorModel } from '../../../models/activitypub/actor' | 5 | import { ActorModel } from '../../../models/activitypub/actor' |
6 | import { VideoModel } from '../../../models/video/video' | 6 | import { VideoModel } from '../../../models/video/video' |
7 | import { VideoChannelModel } from '../../../models/video/video-channel' | ||
7 | import { VideoShareModel } from '../../../models/video/video-share' | 8 | import { VideoShareModel } from '../../../models/video/video-share' |
8 | import { getUpdateActivityPubUrl } from '../url' | 9 | import { getUpdateActivityPubUrl } from '../url' |
9 | import { audiencify, broadcastToFollowers, getAudience } from './misc' | 10 | import { audiencify, broadcastToFollowers, getAudience } from './misc' |
@@ -23,15 +24,23 @@ async function sendUpdateVideo (video: VideoModel, t: Transaction) { | |||
23 | return broadcastToFollowers(data, byActor, actorsInvolved, t) | 24 | return broadcastToFollowers(data, byActor, actorsInvolved, t) |
24 | } | 25 | } |
25 | 26 | ||
26 | async function sendUpdateUser (user: UserModel, t: Transaction) { | 27 | async function sendUpdateActor (accountOrChannel: AccountModel | VideoChannelModel, t: Transaction) { |
27 | const byActor = user.Account.Actor | 28 | const byActor = accountOrChannel.Actor |
28 | 29 | ||
29 | const url = getUpdateActivityPubUrl(byActor.url, byActor.updatedAt.toISOString()) | 30 | const url = getUpdateActivityPubUrl(byActor.url, byActor.updatedAt.toISOString()) |
30 | const accountObject = user.Account.toActivityPubObject() | 31 | const accountOrChannelObject = accountOrChannel.toActivityPubObject() |
31 | const audience = await getAudience(byActor, t) | 32 | const audience = await getAudience(byActor, t) |
32 | const data = await updateActivityData(url, byActor, accountObject, t, audience) | 33 | const data = await updateActivityData(url, byActor, accountOrChannelObject, t, audience) |
34 | |||
35 | let actorsInvolved: ActorModel[] | ||
36 | if (accountOrChannel instanceof AccountModel) { | ||
37 | // Actors that shared my videos are involved too | ||
38 | actorsInvolved = await VideoShareModel.loadActorsByVideoOwner(byActor.id, t) | ||
39 | } else { | ||
40 | // Actors that shared videos of my channel are involved too | ||
41 | actorsInvolved = await VideoShareModel.loadActorsByVideoChannel(accountOrChannel.id, t) | ||
42 | } | ||
33 | 43 | ||
34 | const actorsInvolved = await VideoShareModel.loadActorsByVideoOwner(byActor.id, t) | ||
35 | actorsInvolved.push(byActor) | 44 | actorsInvolved.push(byActor) |
36 | 45 | ||
37 | return broadcastToFollowers(data, byActor, actorsInvolved, t) | 46 | return broadcastToFollowers(data, byActor, actorsInvolved, t) |
@@ -40,7 +49,7 @@ async function sendUpdateUser (user: UserModel, t: Transaction) { | |||
40 | // --------------------------------------------------------------------------- | 49 | // --------------------------------------------------------------------------- |
41 | 50 | ||
42 | export { | 51 | export { |
43 | sendUpdateUser, | 52 | sendUpdateActor, |
44 | sendUpdateVideo | 53 | sendUpdateVideo |
45 | } | 54 | } |
46 | 55 | ||