Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

リストの登録上限判定が1つずれている #12279

Closed
mumincacao opened this issue Nov 7, 2023 · 0 comments · Fixed by #14036
Closed

リストの登録上限判定が1つずれている #12279

mumincacao opened this issue Nov 7, 2023 · 0 comments · Fixed by #14036
Labels
🐛Bug Unexpected behavior packages/backend Server side specific issue/PR

Comments

@mumincacao
Copy link

💡 Summary

  • ユーザリストの作成可能数
  • ユーザリスト内のユーザの最大数

で設定された値より1つリストやユーザを多く登録できる。

🥰 Expected Behavior

登録上限を超えて登録しようとしたらエラーが出てほしい。

🤬 Actual Behavior

上限+1個目の登録でも通常通り処理されて 51/50ユーザー のような表示になる。

📝 Steps to Reproduce

ユーザリストの作成可能数

  1. 設定された上限までリストを作る
  2. もう1つリストを作る

ユーザリスト内のユーザの最大数

  1. 1つのリストに設定された上限までユーザを登録する
  2. もう一人ユーザを登録する

ローカル環境を構築して試したところ以下の修正で想定通りの動作になりました。

diff --git a/packages/backend/src/core/UserListService.ts b/packages/backend/src/core/UserListService.ts
index 702c731fc..64b7f65bb 100644
--- a/packages/backend/src/core/UserListService.ts
+++ b/packages/backend/src/core/UserListService.ts
@@ -88,7 +88,7 @@ export class UserListService implements OnApplicationShutdown {
                const currentCount = await this.userListMembershipsRepository.countBy({
                        userListId: list.id,
                });
-               if (currentCount > (await this.roleService.getUserPolicies(me.id)).userEachUserListsLimit) {
+               if (currentCount >= (await this.roleService.getUserPolicies(me.id)).userEachUserListsLimit) {
                        throw new UserListService.TooManyUsersError();
                }

diff --git a/packages/backend/src/server/api/endpoints/users/lists/create.ts b/packages/backend/src/server/api/endpoints/users/lists/create.ts
index e86e4c0de..09c95c5a9 100644
--- a/packages/backend/src/server/api/endpoints/users/lists/create.ts
+++ b/packages/backend/src/server/api/endpoints/users/lists/create.ts
@@ -61,7 +61,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
                        const currentCount = await this.userListsRepository.countBy({
                                userId: me.id,
                        });
-                       if (currentCount > (await this.roleService.getUserPolicies(me.id)).userListLimit) {
+                       if (currentCount >= (await this.roleService.getUserPolicies(me.id)).userListLimit) {
                                throw new ApiError(meta.errors.tooManyUserLists);
                        }

💻 Frontend Environment

* Model and OS of the device(s): Windows 10 Pro 22H2 19045.3570
* Browser: Firefox 119.0 (64 ビット)
* Server URL: localhost
* Misskey: 2023.11.0

🛰 Backend Environment (for server admin)

* Installation Method or Hosting Service: docker compose
* Misskey: 2023.11.0
* Node: v20.5.1
* PostgreSQL: 15.4
* Redis: 7.2.3
* OS and Architecture: Ubuntu 20.04.6 LTS x86_64
@mumincacao mumincacao added the ⚠️bug? This might be a bug label Nov 7, 2023
@KisaragiEffective KisaragiEffective added 🐛Bug Unexpected behavior packages/backend Server side specific issue/PR and removed ⚠️bug? This might be a bug labels Jun 18, 2024
@KisaragiEffective KisaragiEffective linked a pull request Jun 18, 2024 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛Bug Unexpected behavior packages/backend Server side specific issue/PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants