diff options
Diffstat (limited to 'server/lib/activitypub/send/misc.ts')
-rw-r--r-- | server/lib/activitypub/send/misc.ts | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/server/lib/activitypub/send/misc.ts b/server/lib/activitypub/send/misc.ts index 444c1cbd6..fd1add68e 100644 --- a/server/lib/activitypub/send/misc.ts +++ b/server/lib/activitypub/send/misc.ts | |||
@@ -1,13 +1,14 @@ | |||
1 | import { Transaction } from 'sequelize' | 1 | import { Transaction } from 'sequelize' |
2 | import { Activity } from '../../../../shared/models/activitypub/activity' | ||
2 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
3 | import { ACTIVITY_PUB, database as db } from '../../../initializers' | 4 | import { ACTIVITY_PUB, database as db } from '../../../initializers' |
4 | import { AccountInstance } from '../../../models/account/account-interface' | 5 | import { AccountInstance } from '../../../models/account/account-interface' |
6 | import { VideoChannelInstance } from '../../../models/index' | ||
7 | import { VideoInstance } from '../../../models/video/video-interface' | ||
5 | import { | 8 | import { |
6 | activitypubHttpJobScheduler, | 9 | activitypubHttpJobScheduler, |
7 | ActivityPubHttpPayload | 10 | ActivityPubHttpPayload |
8 | } from '../../jobs/activitypub-http-job-scheduler/activitypub-http-job-scheduler' | 11 | } from '../../jobs/activitypub-http-job-scheduler/activitypub-http-job-scheduler' |
9 | import { VideoInstance } from '../../../models/video/video-interface' | ||
10 | import { Activity } from '../../../../shared/models/activitypub/activity' | ||
11 | 12 | ||
12 | async function forwardActivity ( | 13 | async function forwardActivity ( |
13 | activity: Activity, | 14 | activity: Activity, |
@@ -85,9 +86,16 @@ function getOriginVideoAudience (video: VideoInstance, accountsInvolvedInVideo: | |||
85 | } | 86 | } |
86 | } | 87 | } |
87 | 88 | ||
88 | function getVideoFollowersAudience (accountsInvolvedInVideo: AccountInstance[]) { | 89 | function getOriginVideoChannelAudience (videoChannel: VideoChannelInstance, accountsInvolved: AccountInstance[]) { |
90 | return { | ||
91 | to: [ videoChannel.Account.url ], | ||
92 | cc: accountsInvolved.map(a => a.followersUrl) | ||
93 | } | ||
94 | } | ||
95 | |||
96 | function getObjectFollowersAudience (accountsInvolvedInObject: AccountInstance[]) { | ||
89 | return { | 97 | return { |
90 | to: accountsInvolvedInVideo.map(a => a.followersUrl), | 98 | to: accountsInvolvedInObject.map(a => a.followersUrl), |
91 | cc: [] | 99 | cc: [] |
92 | } | 100 | } |
93 | } | 101 | } |
@@ -99,6 +107,13 @@ async function getAccountsInvolvedInVideo (video: VideoInstance) { | |||
99 | return accountsToForwardView | 107 | return accountsToForwardView |
100 | } | 108 | } |
101 | 109 | ||
110 | async function getAccountsInvolvedInVideoChannel (videoChannel: VideoChannelInstance) { | ||
111 | const accountsToForwardView = await db.VideoChannelShare.loadAccountsByShare(videoChannel.id) | ||
112 | accountsToForwardView.push(videoChannel.Account) | ||
113 | |||
114 | return accountsToForwardView | ||
115 | } | ||
116 | |||
102 | async function getAudience (accountSender: AccountInstance, isPublic = true) { | 117 | async function getAudience (accountSender: AccountInstance, isPublic = true) { |
103 | const followerInboxUrls = await accountSender.getFollowerSharedInboxUrls() | 118 | const followerInboxUrls = await accountSender.getFollowerSharedInboxUrls() |
104 | 119 | ||
@@ -131,10 +146,12 @@ async function computeFollowerUris (toAccountFollower: AccountInstance[], follow | |||
131 | 146 | ||
132 | export { | 147 | export { |
133 | broadcastToFollowers, | 148 | broadcastToFollowers, |
149 | getOriginVideoChannelAudience, | ||
134 | unicastTo, | 150 | unicastTo, |
135 | getAudience, | 151 | getAudience, |
136 | getOriginVideoAudience, | 152 | getOriginVideoAudience, |
137 | getAccountsInvolvedInVideo, | 153 | getAccountsInvolvedInVideo, |
138 | getVideoFollowersAudience, | 154 | getAccountsInvolvedInVideoChannel, |
155 | getObjectFollowersAudience, | ||
139 | forwardActivity | 156 | forwardActivity |
140 | } | 157 | } |