aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/extra-utils/requests/requests.ts8
-rw-r--r--shared/extra-utils/shared/abstract-command.ts16
-rw-r--r--shared/extra-utils/videos/videos-command.ts15
3 files changed, 36 insertions, 3 deletions
diff --git a/shared/extra-utils/requests/requests.ts b/shared/extra-utils/requests/requests.ts
index 5bbf7f3bf..501e0b374 100644
--- a/shared/extra-utils/requests/requests.ts
+++ b/shared/extra-utils/requests/requests.ts
@@ -57,9 +57,15 @@ function makeActivityPubGetRequest (url: string, path: string, expectedStatus =
57 }) 57 })
58} 58}
59 59
60function makeDeleteRequest (options: CommonRequestParams) { 60function makeDeleteRequest (options: CommonRequestParams & {
61 query?: any
62 rawQuery?: string
63}) {
61 const req = request(options.url).delete(options.path) 64 const req = request(options.url).delete(options.path)
62 65
66 if (options.query) req.query(options.query)
67 if (options.rawQuery) req.query(options.rawQuery)
68
63 return buildRequest(req, { accept: 'application/json', expectedStatus: HttpStatusCode.BAD_REQUEST_400, ...options }) 69 return buildRequest(req, { accept: 'application/json', expectedStatus: HttpStatusCode.BAD_REQUEST_400, ...options })
64} 70}
65 71
diff --git a/shared/extra-utils/shared/abstract-command.ts b/shared/extra-utils/shared/abstract-command.ts
index 021045e49..a57c857fc 100644
--- a/shared/extra-utils/shared/abstract-command.ts
+++ b/shared/extra-utils/shared/abstract-command.ts
@@ -40,6 +40,11 @@ interface InternalGetCommandOptions extends InternalCommonCommandOptions {
40 query?: { [ id: string ]: any } 40 query?: { [ id: string ]: any }
41} 41}
42 42
43interface InternalDeleteCommandOptions extends InternalCommonCommandOptions {
44 query?: { [ id: string ]: any }
45 rawQuery?: string
46}
47
43abstract class AbstractCommand { 48abstract class AbstractCommand {
44 49
45 constructor ( 50 constructor (
@@ -82,8 +87,15 @@ abstract class AbstractCommand {
82 }) 87 })
83 } 88 }
84 89
85 protected deleteRequest (options: InternalCommonCommandOptions) { 90 protected deleteRequest (options: InternalDeleteCommandOptions) {
86 return makeDeleteRequest(this.buildCommonRequestOptions(options)) 91 const { query, rawQuery } = options
92
93 return makeDeleteRequest({
94 ...this.buildCommonRequestOptions(options),
95
96 query,
97 rawQuery
98 })
87 } 99 }
88 100
89 protected putBodyRequest (options: InternalCommonCommandOptions & { 101 protected putBodyRequest (options: InternalCommonCommandOptions & {
diff --git a/shared/extra-utils/videos/videos-command.ts b/shared/extra-utils/videos/videos-command.ts
index d35339c8d..63980c147 100644
--- a/shared/extra-utils/videos/videos-command.ts
+++ b/shared/extra-utils/videos/videos-command.ts
@@ -449,6 +449,8 @@ export class VideosCommand extends AbstractCommand {
449 449
450 const result = await this.sendResumableChunks({ ...options, pathUploadId, videoFilePath, size }) 450 const result = await this.sendResumableChunks({ ...options, pathUploadId, videoFilePath, size })
451 451
452 await this.endResumableUpload({ ...options, pathUploadId })
453
452 return result.body?.video || result.body as any 454 return result.body?.video || result.body as any
453 } 455 }
454 456
@@ -542,6 +544,19 @@ export class VideosCommand extends AbstractCommand {
542 }) 544 })
543 } 545 }
544 546
547 endResumableUpload (options: OverrideCommandOptions & {
548 pathUploadId: string
549 }) {
550 return this.deleteRequest({
551 ...options,
552
553 path: '/api/v1/videos/upload-resumable',
554 rawQuery: options.pathUploadId,
555 implicitToken: true,
556 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
557 })
558 }
559
545 quickUpload (options: OverrideCommandOptions & { 560 quickUpload (options: OverrideCommandOptions & {
546 name: string 561 name: string
547 nsfw?: boolean 562 nsfw?: boolean