]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/extra-utils/videos/comments-command.ts
Add ability for instances to follow any actor
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / videos / comments-command.ts
index dd14e4b641ea4d893d504d54b3332fe82d164264..5034c57ad5190ca796be87c85b1cbcbd4cdca217 100644 (file)
@@ -5,6 +5,10 @@ import { AbstractCommand, OverrideCommandOptions } from '../shared'
 
 export class CommentsCommand extends AbstractCommand {
 
+  private lastVideoId: number | string
+  private lastThreadId: number
+  private lastReplyId: number
+
   listForAdmin (options: OverrideCommandOptions & {
     start?: number
     count?: number
@@ -80,6 +84,9 @@ export class CommentsCommand extends AbstractCommand {
       defaultExpectedStatus: HttpStatusCode.OK_200
     }))
 
+    this.lastThreadId = body.comment.id
+    this.lastVideoId = videoId
+
     return body.comment
   }
 
@@ -100,9 +107,23 @@ export class CommentsCommand extends AbstractCommand {
       defaultExpectedStatus: HttpStatusCode.OK_200
     }))
 
+    this.lastReplyId = body.comment.id
+
     return body.comment
   }
 
+  async addReplyToLastReply (options: OverrideCommandOptions & {
+    text: string
+  }) {
+    return this.addReply({ ...options, videoId: this.lastVideoId, toCommentId: this.lastReplyId })
+  }
+
+  async addReplyToLastThread (options: OverrideCommandOptions & {
+    text: string
+  }) {
+    return this.addReply({ ...options, videoId: this.lastVideoId, toCommentId: this.lastThreadId })
+  }
+
   async findCommentId (options: OverrideCommandOptions & {
     videoId: number | string
     text: string