diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2019-12-28 11:27:31 +0100 |
---|---|---|
committer | Rigel Kent <sendmemail@rigelk.eu> | 2019-12-28 11:48:53 +0100 |
commit | 5b0413ddaa7949a6a44512a8281c5a23466599ae (patch) | |
tree | 07dafe7f97ffc1e7570e8b1ee9515f29d6c2d611 /server/models/video/video-comment.ts | |
parent | bf64ed4196938ba9002c887cadb01bd2a6e3127a (diff) | |
download | PeerTube-5b0413ddaa7949a6a44512a8281c5a23466599ae.tar.gz PeerTube-5b0413ddaa7949a6a44512a8281c5a23466599ae.tar.zst PeerTube-5b0413ddaa7949a6a44512a8281c5a23466599ae.zip |
Add author indicator to the comment replies loader
Diffstat (limited to 'server/models/video/video-comment.ts')
-rw-r--r-- | server/models/video/video-comment.ts | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts index 28f011b03..c2798e82a 100644 --- a/server/models/video/video-comment.ts +++ b/server/models/video/video-comment.ts | |||
@@ -56,6 +56,17 @@ enum ScopeNames { | |||
56 | ')' | 56 | ')' |
57 | ), | 57 | ), |
58 | 'totalReplies' | 58 | 'totalReplies' |
59 | ], | ||
60 | [ | ||
61 | Sequelize.literal( | ||
62 | '(' + | ||
63 | 'SELECT COUNT("replies"."id") ' + | ||
64 | 'FROM "videoComment" AS "replies" ' + | ||
65 | 'WHERE "replies"."originCommentId" = "VideoCommentModel"."id" ' + | ||
66 | 'AND "accountId" = ' + userAccountId + | ||
67 | ')' | ||
68 | ), | ||
69 | 'totalRepliesFromVideoAuthor' | ||
59 | ] | 70 | ] |
60 | ] | 71 | ] |
61 | } | 72 | } |
@@ -501,6 +512,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> { | |||
501 | updatedAt: this.updatedAt, | 512 | updatedAt: this.updatedAt, |
502 | deletedAt: this.deletedAt, | 513 | deletedAt: this.deletedAt, |
503 | isDeleted: this.isDeleted(), | 514 | isDeleted: this.isDeleted(), |
515 | totalRepliesFromVideoAuthor: this.get('totalRepliesFromVideoAuthor') || 0, | ||
504 | totalReplies: this.get('totalReplies') || 0, | 516 | totalReplies: this.get('totalReplies') || 0, |
505 | account: this.Account ? this.Account.toFormattedJSON() : null | 517 | account: this.Account ? this.Account.toFormattedJSON() : null |
506 | } as VideoComment | 518 | } as VideoComment |