mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 19:42:24 +02:00
Don't show videos of remote instance after unfollow
This commit is contained in:
parent
1174a8479a
commit
f05a1c30c1
38 changed files with 402 additions and 211 deletions
|
@ -309,7 +309,10 @@ async function refreshActorIfNeeded (actor: ActorModel) {
|
|||
|
||||
const actorUrl = await getUrlFromWebfinger(actor.preferredUsername, actor.getHost())
|
||||
const result = await fetchRemoteActor(actorUrl)
|
||||
if (result === undefined) throw new Error('Cannot fetch remote actor in refresh actor.')
|
||||
if (result === undefined) {
|
||||
logger.warn('Cannot fetch remote actor in refresh actor.')
|
||||
return actor
|
||||
}
|
||||
|
||||
return sequelizeTypescript.transaction(async t => {
|
||||
updateInstanceWithAnother(actor, result.actor)
|
||||
|
|
|
@ -10,21 +10,26 @@ import { VideoCommentModel } from '../../../models/video/video-comment'
|
|||
import { getOrCreateActorAndServerAndModel } from '../actor'
|
||||
|
||||
async function processDeleteActivity (activity: ActivityDelete) {
|
||||
const actor = await getOrCreateActorAndServerAndModel(activity.actor)
|
||||
const objectUrl = typeof activity.object === 'string' ? activity.object : activity.object.id
|
||||
|
||||
if (actor.url === objectUrl) {
|
||||
if (activity.actor === objectUrl) {
|
||||
let actor = await ActorModel.loadByUrl(activity.actor)
|
||||
if (!actor) return
|
||||
|
||||
if (actor.type === 'Person') {
|
||||
if (!actor.Account) throw new Error('Actor ' + actor.url + ' is a person but we cannot find it in database.')
|
||||
|
||||
actor.Account.Actor = await actor.Account.$get('Actor') as ActorModel
|
||||
return processDeleteAccount(actor.Account)
|
||||
} else if (actor.type === 'Group') {
|
||||
if (!actor.VideoChannel) throw new Error('Actor ' + actor.url + ' is a group but we cannot find it in database.')
|
||||
|
||||
actor.VideoChannel.Actor = await actor.VideoChannel.$get('Actor') as ActorModel
|
||||
return processDeleteVideoChannel(actor.VideoChannel)
|
||||
}
|
||||
}
|
||||
|
||||
const actor = await getOrCreateActorAndServerAndModel(activity.actor)
|
||||
{
|
||||
const videoCommentInstance = await VideoCommentModel.loadByUrlAndPopulateAccount(objectUrl)
|
||||
if (videoCommentInstance) {
|
||||
|
|
|
@ -23,7 +23,10 @@ async function sendDeleteActor (byActor: ActorModel, t: Transaction) {
|
|||
const url = getDeleteActivityPubUrl(byActor.url)
|
||||
const data = deleteActivityData(url, byActor.url, byActor)
|
||||
|
||||
return broadcastToFollowers(data, byActor, [ byActor ], t)
|
||||
const actorsInvolved = await VideoShareModel.loadActorsByVideoOwner(byActor.id, t)
|
||||
actorsInvolved.push(byActor)
|
||||
|
||||
return broadcastToFollowers(data, byActor, actorsInvolved, t)
|
||||
}
|
||||
|
||||
async function sendDeleteVideoComment (videoComment: VideoCommentModel, t: Transaction) {
|
||||
|
|
|
@ -20,17 +20,16 @@ import { VideoShareModel } from '../../models/video/video-share'
|
|||
import { getOrCreateActorAndServerAndModel } from './actor'
|
||||
|
||||
function fetchRemoteVideoPreview (video: VideoModel, reject: Function) {
|
||||
// FIXME: use url
|
||||
const host = video.VideoChannel.Account.Actor.Server.host
|
||||
const path = join(STATIC_PATHS.PREVIEWS, video.getPreviewName())
|
||||
|
||||
// We need to provide a callback, if no we could have an uncaught exception
|
||||
return request.get(REMOTE_SCHEME.HTTP + '://' + host + path, err => {
|
||||
if (err) reject(err)
|
||||
})
|
||||
}
|
||||
|
||||
async function fetchRemoteVideoDescription (video: VideoModel) {
|
||||
// FIXME: use url
|
||||
const host = video.VideoChannel.Account.Actor.Server.host
|
||||
const path = video.getDescriptionPath()
|
||||
const options = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue