]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/extra-utils/moderation/abuses-command.ts
Merge branch 'release/3.3.0' into develop
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / moderation / abuses-command.ts
index 59126d0a927e08619a8d620cc790daf1e17d4813..0db32ba46794a2ae5cd991e464d87b3b7ad583bb 100644 (file)
@@ -1,4 +1,4 @@
-import { pick } from 'lodash'
+import { pick } from '@shared/core-utils'
 import {
   AbuseFilter,
   AbuseMessage,
@@ -7,12 +7,12 @@ import {
   AbuseUpdate,
   AbuseVideoIs,
   AdminAbuse,
+  HttpStatusCode,
   ResultList,
   UserAbuse
 } from '@shared/models'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
-import { AbstractCommand, OverrideCommandOptions } from '../shared'
 import { unwrapBody } from '../requests/requests'
+import { AbstractCommand, OverrideCommandOptions } from '../shared'
 
 export class AbusesCommand extends AbstractCommand {
 
@@ -60,6 +60,7 @@ export class AbusesCommand extends AbstractCommand {
 
       path,
       fields: body,
+      implicitToken: true,
       defaultExpectedStatus: HttpStatusCode.OK_200
     }))
   }
@@ -80,7 +81,7 @@ export class AbusesCommand extends AbstractCommand {
     searchVideo?: string
     searchVideoChannel?: string
   } = {}) {
-    const toPick = [
+    const toPick: (keyof typeof options)[] = [
       'count',
       'filter',
       'id',
@@ -106,6 +107,7 @@ export class AbusesCommand extends AbstractCommand {
 
       path,
       query,
+      implicitToken: true,
       defaultExpectedStatus: HttpStatusCode.OK_200
     })
   }
@@ -119,7 +121,7 @@ export class AbusesCommand extends AbstractCommand {
     search?: string
     state?: AbuseState
   }) {
-    const toPick = [
+    const toPick: (keyof typeof options)[] = [
       'id',
       'search',
       'state',
@@ -138,6 +140,7 @@ export class AbusesCommand extends AbstractCommand {
 
       path,
       query,
+      implicitToken: true,
       defaultExpectedStatus: HttpStatusCode.OK_200
     })
   }
@@ -154,6 +157,7 @@ export class AbusesCommand extends AbstractCommand {
 
       path,
       fields: body,
+      implicitToken: true,
       defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
     })
   }
@@ -164,7 +168,13 @@ export class AbusesCommand extends AbstractCommand {
     const { abuseId } = options
     const path = '/api/v1/abuses/' + abuseId
 
-    return this.deleteRequest({ ...options, path, defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 })
+    return this.deleteRequest({
+      ...options,
+
+      path,
+      implicitToken: true,
+      defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
+    })
   }
 
   listMessages (options: OverrideCommandOptions & {
@@ -173,7 +183,13 @@ export class AbusesCommand extends AbstractCommand {
     const { abuseId } = options
     const path = '/api/v1/abuses/' + abuseId + '/messages'
 
-    return this.getRequestBody<ResultList<AbuseMessage>>({ ...options, path, defaultExpectedStatus: HttpStatusCode.OK_200 })
+    return this.getRequestBody<ResultList<AbuseMessage>>({
+      ...options,
+
+      path,
+      implicitToken: true,
+      defaultExpectedStatus: HttpStatusCode.OK_200
+    })
   }
 
   deleteMessage (options: OverrideCommandOptions & {
@@ -183,7 +199,13 @@ export class AbusesCommand extends AbstractCommand {
     const { abuseId, messageId } = options
     const path = '/api/v1/abuses/' + abuseId + '/messages/' + messageId
 
-    return this.deleteRequest({ ...options, path, defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 })
+    return this.deleteRequest({
+      ...options,
+
+      path,
+      implicitToken: true,
+      defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
+    })
   }
 
   addMessage (options: OverrideCommandOptions & {
@@ -198,6 +220,7 @@ export class AbusesCommand extends AbstractCommand {
 
       path,
       fields: { message },
+      implicitToken: true,
       defaultExpectedStatus: HttpStatusCode.OK_200
     })
   }