aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-comment.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video-comment.ts')
-rw-r--r--server/models/video/video-comment.ts27
1 files changed, 25 insertions, 2 deletions
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts
index 90625d987..75b914b8c 100644
--- a/server/models/video/video-comment.ts
+++ b/server/models/video/video-comment.ts
@@ -1,7 +1,20 @@
1import * as Bluebird from 'bluebird' 1import * as Bluebird from 'bluebird'
2import { uniq } from 'lodash' 2import { uniq } from 'lodash'
3import { FindOptions, Op, Order, ScopeOptions, Sequelize, Transaction } from 'sequelize' 3import { FindOptions, Op, Order, ScopeOptions, Sequelize, Transaction } from 'sequelize'
4import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' 4import {
5 AllowNull,
6 BelongsTo,
7 Column,
8 CreatedAt,
9 DataType,
10 ForeignKey,
11 HasMany,
12 Is,
13 Model,
14 Scopes,
15 Table,
16 UpdatedAt
17} from 'sequelize-typescript'
5import { getServerActor } from '@server/models/application/application' 18import { getServerActor } from '@server/models/application/application'
6import { MAccount, MAccountId, MUserAccountId } from '@server/types/models' 19import { MAccount, MAccountId, MUserAccountId } from '@server/types/models'
7import { VideoPrivacy } from '@shared/models' 20import { VideoPrivacy } from '@shared/models'
@@ -24,6 +37,7 @@ import {
24 MCommentOwnerVideoReply, 37 MCommentOwnerVideoReply,
25 MVideoImmutable 38 MVideoImmutable
26} from '../../types/models/video' 39} from '../../types/models/video'
40import { VideoCommentAbuseModel } from '../abuse/video-comment-abuse'
27import { AccountModel } from '../account/account' 41import { AccountModel } from '../account/account'
28import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor' 42import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor'
29import { buildBlockedAccountSQL, buildLocalAccountIdsIn, getCommentSort, throwIfNotValid } from '../utils' 43import { buildBlockedAccountSQL, buildLocalAccountIdsIn, getCommentSort, throwIfNotValid } from '../utils'
@@ -224,6 +238,15 @@ export class VideoCommentModel extends Model<VideoCommentModel> {
224 }) 238 })
225 Account: AccountModel 239 Account: AccountModel
226 240
241 @HasMany(() => VideoCommentAbuseModel, {
242 foreignKey: {
243 name: 'videoCommentId',
244 allowNull: true
245 },
246 onDelete: 'set null'
247 })
248 CommentAbuses: VideoCommentAbuseModel[]
249
227 static loadById (id: number, t?: Transaction): Bluebird<MComment> { 250 static loadById (id: number, t?: Transaction): Bluebird<MComment> {
228 const query: FindOptions = { 251 const query: FindOptions = {
229 where: { 252 where: {
@@ -632,7 +655,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> {
632 id: this.id, 655 id: this.id,
633 url: this.url, 656 url: this.url,
634 text: this.text, 657 text: this.text,
635 threadId: this.originCommentId || this.id, 658 threadId: this.getThreadId(),
636 inReplyToCommentId: this.inReplyToCommentId || null, 659 inReplyToCommentId: this.inReplyToCommentId || null,
637 videoId: this.videoId, 660 videoId: this.videoId,
638 createdAt: this.createdAt, 661 createdAt: this.createdAt,