aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/lib/activitypub/process/process-create.ts19
-rw-r--r--server/lib/activitypub/video-comments.ts14
2 files changed, 19 insertions, 14 deletions
diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts
index f84992489..9cded4dec 100644
--- a/server/lib/activitypub/process/process-create.ts
+++ b/server/lib/activitypub/process/process-create.ts
@@ -91,6 +91,7 @@ async function processCreateVideoComment (activity: ActivityCreate, byActor: MAc
91 let comment: MCommentOwnerVideo 91 let comment: MCommentOwnerVideo
92 try { 92 try {
93 const resolveThreadResult = await resolveThread({ url: commentObject.id, isVideo: false }) 93 const resolveThreadResult = await resolveThread({ url: commentObject.id, isVideo: false })
94
94 video = resolveThreadResult.video 95 video = resolveThreadResult.video
95 created = resolveThreadResult.commentCreated 96 created = resolveThreadResult.commentCreated
96 comment = resolveThreadResult.comment 97 comment = resolveThreadResult.comment
@@ -104,16 +105,18 @@ async function processCreateVideoComment (activity: ActivityCreate, byActor: MAc
104 } 105 }
105 106
106 // Try to not forward unwanted commments on our videos 107 // Try to not forward unwanted commments on our videos
107 if (video.isOwned() && await isBlockedByServerOrAccount(comment.Account, video.VideoChannel.Account)) { 108 if (video.isOwned()) {
108 logger.info('Skip comment forward from blocked account or server %s.', comment.Account.Actor.url) 109 if (await isBlockedByServerOrAccount(comment.Account, video.VideoChannel.Account)) {
109 return 110 logger.info('Skip comment forward from blocked account or server %s.', comment.Account.Actor.url)
110 } 111 return
112 }
111 113
112 if (video.isOwned() && created === true) { 114 if (created === true) {
113 // Don't resend the activity to the sender 115 // Don't resend the activity to the sender
114 const exceptions = [ byActor ] 116 const exceptions = [ byActor ]
115 117
116 await forwardVideoRelatedActivity(activity, undefined, exceptions, video) 118 await forwardVideoRelatedActivity(activity, undefined, exceptions, video)
119 }
117 } 120 }
118 121
119 if (created && notify) Notifier.Instance.notifyOnNewComment(comment) 122 if (created && notify) Notifier.Instance.notifyOnNewComment(comment)
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