import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers/constants'
import { AccountModel } from '../account/account'
import { ActorModel } from '../activitypub/actor'
-import { buildBlockedAccountSQL, buildLocalAccountIdsIn, getSort, throwIfNotValid } from '../utils'
+import { buildBlockedAccountSQL, buildLocalAccountIdsIn, getCommentSort, throwIfNotValid } from '../utils'
import { VideoModel } from './video'
import { VideoChannelModel } from './video-channel'
import { getServerActor } from '../../helpers/utils'
')'
),
'totalReplies'
+ ],
+ [
+ Sequelize.literal(
+ '(' +
+ 'SELECT COUNT("replies"."id") ' +
+ 'FROM "videoComment" AS "replies" ' +
+ 'INNER JOIN "video" ON "video"."id" = "replies"."videoId" ' +
+ 'INNER JOIN "videoChannel" ON "videoChannel"."id" = "video"."channelId" ' +
+ 'WHERE "replies"."originCommentId" = "VideoCommentModel"."id" ' +
+ 'AND "replies"."accountId" = "videoChannel"."accountId"' +
+ ')'
+ ),
+ 'totalRepliesFromVideoAuthor'
]
]
}
const query = {
offset: start,
limit: count,
- order: getSort(sort),
+ order: getCommentSort(sort),
where: {
videoId,
inReplyToCommentId: null,
updatedAt: this.updatedAt,
deletedAt: this.deletedAt,
isDeleted: this.isDeleted(),
+ totalRepliesFromVideoAuthor: this.get('totalRepliesFromVideoAuthor') || 0,
totalReplies: this.get('totalReplies') || 0,
account: this.Account ? this.Account.toFormattedJSON() : null
} as VideoComment