diff options
Diffstat (limited to 'server/lib/video-comment.ts')
-rw-r--r-- | server/lib/video-comment.ts | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/server/lib/video-comment.ts b/server/lib/video-comment.ts index ef6a8f097..0d744c526 100644 --- a/server/lib/video-comment.ts +++ b/server/lib/video-comment.ts | |||
@@ -1,29 +1,32 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import { ResultList } from '../../shared/models' | 2 | import { ResultList } from '../../shared/models' |
3 | import { VideoCommentThreadTree } from '../../shared/models/videos/video-comment.model' | 3 | import { VideoCommentThreadTree } from '../../shared/models/videos/video-comment.model' |
4 | import { AccountModel } from '../models/account/account' | ||
4 | import { VideoModel } from '../models/video/video' | 5 | import { VideoModel } from '../models/video/video' |
5 | import { VideoCommentModel } from '../models/video/video-comment' | 6 | import { VideoCommentModel } from '../models/video/video-comment' |
6 | import { getVideoCommentActivityPubUrl, sendVideoRateChangeToFollowers } from './activitypub' | 7 | import { getVideoCommentActivityPubUrl } from './activitypub' |
7 | import { sendCreateVideoCommentToOrigin, sendCreateVideoCommentToVideoFollowers } from './activitypub/send' | 8 | import { sendCreateVideoCommentToOrigin, sendCreateVideoCommentToVideoFollowers } from './activitypub/send' |
8 | 9 | ||
9 | async function createVideoComment (obj: { | 10 | async function createVideoComment (obj: { |
10 | text: string, | 11 | text: string, |
11 | inReplyToComment: VideoCommentModel, | 12 | inReplyToComment: VideoCommentModel, |
12 | video: VideoModel | 13 | video: VideoModel |
13 | accountId: number | 14 | account: AccountModel |
14 | }, t: Sequelize.Transaction) { | 15 | }, t: Sequelize.Transaction) { |
15 | let originCommentId: number = null | 16 | let originCommentId: number = null |
17 | let inReplyToCommentId: number = null | ||
16 | 18 | ||
17 | if (obj.inReplyToComment) { | 19 | if (obj.inReplyToComment) { |
18 | originCommentId = obj.inReplyToComment.originCommentId || obj.inReplyToComment.id | 20 | originCommentId = obj.inReplyToComment.originCommentId || obj.inReplyToComment.id |
21 | inReplyToCommentId = obj.inReplyToComment.id | ||
19 | } | 22 | } |
20 | 23 | ||
21 | const comment = await VideoCommentModel.create({ | 24 | const comment = await VideoCommentModel.create({ |
22 | text: obj.text, | 25 | text: obj.text, |
23 | originCommentId, | 26 | originCommentId, |
24 | inReplyToCommentId: obj.inReplyToComment.id, | 27 | inReplyToCommentId, |
25 | videoId: obj.video.id, | 28 | videoId: obj.video.id, |
26 | accountId: obj.accountId, | 29 | accountId: obj.account.id, |
27 | url: 'fake url' | 30 | url: 'fake url' |
28 | }, { transaction: t, validate: false }) | 31 | }, { transaction: t, validate: false }) |
29 | 32 | ||
@@ -32,6 +35,7 @@ async function createVideoComment (obj: { | |||
32 | const savedComment = await comment.save({ transaction: t }) | 35 | const savedComment = await comment.save({ transaction: t }) |
33 | savedComment.InReplyToVideoComment = obj.inReplyToComment | 36 | savedComment.InReplyToVideoComment = obj.inReplyToComment |
34 | savedComment.Video = obj.video | 37 | savedComment.Video = obj.video |
38 | savedComment.Account = obj.account | ||
35 | 39 | ||
36 | if (savedComment.Video.isOwned()) { | 40 | if (savedComment.Video.isOwned()) { |
37 | await sendCreateVideoCommentToVideoFollowers(savedComment, t) | 41 | await sendCreateVideoCommentToVideoFollowers(savedComment, t) |