aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-18 10:53:54 +0100
committerChocobozzz <me@florianbigard.com>2018-01-18 15:42:20 +0100
commitf05a1c30c15d2ae35c11e241ca039a72eeb7d6ad (patch)
tree6d90c0de5dd3ad506e738d447e4f396951ed5624 /server/lib/activitypub
parent1174a8479ab9ee47b3305d668fe757435057a298 (diff)
downloadPeerTube-f05a1c30c15d2ae35c11e241ca039a72eeb7d6ad.tar.gz
PeerTube-f05a1c30c15d2ae35c11e241ca039a72eeb7d6ad.tar.zst
PeerTube-f05a1c30c15d2ae35c11e241ca039a72eeb7d6ad.zip
Don't show videos of remote instance after unfollow
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r--server/lib/activitypub/actor.ts5
-rw-r--r--server/lib/activitypub/process/process-delete.ts9
-rw-r--r--server/lib/activitypub/send/send-delete.ts5
-rw-r--r--server/lib/activitypub/videos.ts3
4 files changed, 16 insertions, 6 deletions
diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts
index 2e0f3cfc2..a39b4e137 100644
--- a/server/lib/activitypub/actor.ts
+++ b/server/lib/activitypub/actor.ts
@@ -309,7 +309,10 @@ async function refreshActorIfNeeded (actor: ActorModel) {
309 309
310 const actorUrl = await getUrlFromWebfinger(actor.preferredUsername, actor.getHost()) 310 const actorUrl = await getUrlFromWebfinger(actor.preferredUsername, actor.getHost())
311 const result = await fetchRemoteActor(actorUrl) 311 const result = await fetchRemoteActor(actorUrl)
312 if (result === undefined) throw new Error('Cannot fetch remote actor in refresh actor.') 312 if (result === undefined) {
313 logger.warn('Cannot fetch remote actor in refresh actor.')
314 return actor
315 }
313 316
314 return sequelizeTypescript.transaction(async t => { 317 return sequelizeTypescript.transaction(async t => {
315 updateInstanceWithAnother(actor, result.actor) 318 updateInstanceWithAnother(actor, result.actor)
diff --git a/server/lib/activitypub/process/process-delete.ts b/server/lib/activitypub/process/process-delete.ts
index 07e6a0075..03eadcbfc 100644
--- a/server/lib/activitypub/process/process-delete.ts
+++ b/server/lib/activitypub/process/process-delete.ts
@@ -10,21 +10,26 @@ import { VideoCommentModel } from '../../../models/video/video-comment'
10import { getOrCreateActorAndServerAndModel } from '../actor' 10import { getOrCreateActorAndServerAndModel } from '../actor'
11 11
12async function processDeleteActivity (activity: ActivityDelete) { 12async function processDeleteActivity (activity: ActivityDelete) {
13 const actor = await getOrCreateActorAndServerAndModel(activity.actor)
14 const objectUrl = typeof activity.object === 'string' ? activity.object : activity.object.id 13 const objectUrl = typeof activity.object === 'string' ? activity.object : activity.object.id
15 14
16 if (actor.url === objectUrl) { 15 if (activity.actor === objectUrl) {
16 let actor = await ActorModel.loadByUrl(activity.actor)
17 if (!actor) return
18
17 if (actor.type === 'Person') { 19 if (actor.type === 'Person') {
18 if (!actor.Account) throw new Error('Actor ' + actor.url + ' is a person but we cannot find it in database.') 20 if (!actor.Account) throw new Error('Actor ' + actor.url + ' is a person but we cannot find it in database.')
19 21
22 actor.Account.Actor = await actor.Account.$get('Actor') as ActorModel
20 return processDeleteAccount(actor.Account) 23 return processDeleteAccount(actor.Account)
21 } else if (actor.type === 'Group') { 24 } else if (actor.type === 'Group') {
22 if (!actor.VideoChannel) throw new Error('Actor ' + actor.url + ' is a group but we cannot find it in database.') 25 if (!actor.VideoChannel) throw new Error('Actor ' + actor.url + ' is a group but we cannot find it in database.')
23 26
27 actor.VideoChannel.Actor = await actor.VideoChannel.$get('Actor') as ActorModel
24 return processDeleteVideoChannel(actor.VideoChannel) 28 return processDeleteVideoChannel(actor.VideoChannel)
25 } 29 }
26 } 30 }
27 31
32 const actor = await getOrCreateActorAndServerAndModel(activity.actor)
28 { 33 {
29 const videoCommentInstance = await VideoCommentModel.loadByUrlAndPopulateAccount(objectUrl) 34 const videoCommentInstance = await VideoCommentModel.loadByUrlAndPopulateAccount(objectUrl)
30 if (videoCommentInstance) { 35 if (videoCommentInstance) {
diff --git a/server/lib/activitypub/send/send-delete.ts b/server/lib/activitypub/send/send-delete.ts
index 995a534a6..9f1ea3bd0 100644
--- a/server/lib/activitypub/send/send-delete.ts
+++ b/server/lib/activitypub/send/send-delete.ts
@@ -23,7 +23,10 @@ async function sendDeleteActor (byActor: ActorModel, t: Transaction) {
23 const url = getDeleteActivityPubUrl(byActor.url) 23 const url = getDeleteActivityPubUrl(byActor.url)
24 const data = deleteActivityData(url, byActor.url, byActor) 24 const data = deleteActivityData(url, byActor.url, byActor)
25 25
26 return broadcastToFollowers(data, byActor, [ byActor ], t) 26 const actorsInvolved = await VideoShareModel.loadActorsByVideoOwner(byActor.id, t)
27 actorsInvolved.push(byActor)
28
29 return broadcastToFollowers(data, byActor, actorsInvolved, t)
27} 30}
28 31
29async function sendDeleteVideoComment (videoComment: VideoCommentModel, t: Transaction) { 32async function sendDeleteVideoComment (videoComment: VideoCommentModel, t: Transaction) {
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index 5b429709f..1d2d46cbc 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -20,17 +20,16 @@ import { VideoShareModel } from '../../models/video/video-share'
20import { getOrCreateActorAndServerAndModel } from './actor' 20import { getOrCreateActorAndServerAndModel } from './actor'
21 21
22function fetchRemoteVideoPreview (video: VideoModel, reject: Function) { 22function fetchRemoteVideoPreview (video: VideoModel, reject: Function) {
23 // FIXME: use url
24 const host = video.VideoChannel.Account.Actor.Server.host 23 const host = video.VideoChannel.Account.Actor.Server.host
25 const path = join(STATIC_PATHS.PREVIEWS, video.getPreviewName()) 24 const path = join(STATIC_PATHS.PREVIEWS, video.getPreviewName())
26 25
26 // We need to provide a callback, if no we could have an uncaught exception
27 return request.get(REMOTE_SCHEME.HTTP + '://' + host + path, err => { 27 return request.get(REMOTE_SCHEME.HTTP + '://' + host + path, err => {
28 if (err) reject(err) 28 if (err) reject(err)
29 }) 29 })
30} 30}
31 31
32async function fetchRemoteVideoDescription (video: VideoModel) { 32async function fetchRemoteVideoDescription (video: VideoModel) {
33 // FIXME: use url
34 const host = video.VideoChannel.Account.Actor.Server.host 33 const host = video.VideoChannel.Account.Actor.Server.host
35 const path = video.getDescriptionPath() 34 const path = video.getDescriptionPath()
36 const options = { 35 const options = {