aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/process
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub/process')
-rw-r--r--server/lib/activitypub/process/process-create.ts36
1 files changed, 22 insertions, 14 deletions
diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts
index 6c2ee97eb..628942a58 100644
--- a/server/lib/activitypub/process/process-create.ts
+++ b/server/lib/activitypub/process/process-create.ts
@@ -257,11 +257,11 @@ function createVideoComment (byActor: ActorModel, activity: ActivityCreate) {
257 if (!byAccount) throw new Error('Cannot create video comment with the non account actor ' + byActor.url) 257 if (!byAccount) throw new Error('Cannot create video comment with the non account actor ' + byActor.url)
258 258
259 return sequelizeTypescript.transaction(async t => { 259 return sequelizeTypescript.transaction(async t => {
260 const video = await VideoModel.loadByUrl(comment.inReplyTo, t) 260 let video = await VideoModel.loadByUrl(comment.inReplyTo, t)
261 261
262 // This is a new thread 262 // This is a new thread
263 if (video) { 263 if (video) {
264 return VideoCommentModel.create({ 264 await VideoCommentModel.create({
265 url: comment.id, 265 url: comment.id,
266 text: comment.content, 266 text: comment.content,
267 originCommentId: null, 267 originCommentId: null,
@@ -269,19 +269,27 @@ function createVideoComment (byActor: ActorModel, activity: ActivityCreate) {
269 videoId: video.id, 269 videoId: video.id,
270 accountId: byAccount.id 270 accountId: byAccount.id
271 }, { transaction: t }) 271 }, { transaction: t })
272 } 272 } else {
273 const inReplyToComment = await VideoCommentModel.loadByUrl(comment.inReplyTo, t)
274 if (!inReplyToComment) throw new Error('Unknown replied comment ' + comment.inReplyTo)
273 275
274 const inReplyToComment = await VideoCommentModel.loadByUrl(comment.inReplyTo, t) 276 video = await VideoModel.load(inReplyToComment.videoId)
275 if (!inReplyToComment) throw new Error('Unknown replied comment ' + comment.inReplyTo)
276 277
277 const originCommentId = inReplyToComment.originCommentId || inReplyToComment.id 278 const originCommentId = inReplyToComment.originCommentId || inReplyToComment.id
278 return VideoCommentModel.create({ 279 await VideoCommentModel.create({
279 url: comment.id, 280 url: comment.id,
280 text: comment.content, 281 text: comment.content,
281 originCommentId, 282 originCommentId,
282 inReplyToCommentId: inReplyToComment.id, 283 inReplyToCommentId: inReplyToComment.id,
283 videoId: inReplyToComment.videoId, 284 videoId: video.id,
284 accountId: byAccount.id 285 accountId: byAccount.id
285 }, { transaction: t }) 286 }, { transaction: t })
287 }
288
289 if (video.isOwned()) {
290 // Don't resend the activity to the sender
291 const exceptions = [ byActor ]
292 await forwardActivity(activity, t, exceptions)
293 }
286 }) 294 })
287} 295}