diff options
| author | おさむのひと <46447427+samunohito@users.noreply.github.com> | 2023-11-03 17:34:23 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-03 17:34:23 +0900 |
| commit | 39a3f4ae98ebe436ed023fab737a823717da5e0b (patch) | |
| tree | cadb9e1bb9d24f16527fe6fb912d6a746cc59748 /packages/backend/src/server/api/endpoints/notes | |
| parent | fix(frontend): In deck layout, replies option is not saved after refresh (diff) | |
| download | sharkey-39a3f4ae98ebe436ed023fab737a823717da5e0b.tar.gz sharkey-39a3f4ae98ebe436ed023fab737a823717da5e0b.tar.bz2 sharkey-39a3f4ae98ebe436ed023fab737a823717da5e0b.zip | |
feat: チャンネル内→チャンネル外へのリノート制限機能追加 (#12230)
* チャンネル内→チャンネル外へのリノート制限機能追加
* fix CHANGELOG.md
* コメント対応(canRenoteSwitch→allowRenoteToExternal)
* コメント対応(別チャンネルへのリノート対策)
* コメント対応(canRenote->allowRenoteToExternal)
* fix comment
* Update misskey-js.api.md
* :v:
---------
Co-authored-by: osamu <46447427+sam-osamu@users.noreply.github.com>
Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
Diffstat (limited to 'packages/backend/src/server/api/endpoints/notes')
| -rw-r--r-- | packages/backend/src/server/api/endpoints/notes/create.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/packages/backend/src/server/api/endpoints/notes/create.ts b/packages/backend/src/server/api/endpoints/notes/create.ts index fb650f69ff..df02d3acb7 100644 --- a/packages/backend/src/server/api/endpoints/notes/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/create.ts @@ -99,6 +99,12 @@ export const meta = { code: 'NO_SUCH_FILE', id: 'b6992544-63e7-67f0-fa7f-32444b1b5306', }, + + cannotRenoteOutsideOfChannel: { + message: 'Cannot renote outside of channel.', + code: 'CANNOT_RENOTE_OUTSIDE_OF_CHANNEL', + id: '33510210-8452-094c-6227-4a6c05d99f00', + }, }, } as const; @@ -246,6 +252,19 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- // specified / direct noteはreject throw new ApiError(meta.errors.cannotRenoteDueToVisibility); } + + if (renote.channelId && renote.channelId !== ps.channelId) { + // チャンネルのノートに対しリノート要求がきたとき、チャンネル外へのリノート可否をチェック + // リノートのユースケースのうち、チャンネル内→チャンネル外は少数だと考えられるため、JOINはせず必要な時に都度取得する + const renoteChannel = await this.channelsRepository.findOneById(renote.channelId); + if (renoteChannel == null) { + // リノートしたいノートが書き込まれているチャンネルが無い + throw new ApiError(meta.errors.noSuchChannel); + } else if (!renoteChannel.allowRenoteToExternal) { + // リノート作成のリクエストだが、対象チャンネルがリノート禁止だった場合 + throw new ApiError(meta.errors.cannotRenoteOutsideOfChannel); + } + } } let reply: MiNote | null = null; |