mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 10:19:35 +02:00
Send video comment comments to followers/origin
This commit is contained in:
parent
e2e22e40f9
commit
ea44f375f5
5 changed files with 118 additions and 51 deletions
|
@ -257,11 +257,11 @@ function createVideoComment (byActor: ActorModel, activity: ActivityCreate) {
|
|||
if (!byAccount) throw new Error('Cannot create video comment with the non account actor ' + byActor.url)
|
||||
|
||||
return sequelizeTypescript.transaction(async t => {
|
||||
const video = await VideoModel.loadByUrl(comment.inReplyTo, t)
|
||||
let video = await VideoModel.loadByUrl(comment.inReplyTo, t)
|
||||
|
||||
// This is a new thread
|
||||
if (video) {
|
||||
return VideoCommentModel.create({
|
||||
await VideoCommentModel.create({
|
||||
url: comment.id,
|
||||
text: comment.content,
|
||||
originCommentId: null,
|
||||
|
@ -269,19 +269,27 @@ function createVideoComment (byActor: ActorModel, activity: ActivityCreate) {
|
|||
videoId: video.id,
|
||||
accountId: byAccount.id
|
||||
}, { transaction: t })
|
||||
} else {
|
||||
const inReplyToComment = await VideoCommentModel.loadByUrl(comment.inReplyTo, t)
|
||||
if (!inReplyToComment) throw new Error('Unknown replied comment ' + comment.inReplyTo)
|
||||
|
||||
video = await VideoModel.load(inReplyToComment.videoId)
|
||||
|
||||
const originCommentId = inReplyToComment.originCommentId || inReplyToComment.id
|
||||
await VideoCommentModel.create({
|
||||
url: comment.id,
|
||||
text: comment.content,
|
||||
originCommentId,
|
||||
inReplyToCommentId: inReplyToComment.id,
|
||||
videoId: video.id,
|
||||
accountId: byAccount.id
|
||||
}, { transaction: t })
|
||||
}
|
||||
|
||||
const inReplyToComment = await VideoCommentModel.loadByUrl(comment.inReplyTo, t)
|
||||
if (!inReplyToComment) throw new Error('Unknown replied comment ' + comment.inReplyTo)
|
||||
|
||||
const originCommentId = inReplyToComment.originCommentId || inReplyToComment.id
|
||||
return VideoCommentModel.create({
|
||||
url: comment.id,
|
||||
text: comment.content,
|
||||
originCommentId,
|
||||
inReplyToCommentId: inReplyToComment.id,
|
||||
videoId: inReplyToComment.videoId,
|
||||
accountId: byAccount.id
|
||||
}, { transaction: t })
|
||||
if (video.isOwned()) {
|
||||
// Don't resend the activity to the sender
|
||||
const exceptions = [ byActor ]
|
||||
await forwardActivity(activity, t, exceptions)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue