mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Fix federation with some actors
That don't have a shared inbox, or a URL
This commit is contained in:
@@ -163,9 +163,12 @@ async function updateActorInstance (actorInstance: ActorModel, attributes: Activ
|
||||
actorInstance.followingCount = followingCount
|
||||
actorInstance.inboxUrl = attributes.inbox
|
||||
actorInstance.outboxUrl = attributes.outbox
|
||||
actorInstance.sharedInboxUrl = attributes.endpoints.sharedInbox
|
||||
actorInstance.followersUrl = attributes.followers
|
||||
actorInstance.followingUrl = attributes.following
|
||||
|
||||
if (attributes.endpoints && attributes.endpoints.sharedInbox) {
|
||||
actorInstance.sharedInboxUrl = attributes.endpoints.sharedInbox
|
||||
}
|
||||
}
|
||||
|
||||
type AvatarInfo = { name: string, onDisk: boolean, fileUrl: string }
|
||||
@@ -437,9 +440,12 @@ async function fetchRemoteActor (actorUrl: string): Promise<{ statusCode?: numbe
|
||||
followingCount: followingCount,
|
||||
inboxUrl: actorJSON.inbox,
|
||||
outboxUrl: actorJSON.outbox,
|
||||
sharedInboxUrl: actorJSON.endpoints.sharedInbox,
|
||||
followersUrl: actorJSON.followers,
|
||||
followingUrl: actorJSON.following
|
||||
followingUrl: actorJSON.following,
|
||||
|
||||
sharedInboxUrl: actorJSON.endpoints && actorJSON.endpoints.sharedInbox
|
||||
? actorJSON.endpoints.sharedInbox
|
||||
: null,
|
||||
})
|
||||
|
||||
const avatarInfo = await getAvatarInfoIfExists(actorJSON)
|
||||
|
||||
@@ -100,7 +100,7 @@ async function sendCreateVideoComment (comment: MCommentOwnerVideo, t: Transacti
|
||||
if (isOrigin) return broadcastToFollowers(createActivity, byActor, actorsInvolvedInComment, t, actorsException)
|
||||
|
||||
// Send to origin
|
||||
t.afterCommit(() => unicastTo(createActivity, byActor, comment.Video.VideoChannel.Account.Actor.sharedInboxUrl))
|
||||
t.afterCommit(() => unicastTo(createActivity, byActor, comment.Video.VideoChannel.Account.Actor.getSharedInbox()))
|
||||
}
|
||||
|
||||
function buildCreateActivity (url: string, byActor: MActorLight, object: any, audience?: ActivityAudience): ActivityCreate {
|
||||
|
||||
@@ -71,7 +71,7 @@ async function sendDeleteVideoComment (videoComment: MCommentOwnerVideoReply, t:
|
||||
if (isVideoOrigin) return broadcastToFollowers(activity, byActor, actorsInvolvedInComment, t, actorsException)
|
||||
|
||||
// Send to origin
|
||||
t.afterCommit(() => unicastTo(activity, byActor, videoComment.Video.VideoChannel.Account.Actor.sharedInboxUrl))
|
||||
t.afterCommit(() => unicastTo(activity, byActor, videoComment.Video.VideoChannel.Account.Actor.getSharedInbox()))
|
||||
}
|
||||
|
||||
async function sendDeleteVideoPlaylist (videoPlaylist: MVideoPlaylistFullSummary, t: Transaction) {
|
||||
|
||||
@@ -18,7 +18,7 @@ async function sendVideoAbuse (byActor: MActor, videoAbuse: MVideoAbuseVideo, vi
|
||||
const audience = { to: [ video.VideoChannel.Account.Actor.url ], cc: [] }
|
||||
const flagActivity = buildFlagActivity(url, byActor, videoAbuse, audience)
|
||||
|
||||
t.afterCommit(() => unicastTo(flagActivity, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl))
|
||||
t.afterCommit(() => unicastTo(flagActivity, byActor, video.VideoChannel.Account.Actor.getSharedInbox()))
|
||||
}
|
||||
|
||||
function buildFlagActivity (url: string, byActor: MActor, videoAbuse: MVideoAbuseVideo, audience: ActivityAudience): ActivityFlag {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { JobQueue } from '../../job-queue'
|
||||
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,
|
||||
@@ -24,7 +24,7 @@ async function sendVideoRelatedActivity (activityBuilder: (audience: ActivityAud
|
||||
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())
|
||||
})
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ async function sendVideoRelatedActivity (activityBuilder: (audience: ActivityAud
|
||||
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
|
||||
@@ -53,7 +53,7 @@ async function forwardVideoRelatedActivity (
|
||||
async function forwardActivity (
|
||||
activity: Activity,
|
||||
t: Transaction,
|
||||
followersException: MActorFollowerException[] = [],
|
||||
followersException: MActorWithInboxes[] = [],
|
||||
additionalFollowerUrls: string[] = []
|
||||
) {
|
||||
logger.info('Forwarding activity %s.', activity.id)
|
||||
@@ -90,7 +90,7 @@ async function broadcastToFollowers (
|
||||
byActor: MActorId,
|
||||
toFollowersOf: MActorId[],
|
||||
t: Transaction,
|
||||
actorsException: MActorFollowerException[] = []
|
||||
actorsException: MActorWithInboxes[] = []
|
||||
) {
|
||||
const uris = await computeFollowerUris(toFollowersOf, actorsException, t)
|
||||
|
||||
@@ -102,7 +102,7 @@ async function broadcastToActors (
|
||||
byActor: MActorId,
|
||||
toActors: MActor[],
|
||||
t?: Transaction,
|
||||
actorsException: MActorFollowerException[] = []
|
||||
actorsException: MActorWithInboxes[] = []
|
||||
) {
|
||||
const uris = await computeUris(toActors, actorsException)
|
||||
return afterCommitIfTransaction(t, () => broadcastTo(uris, data, byActor))
|
||||
@@ -147,7 +147,7 @@ export {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
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)
|
||||
@@ -156,11 +156,11 @@ async function computeFollowerUris (toFollowersOf: MActorId[], actorsException:
|
||||
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)
|
||||
|
||||
@@ -169,10 +169,10 @@ async function computeUris (toActors: MActor[], actorsException: MActorFollowerE
|
||||
.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 ])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user