aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/video-comments.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-10 14:34:04 +0100
committerChocobozzz <me@florianbigard.com>2020-11-10 14:34:04 +0100
commit403c69c5a34e6db621f30c7b2bfb2b80dc8e74c1 (patch)
tree42831f62cdc211fe08ec1c817d13e1bb8d91ad39 /server/lib/activitypub/video-comments.ts
parentd47044142417065c70cd6c731a500d97fbd306b5 (diff)
downloadPeerTube-403c69c5a34e6db621f30c7b2bfb2b80dc8e74c1.tar.gz
PeerTube-403c69c5a34e6db621f30c7b2bfb2b80dc8e74c1.tar.zst
PeerTube-403c69c5a34e6db621f30c7b2bfb2b80dc8e74c1.zip
Check threads resolve on non federated videos
Diffstat (limited to 'server/lib/activitypub/video-comments.ts')
-rw-r--r--server/lib/activitypub/video-comments.ts14
1 files changed, 8 insertions, 6 deletions
diff --git a/server/lib/activitypub/video-comments.ts b/server/lib/activitypub/video-comments.ts
index dcae2a255..776a295c0 100644
--- a/server/lib/activitypub/video-comments.ts
+++ b/server/lib/activitypub/video-comments.ts
@@ -29,20 +29,18 @@ async function resolveThread (params: ResolveThreadParams): ResolveThreadResult
29 if (params.comments === undefined) params.comments = [] 29 if (params.comments === undefined) params.comments = []
30 30
31 // Already have this comment? 31 // Already have this comment?
32 if (isVideo !== true) { 32 if (isVideo === false) {
33 const result = await resolveCommentFromDB(params) 33 const result = await resolveCommentFromDB(params)
34 if (result) return result 34 if (result) return result
35 } 35 }
36 36
37 try { 37 try {
38 if (isVideo !== false) return await tryResolveThreadFromVideo(params) 38 if (isVideo === true) return tryResolveThreadFromVideo(params)
39
40 return resolveParentComment(params)
41 } catch (err) { 39 } catch (err) {
42 logger.debug('Cannot get or create account and video and channel for reply %s, fetch comment', url, { err }) 40 logger.debug('Cannot get or create account and video and channel for reply %s, fetch comment', url, { err })
43
44 return resolveParentComment(params)
45 } 41 }
42
43 return resolveParentComment(params)
46} 44}
47 45
48export { 46export {
@@ -85,6 +83,10 @@ async function tryResolveThreadFromVideo (params: ResolveThreadParams) {
85 const syncParam = { likes: true, dislikes: true, shares: true, comments: false, thumbnail: true, refreshVideo: false } 83 const syncParam = { likes: true, dislikes: true, shares: true, comments: false, thumbnail: true, refreshVideo: false }
86 const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: url, syncParam }) 84 const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: url, syncParam })
87 85
86 if (video.isOwned() && !video.hasPrivacyForFederation()) {
87 throw new Error('Cannot resolve thread of video with privacy that is not compatible with federation')
88 }
89
88 let resultComment: MCommentOwnerVideo 90 let resultComment: MCommentOwnerVideo
89 if (comments.length !== 0) { 91 if (comments.length !== 0) {
90 const firstReply = comments[comments.length - 1] as MCommentOwnerVideo 92 const firstReply = comments[comments.length - 1] as MCommentOwnerVideo