aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/send/misc.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub/send/misc.ts')
-rw-r--r--server/lib/activitypub/send/misc.ts27
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 @@
1import { Transaction } from 'sequelize' 1import { Transaction } from 'sequelize'
2import { Activity } from '../../../../shared/models/activitypub/activity'
2import { logger } from '../../../helpers/logger' 3import { logger } from '../../../helpers/logger'
3import { ACTIVITY_PUB, database as db } from '../../../initializers' 4import { ACTIVITY_PUB, database as db } from '../../../initializers'
4import { AccountInstance } from '../../../models/account/account-interface' 5import { AccountInstance } from '../../../models/account/account-interface'
6import { VideoChannelInstance } from '../../../models/index'
7import { VideoInstance } from '../../../models/video/video-interface'
5import { 8import {
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'
9import { VideoInstance } from '../../../models/video/video-interface'
10import { Activity } from '../../../../shared/models/activitypub/activity'
11 12
12async function forwardActivity ( 13async function forwardActivity (
13 activity: Activity, 14 activity: Activity,
@@ -85,9 +86,16 @@ function getOriginVideoAudience (video: VideoInstance, accountsInvolvedInVideo:
85 } 86 }
86} 87}
87 88
88function getVideoFollowersAudience (accountsInvolvedInVideo: AccountInstance[]) { 89function getOriginVideoChannelAudience (videoChannel: VideoChannelInstance, accountsInvolved: AccountInstance[]) {
90 return {
91 to: [ videoChannel.Account.url ],
92 cc: accountsInvolved.map(a => a.followersUrl)
93 }
94}
95
96function 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
110async function getAccountsInvolvedInVideoChannel (videoChannel: VideoChannelInstance) {
111 const accountsToForwardView = await db.VideoChannelShare.loadAccountsByShare(videoChannel.id)
112 accountsToForwardView.push(videoChannel.Account)
113
114 return accountsToForwardView
115}
116
102async function getAudience (accountSender: AccountInstance, isPublic = true) { 117async 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
132export { 147export {
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}