From c801434d11a546f5d5375c1798cf9bb981d3f6b2 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 26 Dec 2022 08:50:17 +0900 Subject: [PATCH] =?UTF-8?q?fix(server):=20=E3=82=A2=E3=83=B3=E3=83=86?= =?UTF-8?q?=E3=83=8A=E3=81=AE=E4=BD=9C=E6=88=90=E6=95=B0=E4=B8=8A=E9=99=90?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + .../src/server/api/endpoints/antennas/create.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13c2876a82..af3fc75c06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ You should also include the user name that made the change. - Server: Fix peers API returning suspended instances @ineffyble - Server: trim long text of note from ap @syuilo - Server: Ap inboxの最大ペイロードサイズを64kbに制限 @syuilo +- Server: アンテナの作成数上限を追加 @syuilo - Client: case insensitive emoji search @saschanaz - Client: InAppウィンドウが操作できなくなることがあるのを修正 @tamaina - Client: use proxied image for instance icon @syuilo diff --git a/packages/backend/src/server/api/endpoints/antennas/create.ts b/packages/backend/src/server/api/endpoints/antennas/create.ts index fe24a10300..2378660ec8 100644 --- a/packages/backend/src/server/api/endpoints/antennas/create.ts +++ b/packages/backend/src/server/api/endpoints/antennas/create.ts @@ -26,6 +26,12 @@ export const meta = { code: 'NO_SUCH_USER_GROUP', id: 'aa3c0b9a-8cae-47c0-92ac-202ce5906682', }, + + tooManyAntennas: { + message: 'You cannot create antenna any more.', + code: 'TOO_MANY_ANTENNAS', + id: 'faf47050-e8b5-438c-913c-db2b1576fde4', + }, }, res: { @@ -81,6 +87,13 @@ export default class extends Endpoint { private globalEventService: GlobalEventService, ) { super(meta, paramDef, async (ps, me) => { + const currentAntennasCount = await this.antennasRepository.countBy({ + userId: me.id, + }); + if (currentAntennasCount > 5) { + throw new ApiError(meta.errors.tooManyAntennas); + } + let userList; let userGroupJoining;