diff options
Diffstat (limited to 'server/models/video/video-comment.ts')
-rw-r--r-- | server/models/video/video-comment.ts | 27 |
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 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import * as Bluebird from 'bluebird' |
2 | import { uniq } from 'lodash' | 2 | import { uniq } from 'lodash' |
3 | import { FindOptions, Op, Order, ScopeOptions, Sequelize, Transaction } from 'sequelize' | 3 | import { FindOptions, Op, Order, ScopeOptions, Sequelize, Transaction } from 'sequelize' |
4 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' | 4 | import { |
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' | ||
5 | import { getServerActor } from '@server/models/application/application' | 18 | import { getServerActor } from '@server/models/application/application' |
6 | import { MAccount, MAccountId, MUserAccountId } from '@server/types/models' | 19 | import { MAccount, MAccountId, MUserAccountId } from '@server/types/models' |
7 | import { VideoPrivacy } from '@shared/models' | 20 | import { 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' |
40 | import { VideoCommentAbuseModel } from '../abuse/video-comment-abuse' | ||
27 | import { AccountModel } from '../account/account' | 41 | import { AccountModel } from '../account/account' |
28 | import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor' | 42 | import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor' |
29 | import { buildBlockedAccountSQL, buildLocalAccountIdsIn, getCommentSort, throwIfNotValid } from '../utils' | 43 | import { 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, |