import { getActorsInvolvedInVideo, getAudienceFromFollowersOf, getRemoteVideoAudience } from '../audience'
import { getServerActor } from '../../../helpers/utils'
import { afterCommitIfTransaction } from '../../../helpers/database-utils'
-import { MActorFollowerException, MActor, MActorId, MActorLight, MVideo, MVideoAccountLight } from '../../../typings/models'
+import { MActorWithInboxes, MActor, MActorId, MActorLight, MVideo, MVideoAccountLight } from '../../../typings/models'
async function sendVideoRelatedActivity (activityBuilder: (audience: ActivityAudience) => Activity, options: {
byActor: MActorLight,
const activity = activityBuilder(audience)
return afterCommitIfTransaction(transaction, () => {
- return unicastTo(activity, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl)
+ return unicastTo(activity, byActor, video.VideoChannel.Account.Actor.getSharedInbox())
})
}
async function forwardVideoRelatedActivity (
activity: Activity,
t: Transaction,
- followersException: MActorFollowerException[] = [],
+ followersException: MActorWithInboxes[] = [],
video: MVideo
) {
// Mastodon does not add our announces in audience, so we forward to them manually
async function forwardActivity (
activity: Activity,
t: Transaction,
- followersException: MActorFollowerException[] = [],
+ followersException: MActorWithInboxes[] = [],
additionalFollowerUrls: string[] = []
) {
logger.info('Forwarding activity %s.', activity.id)
byActor: MActorId,
toFollowersOf: MActorId[],
t: Transaction,
- actorsException: MActorFollowerException[] = []
+ actorsException: MActorWithInboxes[] = []
) {
const uris = await computeFollowerUris(toFollowersOf, actorsException, t)
byActor: MActorId,
toActors: MActor[],
t?: Transaction,
- actorsException: MActorFollowerException[] = []
+ actorsException: MActorWithInboxes[] = []
) {
const uris = await computeUris(toActors, actorsException)
return afterCommitIfTransaction(t, () => broadcastTo(uris, data, byActor))
// ---------------------------------------------------------------------------
-async function computeFollowerUris (toFollowersOf: MActorId[], actorsException: MActorFollowerException[], t: Transaction) {
+async function computeFollowerUris (toFollowersOf: MActorId[], actorsException: MActorWithInboxes[], t: Transaction) {
const toActorFollowerIds = toFollowersOf.map(a => a.id)
const result = await ActorFollowModel.listAcceptedFollowerSharedInboxUrls(toActorFollowerIds, t)
return result.data.filter(sharedInbox => sharedInboxesException.indexOf(sharedInbox) === -1)
}
-async function computeUris (toActors: MActor[], actorsException: MActorFollowerException[] = []) {
+async function computeUris (toActors: MActor[], actorsException: MActorWithInboxes[] = []) {
const serverActor = await getServerActor()
const targetUrls = toActors
.filter(a => a.id !== serverActor.id) // Don't send to ourselves
- .map(a => a.sharedInboxUrl || a.inboxUrl)
+ .map(a => a.getSharedInbox())
const toActorSharedInboxesSet = new Set(targetUrls)
.filter(sharedInbox => sharedInboxesException.indexOf(sharedInbox) === -1)
}
-async function buildSharedInboxesException (actorsException: MActorFollowerException[]) {
+async function buildSharedInboxesException (actorsException: MActorWithInboxes[]) {
const serverActor = await getServerActor()
return actorsException
- .map(f => f.sharedInboxUrl || f.inboxUrl)
+ .map(f => f.getSharedInbox())
.concat([ serverActor.sharedInboxUrl ])
}