]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-comment.ts
Add avatar in comments
[github/Chocobozzz/PeerTube.git] / server / models / video / video-comment.ts
index d381ccafa6e352248cc04296a6e8c66b8f4b30f0..d2d8945c3cd8eec776735dbe2ed7af364b02626a 100644 (file)
@@ -9,6 +9,7 @@ import { isActivityPubUrlValid } from '../../helpers/custom-validators/activityp
 import { CONSTRAINTS_FIELDS } from '../../initializers'
 import { AccountModel } from '../account/account'
 import { ActorModel } from '../activitypub/actor'
+import { AvatarModel } from '../avatar/avatar'
 import { ServerModel } from '../server/server'
 import { getSort, throwIfNotValid } from '../utils'
 import { VideoModel } from './video'
@@ -46,6 +47,10 @@ enum ScopeNames {
               {
                 model: () => ServerModel,
                 required: false
+              },
+              {
+                model: () => AvatarModel,
+                required: false
               }
             ]
           }
@@ -214,7 +219,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> {
 
   static listThreadCommentsForApi (videoId: number, threadId: number) {
     const query = {
-      order: [ [ 'id', 'ASC' ] ],
+      order: [ [ 'createdAt', 'ASC' ] ],
       where: {
         videoId,
         [ Sequelize.Op.or ]: [
@@ -243,10 +248,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> {
       createdAt: this.createdAt,
       updatedAt: this.updatedAt,
       totalReplies: this.get('totalReplies') || 0,
-      account: {
-        name: this.Account.name,
-        host: this.Account.Actor.getHost()
-      }
+      account: this.Account.toFormattedJSON()
     } as VideoComment
   }