mirror of https://github.com/Chocobozzz/PeerTube
Fix actor outbox
parent
9007daff82
commit
e3d5ea4f82
|
@ -47,17 +47,14 @@ async function buildActivities (actor: ActorModel, start: number, count: number)
|
||||||
const actors = data.data.map(v => v.VideoChannel.Account.Actor)
|
const actors = data.data.map(v => v.VideoChannel.Account.Actor)
|
||||||
actors.push(actor)
|
actors.push(actor)
|
||||||
|
|
||||||
const followersMatrix = await ActorModel.getActorsFollowerSharedInboxUrls(actors, undefined)
|
|
||||||
|
|
||||||
for (const video of data.data) {
|
for (const video of data.data) {
|
||||||
const byActor = video.VideoChannel.Account.Actor
|
const byActor = video.VideoChannel.Account.Actor
|
||||||
const createActivityAudience = buildAudience(followersMatrix[byActor.id], video.privacy === VideoPrivacy.PUBLIC)
|
const createActivityAudience = buildAudience([ byActor.followersUrl ], video.privacy === VideoPrivacy.PUBLIC)
|
||||||
|
|
||||||
// This is a shared video
|
// This is a shared video
|
||||||
if (video.VideoShares !== undefined && video.VideoShares.length !== 0) {
|
if (video.VideoShares !== undefined && video.VideoShares.length !== 0) {
|
||||||
const videoShare = video.VideoShares[0]
|
const videoShare = video.VideoShares[0]
|
||||||
const announceAudience = buildAudience(followersMatrix[actor.id], video.privacy === VideoPrivacy.PUBLIC)
|
const announceActivity = await announceActivityData(videoShare.url, actor, video.url, undefined, createActivityAudience)
|
||||||
const announceActivity = await announceActivityData(videoShare.url, actor, video.url, undefined, announceAudience)
|
|
||||||
|
|
||||||
activities.push(announceActivity)
|
activities.push(announceActivity)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -59,14 +59,13 @@ async function getAudience (actorSender: ActorModel, t: Transaction, isPublic =
|
||||||
return buildAudience([ actorSender.followersUrl ], isPublic)
|
return buildAudience([ actorSender.followersUrl ], isPublic)
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildAudience (followerInboxUrls: string[], isPublic = true) {
|
function buildAudience (followerUrls: string[], isPublic = true) {
|
||||||
// Thanks Mastodon: https://github.com/tootsuite/mastodon/blob/master/app/lib/activitypub/tag_manager.rb#L47
|
|
||||||
let to = []
|
let to = []
|
||||||
let cc = []
|
let cc = []
|
||||||
|
|
||||||
if (isPublic) {
|
if (isPublic) {
|
||||||
to = [ ACTIVITY_PUB.PUBLIC ]
|
to = [ ACTIVITY_PUB.PUBLIC ]
|
||||||
cc = followerInboxUrls
|
cc = followerUrls
|
||||||
} else { // Unlisted
|
} else { // Unlisted
|
||||||
to = [ ]
|
to = [ ]
|
||||||
cc = [ ]
|
cc = [ ]
|
||||||
|
|
|
@ -602,6 +602,19 @@ export class VideoModel extends Model<VideoModel> {
|
||||||
attributes: [ 'id', 'url' ],
|
attributes: [ 'id', 'url' ],
|
||||||
model: VideoShareModel.unscoped(),
|
model: VideoShareModel.unscoped(),
|
||||||
required: false,
|
required: false,
|
||||||
|
// We only want videos shared by this actor
|
||||||
|
where: {
|
||||||
|
[Sequelize.Op.and]: [
|
||||||
|
{
|
||||||
|
id: {
|
||||||
|
[Sequelize.Op.not]: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
actorId
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
attributes: [ 'id', 'url' ],
|
attributes: [ 'id', 'url' ],
|
||||||
|
@ -619,14 +632,14 @@ export class VideoModel extends Model<VideoModel> {
|
||||||
required: true,
|
required: true,
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
attributes: [ 'id', 'url' ],
|
attributes: [ 'id', 'url', 'followersUrl' ],
|
||||||
model: ActorModel.unscoped(),
|
model: ActorModel.unscoped(),
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
attributes: [ 'id', 'url' ],
|
attributes: [ 'id', 'url', 'followersUrl' ],
|
||||||
model: ActorModel.unscoped(),
|
model: ActorModel.unscoped(),
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue