diff options
Diffstat (limited to 'shared/extra-utils/videos')
-rw-r--r-- | shared/extra-utils/videos/comments-command.ts | 21 | ||||
-rw-r--r-- | shared/extra-utils/videos/videos-command.ts | 10 |
2 files changed, 31 insertions, 0 deletions
diff --git a/shared/extra-utils/videos/comments-command.ts b/shared/extra-utils/videos/comments-command.ts index dd14e4b64..5034c57ad 100644 --- a/shared/extra-utils/videos/comments-command.ts +++ b/shared/extra-utils/videos/comments-command.ts | |||
@@ -5,6 +5,10 @@ import { AbstractCommand, OverrideCommandOptions } from '../shared' | |||
5 | 5 | ||
6 | export class CommentsCommand extends AbstractCommand { | 6 | export class CommentsCommand extends AbstractCommand { |
7 | 7 | ||
8 | private lastVideoId: number | string | ||
9 | private lastThreadId: number | ||
10 | private lastReplyId: number | ||
11 | |||
8 | listForAdmin (options: OverrideCommandOptions & { | 12 | listForAdmin (options: OverrideCommandOptions & { |
9 | start?: number | 13 | start?: number |
10 | count?: number | 14 | count?: number |
@@ -80,6 +84,9 @@ export class CommentsCommand extends AbstractCommand { | |||
80 | defaultExpectedStatus: HttpStatusCode.OK_200 | 84 | defaultExpectedStatus: HttpStatusCode.OK_200 |
81 | })) | 85 | })) |
82 | 86 | ||
87 | this.lastThreadId = body.comment.id | ||
88 | this.lastVideoId = videoId | ||
89 | |||
83 | return body.comment | 90 | return body.comment |
84 | } | 91 | } |
85 | 92 | ||
@@ -100,9 +107,23 @@ export class CommentsCommand extends AbstractCommand { | |||
100 | defaultExpectedStatus: HttpStatusCode.OK_200 | 107 | defaultExpectedStatus: HttpStatusCode.OK_200 |
101 | })) | 108 | })) |
102 | 109 | ||
110 | this.lastReplyId = body.comment.id | ||
111 | |||
103 | return body.comment | 112 | return body.comment |
104 | } | 113 | } |
105 | 114 | ||
115 | async addReplyToLastReply (options: OverrideCommandOptions & { | ||
116 | text: string | ||
117 | }) { | ||
118 | return this.addReply({ ...options, videoId: this.lastVideoId, toCommentId: this.lastReplyId }) | ||
119 | } | ||
120 | |||
121 | async addReplyToLastThread (options: OverrideCommandOptions & { | ||
122 | text: string | ||
123 | }) { | ||
124 | return this.addReply({ ...options, videoId: this.lastVideoId, toCommentId: this.lastThreadId }) | ||
125 | } | ||
126 | |||
106 | async findCommentId (options: OverrideCommandOptions & { | 127 | async findCommentId (options: OverrideCommandOptions & { |
107 | videoId: number | string | 128 | videoId: number | string |
108 | text: string | 129 | text: string |
diff --git a/shared/extra-utils/videos/videos-command.ts b/shared/extra-utils/videos/videos-command.ts index 40cc4dc28..98465e8f6 100644 --- a/shared/extra-utils/videos/videos-command.ts +++ b/shared/extra-utils/videos/videos-command.ts | |||
@@ -267,6 +267,16 @@ export class VideosCommand extends AbstractCommand { | |||
267 | 267 | ||
268 | // --------------------------------------------------------------------------- | 268 | // --------------------------------------------------------------------------- |
269 | 269 | ||
270 | async find (options: OverrideCommandOptions & { | ||
271 | name: string | ||
272 | }) { | ||
273 | const { data } = await this.list(options) | ||
274 | |||
275 | return data.find(v => v.name === options.name) | ||
276 | } | ||
277 | |||
278 | // --------------------------------------------------------------------------- | ||
279 | |||
270 | update (options: OverrideCommandOptions & { | 280 | update (options: OverrideCommandOptions & { |
271 | id: number | string | 281 | id: number | string |
272 | attributes?: VideoEdit | 282 | attributes?: VideoEdit |