]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/extra-utils/bulk/bulk.ts
Introduce CustomPage command
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / bulk / bulk.ts
index d6798ceb762c24ac7182c04fe463afb4710b9a15..a58fb3fbba7781d9b88cebbc12006b209e6e4606 100644 (file)
@@ -1,24 +1,20 @@
-import { BulkRemoveCommentsOfBody } from "@shared/models/bulk/bulk-remove-comments-of-body.model"
-import { makePostBodyRequest } from "../requests/requests"
 
-function bulkRemoveCommentsOf (options: {
-  url: string
-  token: string
-  attributes: BulkRemoveCommentsOfBody
-  expectedStatus?: number
-}) {
-  const { url, token, attributes, expectedStatus } = options
-  const path = '/api/v1/bulk/remove-comments-of'
+import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model'
+import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
+import { AbstractCommand, OverrideCommandOptions } from '../shared'
 
-  return makePostBodyRequest({
-    url,
-    path,
-    token,
-    fields: attributes,
-    statusCodeExpected: expectedStatus || 204
-  })
-}
+export class BulkCommand extends AbstractCommand {
+
+  removeCommentsOf (options: OverrideCommandOptions & {
+    attributes: BulkRemoveCommentsOfBody
+  }) {
+    const { attributes } = options
 
-export {
-  bulkRemoveCommentsOf
+    return this.postBodyRequest({
+      ...options,
+      path: '/api/v1/bulk/remove-comments-of',
+      fields: attributes,
+      defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
+    })
+  }
 }