diff options
| author | yupix <yupi0982@outlook.jp> | 2024-06-22 14:52:27 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-22 14:52:27 +0900 |
| commit | b50eb511b0cf6fb05d37c3370726f940c1438a99 (patch) | |
| tree | 52e14d01a8a52799da0cf7796caab1c244f04a6b /packages/backend/src/server/api/endpoints/gallery | |
| parent | fix(backend): フィードのノートのMFMはHTMLにレンダーしてか... (diff) | |
| download | misskey-b50eb511b0cf6fb05d37c3370726f940c1438a99.tar.gz misskey-b50eb511b0cf6fb05d37c3370726f940c1438a99.tar.bz2 misskey-b50eb511b0cf6fb05d37c3370726f940c1438a99.zip | |
refactor: api/*/update系の必須キーを最低限に (#13824)
* refactor: clips/updateの必須キーをclipIdのみに
* refactor: admin/roles/update の必須キーをroleIdのみに
* feat: pages/update の必須キーをpageIdのみに
* refactor: gallery/posts/update の必須キーをpostidのみに
* feat: misskey-jsの型を更新
* feat: i/webhooks/updateの必須キーをwebhookIdのみに
* feat: admin/ad/updateの必須キーをidのみに
* feat: misskey-jsの型を更新
* chore: update CHANGELOG.md
* docs: update CHANGELOG.md
* fix: secretが更新できなくなる場合がある
Co-authored-by: zyoshoka <107108195+zyoshoka@users.noreply.github.com>
* Update packages/backend/src/server/api/endpoints/gallery/posts/update.ts
---------
Co-authored-by: zyoshoka <107108195+zyoshoka@users.noreply.github.com>
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
Diffstat (limited to 'packages/backend/src/server/api/endpoints/gallery')
| -rw-r--r-- | packages/backend/src/server/api/endpoints/gallery/posts/update.ts | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/update.ts b/packages/backend/src/server/api/endpoints/gallery/posts/update.ts index 2f977784ec..5243ee9603 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts/update.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts/update.ts @@ -47,7 +47,7 @@ export const paramDef = { } }, isSensitive: { type: 'boolean', default: false }, }, - required: ['postId', 'title', 'fileIds'], + required: ['postId'], } as const; @Injectable() @@ -62,15 +62,19 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- private galleryPostEntityService: GalleryPostEntityService, ) { super(meta, paramDef, async (ps, me) => { - const files = (await Promise.all(ps.fileIds.map(fileId => - this.driveFilesRepository.findOneBy({ - id: fileId, - userId: me.id, - }), - ))).filter(x => x != null); + let files: Array<MiDriveFile> | undefined; - if (files.length === 0) { - throw new Error(); + if (ps.fileIds) { + files = (await Promise.all(ps.fileIds.map(fileId => + this.driveFilesRepository.findOneBy({ + id: fileId, + userId: me.id, + }), + ))).filter(x => x != null); + + if (files.length === 0) { + throw new Error(); + } } await this.galleryPostsRepository.update({ @@ -81,7 +85,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- title: ps.title, description: ps.description, isSensitive: ps.isSensitive, - fileIds: files.map(file => file.id), + fileIds: files ? files.map(file => file.id) : undefined, }); const post = await this.galleryPostsRepository.findOneByOrFail({ id: ps.postId }); |